From 93ee903da7b10326b40bc43d5f5c659d527e8814 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 21 Feb 2012 12:44:27 +0100 Subject: [PATCH] clean up build pass project initialization instead of messing with the Option singleton, add a way to inject extra config values into QMakeProject. Change-Id: Ia347dcc38af2c72913e30ebf5c2b4044f93b4f5f Reviewed-by: Joerg Bornemann Reviewed-by: Marius Storm-Olsen --- qmake/generators/metamakefile.cpp | 16 ++++++---------- qmake/option.cpp | 1 - qmake/option.h | 2 +- qmake/project.cpp | 18 ++++++++++++++---- qmake/project.h | 3 +++ 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index b9fec023ab..55ab0a5af5 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -238,25 +238,21 @@ MakefileGenerator //initialize the base QHash basevars; + QStringList basecfgs; if(!project->isEmpty(build + ".CONFIG")) - basevars["CONFIG"] += project->values(build + ".CONFIG"); - basevars["CONFIG"] += build; - basevars["CONFIG"] += "build_pass"; + basecfgs = project->values(build + ".CONFIG"); + basecfgs += build; + basecfgs += "build_pass"; + basevars["CONFIG"] = basecfgs; basevars["BUILD_PASS"] = QStringList(build); QStringList buildname = project->values(build + ".name"); basevars["BUILD_NAME"] = (buildname.isEmpty() ? QStringList(build) : buildname); //create project QMakeProject *build_proj = new QMakeProject(project->properties(), basevars); + build_proj->setExtraConfigs(basecfgs); - //all the user configs must be set again afterwards (for .pro tests and for .prf tests) - const QStringList old_after_user_config = Option::after_user_configs; - const QStringList old_user_config = Option::user_configs; - Option::after_user_configs += basevars["CONFIG"]; - Option::user_configs += basevars["CONFIG"]; build_proj->read(project->projectFile()); - Option::after_user_configs = old_after_user_config; - Option::user_configs = old_user_config; //done return createMakefileGenerator(build_proj); diff --git a/qmake/option.cpp b/qmake/option.cpp index 93a0ffbd9c..c73eb149ec 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -92,7 +92,6 @@ Option::QMAKE_RECURSIVE Option::recursive = Option::QMAKE_RECURSIVE_DEFAULT; QStringList Option::before_user_vars; QStringList Option::after_user_vars; QStringList Option::user_configs; -QStringList Option::after_user_configs; QString Option::user_template; QString Option::user_template_prefix; QStringList Option::shellPath; diff --git a/qmake/option.h b/qmake/option.h index 96549bb5bc..d1bfcd169b 100644 --- a/qmake/option.h +++ b/qmake/option.h @@ -173,7 +173,7 @@ struct Option static int warn_level; 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; + static QStringList before_user_vars, after_user_vars, user_configs; enum HOST_MODE { HOST_UNKNOWN_MODE, HOST_UNIX_MODE, HOST_WIN_MODE, HOST_MACX_MODE }; static HOST_MODE host_mode; enum TARG_MODE { TARG_UNKNOWN_MODE, TARG_UNIX_MODE, TARG_WIN_MODE, TARG_MACX_MODE, diff --git a/qmake/project.cpp b/qmake/project.cpp index 0533ab30b5..8aa3ed2ed6 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -1326,6 +1326,14 @@ QMakeProject::read(uchar cmd) parse("CONFIG += " + Option::user_configs.join(" "), vars); } + // After user configs, to override them + if (!extra_configs.isEmpty()) { + parser.file = "(extra configs)"; + parser.from_file = false; + parser.line_no = 1; //really arg count now.. duh + parse("CONFIG += " + extra_configs.join(" "), vars); + } + if(cmd & ReadProFile) { // parse project file debug_msg(1, "Project file: reading %s", pfile.toLatin1().constData()); if(pfile != "-" && !QFile::exists(pfile) && !pfile.endsWith(Option::pro_ext)) @@ -1349,12 +1357,14 @@ QMakeProject::read(uchar cmd) } } - //after configs (set in BUILDS) - if ((cmd & ReadSetup) && !Option::after_user_configs.isEmpty()) { - parser.file = "(configs)"; + // Again, to ensure the project does not mess with us. + // Specifically, do not allow a project to override debug/release within a + // debug_and_release build pass - it's too late for that at this point anyway. + if (!extra_configs.isEmpty()) { + parser.file = "(extra configs)"; parser.from_file = false; parser.line_no = 1; //really arg count now.. duh - parse("CONFIG += " + Option::after_user_configs.join(" "), vars); + parse("CONFIG += " + extra_configs.join(" "), vars); } if(cmd & ReadFeatures) { diff --git a/qmake/project.h b/qmake/project.h index ce90be035f..43623a3974 100644 --- a/qmake/project.h +++ b/qmake/project.h @@ -84,6 +84,7 @@ class QMakeProject QString pfile, cfile; QMakeProperty *prop; void reset(); + QStringList extra_configs; QHash vars, base_vars; bool parse(const QString &text, QHash &place, int line_count=1); @@ -118,6 +119,8 @@ public: QMakeProject(QMakeProperty *p, const QHash &nvars) { init(p, &nvars); } ~QMakeProject(); + void setExtraConfigs(const QStringList &_cfgs) { extra_configs = _cfgs; } + enum { ReadProFile=0x01, ReadSetup=0x02, ReadFeatures=0x04, ReadAll=0xFF }; inline bool parse(const QString &text) { return parse(text, vars); } bool read(const QString &project, uchar cmd=ReadAll);