From 4350054ab86b03b2a4e6641238b762fd80a3c5dd Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 9 Aug 2012 18:54:40 +0200 Subject: revamp preparation of command line for qmake calls in makefiles instead of re-assembling a list from the variables, take the original command line minus some explicitly stripped out options. this is way less code and poses no synchronization problem between the two parts. as a "side effect", variables obtained from $QMAKEFLAGS won't multiply with each makefile nesting level, as the generated command line won't replicate data obtained from the environment. Change-Id: I5d1ce0f11efb338f60405529f9818910103b1b0e Reviewed-by: Joerg Bornemann --- qmake/generators/makefile.cpp | 52 ++++++------------------------------------- qmake/generators/makefile.h | 2 +- qmake/option.cpp | 20 +++++++++++------ qmake/option.h | 3 +-- 4 files changed, 22 insertions(+), 55 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 1bdf10c131..d109ae053b 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2147,50 +2147,12 @@ QString MakefileGenerator::fixifySpecdir(const QString &spec, const QString &out return spec; } -QString MakefileGenerator::buildArgs(const QString &outdir) +QString MakefileGenerator::buildArgs() { QString ret; - //special variables - if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH")) - ret += " QMAKE_ABSOLUTE_SOURCE_PATH=" + escapeFilePath(project->first("QMAKE_ABSOLUTE_SOURCE_PATH")); - - //warnings - else if(Option::warn_level == WarnNone) - ret += " -Wnone"; - else if(Option::warn_level == WarnAll) - ret += " -Wall"; - else if(Option::warn_level & WarnParser) - ret += " -Wparser"; - //other options - if(!Option::user_template.isEmpty()) - ret += " -t " + Option::user_template; - if(!Option::user_template_prefix.isEmpty()) - ret += " -tp " + Option::user_template_prefix; - if(!Option::mkfile::do_cache) - ret += " -nocache"; - if(!Option::mkfile::do_deps) - ret += " -nodepend"; - if(!Option::mkfile::do_dep_heuristics) - ret += " -nodependheuristics"; - if(!Option::mkfile::qmakespec_commandline.isEmpty()) - ret += " -spec " + fixifySpecdir(Option::mkfile::qmakespec, outdir); - if (!Option::mkfile::xqmakespec_commandline.isEmpty()) - ret += " -xspec " + fixifySpecdir(Option::mkfile::xqmakespec, outdir); - - //arguments - for(QStringList::Iterator it = Option::before_user_vars.begin(); - it != Option::before_user_vars.end(); ++it) { - if((*it).left(qstrlen("QMAKE_ABSOLUTE_SOURCE_PATH")) != "QMAKE_ABSOLUTE_SOURCE_PATH") - ret += " " + escapeFilePath((*it)); - } - if(Option::after_user_vars.count()) { - ret += " -after "; - for(QStringList::Iterator it = Option::after_user_vars.begin(); - it != Option::after_user_vars.end(); ++it) { - if((*it).left(qstrlen("QMAKE_ABSOLUTE_SOURCE_PATH")) != "QMAKE_ABSOLUTE_SOURCE_PATH") - ret += " " + escapeFilePath((*it)); - } - } + + foreach (const QString &arg, Option::qmake_args) + ret += " " + escapeFilePath(arg); return ret; } @@ -2201,7 +2163,7 @@ QString MakefileGenerator::build_args(const QString &outdir) QString ret = "$(QMAKE)"; // general options and arguments - ret += buildArgs(outdir); + ret += buildArgs(); //output QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.fileName())); @@ -2358,7 +2320,7 @@ MakefileGenerator::writeSubTargetCall(QTextStream &t, if (!in_directory.isEmpty()) t << "\n\t" << mkdir_p_asstring(out_directory); pfx = "( " + chkfile + " " + out + " " + chkglue - + "$(QMAKE) " + in + buildArgs(in_directory) + " -o " + out + + "$(QMAKE) " + in + buildArgs() + " -o " + out + " ) && "; } writeSubMakeCall(t, out_directory_cdin + pfx, makefilein); @@ -2447,7 +2409,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList 1 && arg.startsWith('-')) { /* options */ QString opt = arg.mid(1); if(opt == "o" || opt == "output") { - Option::output.setFileName(args.at(++x)); + Option::output.setFileName(args.at(x + 1)); + args.erase(args.begin() + x, args.begin() + x + 2); + continue; } else if(opt == "after") { before = false; } else if(opt == "t" || opt == "template") { @@ -260,8 +261,12 @@ Option::parseCommandLine(QStringList &args) Option::warn_level = WarnNone; } else if(opt == "r" || opt == "recursive") { Option::recursive = true; + args.removeAt(x); + continue; } else if(opt == "nr" || opt == "norecursive") { Option::recursive = false; + args.removeAt(x); + continue; } else if(opt == "config") { user_configs += args.at(++x); } else { @@ -282,11 +287,9 @@ Option::parseCommandLine(QStringList &args) } else if(opt == "cache") { Option::mkfile::cachefile = args.at(++x); } else if(opt == "platform" || opt == "spec") { - Option::mkfile::qmakespec = cleanSpec(args.at(++x)); - Option::mkfile::qmakespec_commandline = args.at(x); + Option::mkfile::qmakespec = args[x] = cleanSpec(args.at(++x)); } else if (opt == "xplatform" || opt == "xspec") { - Option::mkfile::xqmakespec = cleanSpec(args.at(++x)); - Option::mkfile::xqmakespec_commandline = args.at(x); + Option::mkfile::xqmakespec = args[x] = cleanSpec(args.at(x)); } else { fprintf(stderr, "***Unknown option -%s\n", opt.toLatin1().constData()); return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR; @@ -333,6 +336,8 @@ Option::parseCommandLine(QStringList &args) if(!handled) { return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR; } + args.removeAt(x); + continue; } } x++; @@ -474,6 +479,7 @@ Option::init(int argc, char **argv) return ret; //return ret == QMAKE_CMDLINE_SHOW_USAGE ? usage(argv[0]) : false; } + Option::qmake_args = args; } //last chance for defaults diff --git a/qmake/option.h b/qmake/option.h index 0b3fe2dd8f..cab8426db0 100644 --- a/qmake/option.h +++ b/qmake/option.h @@ -161,6 +161,7 @@ struct Option //all modes static QString qmake_abslocation; + static QStringList qmake_args; static QFile output; static QString output_dir; static int debug_level; @@ -195,8 +196,6 @@ struct Option static QString cachefile; static int cachefile_depth; static QStringList project_files; - static QString qmakespec_commandline; - static QString xqmakespec_commandline; }; private: -- cgit v1.2.3