diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-02-03 18:12:52 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2018-03-14 15:32:47 +0000 |
commit | bfbe67a2554a4531eac42e0407febec112ce9590 (patch) | |
tree | bf5067e2384a64ff970d90f1d4dd3e5eba7f7ad3 /src | |
parent | dd482d681f8909c77614638eb34db3e296b60df5 (diff) |
qmake: add a bunch of complementary options to -after
in particular, -before (just for symmetry, as it's the default), -early
(the actual objective), and -late (for symmetry again).
Change-Id: I274303582a348b052c3e5106ff360ab4fd7d4ee2
(cherry picked from qtbase/4adc1012e19f5e12ab2fb96effc9ea88d2a05eda)
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/proparser/qmakeevaluator.cpp | 12 | ||||
-rw-r--r-- | src/shared/proparser/qmakeglobals.cpp | 33 | ||||
-rw-r--r-- | src/shared/proparser/qmakeglobals.h | 13 |
3 files changed, 33 insertions, 25 deletions
diff --git a/src/shared/proparser/qmakeevaluator.cpp b/src/shared/proparser/qmakeevaluator.cpp index 5d7d9c5420..4b9ebe8f20 100644 --- a/src/shared/proparser/qmakeevaluator.cpp +++ b/src/shared/proparser/qmakeevaluator.cpp @@ -1442,6 +1442,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( if (flags & LoadPreFiles) { setupProject(); + if (!m_option->extra_cmds[QMakeEvalEarly].isEmpty()) + evaluateCommand(m_option->extra_cmds[QMakeEvalEarly], fL1S("(command line -early)")); + for (ProValueMap::ConstIterator it = m_extraVars.constBegin(); it != m_extraVars.constEnd(); ++it) m_valuemapStack.first().insert(it.key(), it.value()); @@ -1453,8 +1456,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( if ((vr = evaluateFeatureFile(QLatin1String("default_pre.prf"))) == ReturnError) goto failed; - if (!m_option->precmds.isEmpty()) { - evaluateCommand(m_option->precmds, fL1S("(command line)")); + if (!m_option->extra_cmds[QMakeEvalBefore].isEmpty()) { + evaluateCommand(m_option->extra_cmds[QMakeEvalBefore], fL1S("(command line)")); // Again, after user configs, to override them applyExtraConfigs(); @@ -1467,7 +1470,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( debugMsg(1, "done visiting file %s", qPrintable(pro->fileName())); if (flags & LoadPostFiles) { - evaluateCommand(m_option->postcmds, fL1S("(command line -after)")); + evaluateCommand(m_option->extra_cmds[QMakeEvalAfter], fL1S("(command line -after)")); // Again, to ensure the project does not mess with us. // Specifically, do not allow a project to override debug/release within a @@ -1477,6 +1480,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( if ((vr = evaluateFeatureFile(QLatin1String("default_post.prf"))) == ReturnError) goto failed; + if (!m_option->extra_cmds[QMakeEvalLate].isEmpty()) + evaluateCommand(m_option->extra_cmds[QMakeEvalLate], fL1S("(command line -late)")); + if ((vr = evaluateConfigFeatures()) == ReturnError) goto failed; } diff --git a/src/shared/proparser/qmakeglobals.cpp b/src/shared/proparser/qmakeglobals.cpp index 04ff561e9d..9d6f628b24 100644 --- a/src/shared/proparser/qmakeglobals.cpp +++ b/src/shared/proparser/qmakeglobals.cpp @@ -108,10 +108,7 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( QString arg = args.at(*pos); switch (argState) { case ArgConfig: - if (state.after) - state.postconfigs << arg; - else - state.preconfigs << arg; + state.configs[state.phase] << arg; break; case ArgSpec: qmakespec = args[*pos] = cleanSpec(state, arg); @@ -138,8 +135,14 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( args.erase(args.begin() + *pos, args.end()); return ArgumentsOk; } - if (arg == QLatin1String("-after")) - state.after = true; + if (arg == QLatin1String("-early")) + state.phase = QMakeEvalEarly; + else if (arg == QLatin1String("-before")) + state.phase = QMakeEvalBefore; + else if (arg == QLatin1String("-after")) + state.phase = QMakeEvalAfter; + else if (arg == QLatin1String("-late")) + state.phase = QMakeEvalLate; else if (arg == QLatin1String("-config")) argState = ArgConfig; else if (arg == QLatin1String("-nocache")) @@ -163,10 +166,7 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( else return ArgumentUnknown; } else if (arg.contains(QLatin1Char('='))) { - if (state.after) - state.postcmds << arg; - else - state.precmds << arg; + state.cmds[state.phase] << arg; } else { return ArgumentUnknown; } @@ -181,18 +181,17 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( void QMakeGlobals::commitCommandLineArguments(QMakeCmdLineParserState &state) { - if (!state.preconfigs.isEmpty()) - state.precmds << (fL1S("CONFIG += ") + state.preconfigs.join(QLatin1Char(' '))); if (!state.extraargs.isEmpty()) { QString extra = fL1S("QMAKE_EXTRA_ARGS ="); foreach (const QString &ea, state.extraargs) extra += QLatin1Char(' ') + QMakeEvaluator::quoteValue(ProString(ea)); - state.precmds << extra; + state.cmds[QMakeEvalBefore] << extra; + } + for (int p = 0; p < 4; p++) { + if (!state.configs[p].isEmpty()) + state.cmds[p] << (fL1S("CONFIG += ") + state.configs[p].join(QLatin1Char(' '))); + extra_cmds[p] = state.cmds[p].join(QLatin1Char('\n')); } - precmds = state.precmds.join(QLatin1Char('\n')); - if (!state.postconfigs.isEmpty()) - state.postcmds << (fL1S("CONFIG += ") + state.postconfigs.join(QLatin1Char(' '))); - postcmds = state.postcmds.join(QLatin1Char('\n')); if (xqmakespec.isEmpty()) xqmakespec = qmakespec; diff --git a/src/shared/proparser/qmakeglobals.h b/src/shared/proparser/qmakeglobals.h index 7e9cf09281..96e2299214 100644 --- a/src/shared/proparser/qmakeglobals.h +++ b/src/shared/proparser/qmakeglobals.h @@ -46,6 +46,8 @@ QT_BEGIN_NAMESPACE class QMakeEvaluator; +enum QMakeEvalPhase { QMakeEvalEarly, QMakeEvalBefore, QMakeEvalAfter, QMakeEvalLate }; + class QMakeBaseKey { public: @@ -79,12 +81,13 @@ public: class QMAKE_EXPORT QMakeCmdLineParserState { public: - QMakeCmdLineParserState(const QString &_pwd) : pwd(_pwd), after(false) {} + QMakeCmdLineParserState(const QString &_pwd) : pwd(_pwd), phase(QMakeEvalBefore) {} QString pwd; - QStringList precmds, preconfigs, postcmds, postconfigs, extraargs; - bool after; + QStringList cmds[4], configs[4]; + QStringList extraargs; + QMakeEvalPhase phase; - void flush() { after = false; } + void flush() { phase = QMakeEvalBefore; } }; class QMAKE_EXPORT QMakeGlobals @@ -106,7 +109,7 @@ public: QString qtconf; QString qmakespec, xqmakespec; QString user_template, user_template_prefix; - QString precmds, postcmds; + QString extra_cmds[4]; #ifdef PROEVALUATOR_DEBUG int debugLevel; |