diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2010-02-22 15:41:35 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2010-02-26 13:29:15 (GMT) |
commit | e795e61ef93f8080f9938ac49f2fca306644af85 (patch) | |
tree | 9974fbf6a1d84929c6014c450b9f4d3b30e5fb5c /qmake | |
parent | d7404e4ce890139c1447f892009c8a30f6dd6314 (diff) | |
download | Qt-e795e61ef93f8080f9938ac49f2fca306644af85.zip Qt-e795e61ef93f8080f9938ac49f2fca306644af85.tar.gz Qt-e795e61ef93f8080f9938ac49f2fca306644af85.tar.bz2 |
add possibility to request project recursion from within a pro file
this is the same as specifying -r on the command line, but it can be set
in pro and spec files for cases where no recursion would plain not work.
the implementation is via a new option() instruction which at some point
will be used to set other "modes of operation" as well. for now, only
the "recursive" option is recognized.
Reviewed-by: mariusSO
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/generators/metamakefile.cpp | 12 | ||||
-rw-r--r-- | qmake/generators/projectgenerator.cpp | 9 | ||||
-rw-r--r-- | qmake/option.cpp | 10 | ||||
-rw-r--r-- | qmake/option.h | 3 | ||||
-rw-r--r-- | qmake/project.cpp | 21 | ||||
-rw-r--r-- | qmake/project.h | 3 |
6 files changed, 44 insertions, 14 deletions
diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index f48491c..81fd12e 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -293,7 +293,15 @@ SubdirsMetaMakefileGenerator::init() init_flag = true; bool hasError = false; - if(Option::recursive) { + // It might make sense to bequeath the CONFIG option to the recursed + // projects. OTOH, one would most likely have it in all projects anyway - + // either through a qmakespec, a .qmake.cache or explicitly - as otherwise + // running qmake in a subdirectory would have a different auto-recurse + // setting than in parent directories. + bool recurse = Option::recursive == Option::QMAKE_RECURSIVE_YES + || (Option::recursive == Option::QMAKE_RECURSIVE_DEFAULT + && project->isRecursive()); + if(recurse) { QString old_output_dir = Option::output_dir; QString old_output = Option::output.fileName(); QString oldpwd = qmake_getpwd(); @@ -375,7 +383,7 @@ SubdirsMetaMakefileGenerator::init() Subdir *self = new Subdir; self->input_dir = qmake_getpwd(); self->output_dir = Option::output_dir; - if(!Option::recursive || (!Option::output.fileName().endsWith(Option::dir_sep) && !QFileInfo(Option::output).isDir())) + if(!recurse || (!Option::output.fileName().endsWith(Option::dir_sep) && !QFileInfo(Option::output).isDir())) self->output_file = Option::output.fileName(); self->makefile = new BuildsMetaMakefileGenerator(project, name, false); self->makefile->init(); diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp index 8622cd9..d225635 100644 --- a/qmake/generators/projectgenerator.cpp +++ b/qmake/generators/projectgenerator.cpp @@ -111,7 +111,7 @@ ProjectGenerator::init() add_depend = true; if(dir.right(1) != Option::dir_sep) dir += Option::dir_sep; - if(Option::recursive) { + if(Option::recursive == Option::QMAKE_RECURSIVE_YES) { QStringList files = QDir(dir).entryList(QDir::Files); for(int i = 0; i < (int)files.count(); i++) { if(files[i] != "." && files[i] != "..") @@ -138,7 +138,7 @@ ProjectGenerator::init() dir = regex.left(s+1); regex = regex.right(regex.length() - (s+1)); } - if(Option::recursive) { + if(Option::recursive == Option::QMAKE_RECURSIVE_YES) { QStringList entries = QDir(dir).entryList(QDir::Dirs); for(int i = 0; i < (int)entries.count(); i++) { if(entries[i] != "." && entries[i] != "..") { @@ -193,7 +193,7 @@ ProjectGenerator::init() subdirs.append(nd); } } - if(Option::recursive) { + if(Option::recursive == Option::QMAKE_RECURSIVE_YES) { QStringList dirs = QDir(newdir).entryList(QDir::Dirs); for(int i = 0; i < (int)dirs.count(); i++) { QString nd = fileFixify(newdir + QDir::separator() + dirs[i]); @@ -230,7 +230,8 @@ ProjectGenerator::init() } } } - if(Option::recursive && !knownDirs.contains(newdir, Qt::CaseInsensitive)) + if(Option::recursive == Option::QMAKE_RECURSIVE_YES + && !knownDirs.contains(newdir, Qt::CaseInsensitive)) knownDirs.append(newdir); } } diff --git a/qmake/option.cpp b/qmake/option.cpp index 18f0541..592e3eb 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -88,7 +88,7 @@ int Option::warn_level = WarnLogic; int Option::debug_level = 0; QFile Option::output; QString Option::output_dir; -bool Option::recursive = false; +Option::QMAKE_RECURSIVE Option::recursive = Option::QMAKE_RECURSIVE_DEFAULT; QStringList Option::before_user_vars; QStringList Option::after_user_vars; QStringList Option::user_configs; @@ -223,7 +223,7 @@ Option::parseCommandLine(int argc, char **argv, int skip) if(x == 1) { bool specified = true; if(opt == "project") { - Option::recursive = true; + Option::recursive = Option::QMAKE_RECURSIVE_YES; Option::qmake_mode = Option::QMAKE_GENERATE_PROJECT; } else if(opt == "prl") { Option::mkfile::do_deps = false; @@ -279,9 +279,9 @@ Option::parseCommandLine(int argc, char **argv, int skip) } else if(opt == "Wnone") { Option::warn_level = WarnNone; } else if(opt == "r" || opt == "recursive") { - Option::recursive = true; - } else if(opt == "norecursive") { - Option::recursive = false; + Option::recursive = Option::QMAKE_RECURSIVE_YES; + } else if(opt == "nr" || opt == "norecursive") { + Option::recursive = Option::QMAKE_RECURSIVE_NO; } else if(opt == "config") { Option::user_configs += argv[++x]; } else { diff --git a/qmake/option.h b/qmake/option.h index 514e442..3ee1743 100644 --- a/qmake/option.h +++ b/qmake/option.h @@ -148,7 +148,8 @@ struct Option static QString output_dir; static int debug_level; static int warn_level; - static bool recursive; + enum QMAKE_RECURSIVE { QMAKE_RECURSIVE_DEFAULT, QMAKE_RECURSIVE_YES, QMAKE_RECURSIVE_NO }; + static QMAKE_RECURSIVE recursive; static QStringList before_user_vars, after_user_vars, user_configs, after_user_configs; enum TARG_MODE { TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE }; static TARG_MODE target_mode; diff --git a/qmake/project.cpp b/qmake/project.cpp index 4193163..db1db58 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -121,7 +121,7 @@ enum TestFunc { T_REQUIRES=1, T_GREATERTHAN, T_LESSTHAN, T_EQUALS, T_EXISTS, T_EXPORT, T_CLEAR, T_UNSET, T_EVAL, T_CONFIG, T_SYSTEM, T_RETURN, T_BREAK, T_NEXT, T_DEFINED, T_CONTAINS, T_INFILE, T_COUNT, T_ISEMPTY, T_INCLUDE, T_LOAD, T_DEBUG, T_ERROR, - T_MESSAGE, T_WARNING, T_IF }; + T_MESSAGE, T_WARNING, T_IF, T_OPTION }; QMap<QString, TestFunc> qmake_testFunctions() { static QMap<QString, TestFunc> *qmake_test_functions = 0; @@ -155,6 +155,7 @@ QMap<QString, TestFunc> qmake_testFunctions() qmake_test_functions->insert("error", T_ERROR); qmake_test_functions->insert("message", T_MESSAGE); qmake_test_functions->insert("warning", T_WARNING); + qmake_test_functions->insert("option", T_OPTION); } return *qmake_test_functions; } @@ -547,7 +548,7 @@ static void init_symbian(const QMap<QString, QStringList>& vars) // Force recursive on Symbian, as non-recursive is not really a viable option there if (isForSymbian_value != isForSymbian_FALSE) - Option::recursive = true; + Option::recursive = Option::QMAKE_RECURSIVE_YES; } bool isForSymbian() @@ -766,6 +767,7 @@ QMakeProject::reset() scope_blocks.push(ScopeBlock()); iterator = 0; function = 0; + recursive = false; } bool @@ -2768,6 +2770,21 @@ QMakeProject::doProjectTest(QString func, QList<QStringList> args_list, QMap<QSt exit(2); #endif return true; } + case T_OPTION: + if (args.count() != 1) { + fprintf(stderr, "%s:%d: option() requires one argument.\n", + parser.file.toLatin1().constData(), parser.line_no); + return false; + } + if (args.first() == "recursive") { + recursive = true; + } else { + fprintf(stderr, "%s:%d: unrecognized option() argument '%s'.\n", + parser.file.toLatin1().constData(), parser.line_no, + args.first().toLatin1().constData()); + return false; + } + return true; default: fprintf(stderr, "%s:%d: Unknown test function: %s\n", parser.file.toLatin1().constData(), parser.line_no, func.toLatin1().constData()); diff --git a/qmake/project.h b/qmake/project.h index 1f53bf2..a8dcc28 100644 --- a/qmake/project.h +++ b/qmake/project.h @@ -78,6 +78,7 @@ class QMakeProject FunctionBlock *function; QMap<QString, FunctionBlock*> testFunctions, replaceFunctions; + bool recursive; bool own_prop; QString pfile, cfile; QMakeProperty *prop; @@ -154,6 +155,8 @@ public: QString first(const QString &v); QMap<QString, QStringList> &variables(); + bool isRecursive() const { return recursive; } + protected: friend class MakefileGenerator; bool read(const QString &file, QMap<QString, QStringList> &place); |