From ddd749b130f44ba48a76a984a602f0e1cea60532 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 12 May 2016 17:50:17 +0200 Subject: [PATCH] introduce a new way to pass arbitrary arguments to the project file this is done by recognizing the -- option and putting everything that follows it into the QMAKE_EXTRA_ARGS variable. the purpose of this is being able to pass "alien" arguments (for example configure options) without having to marshal them into a qmake variable assignment manually. this is expected to greatly enhance the convenience when no wrapper script (i.e., configure itself) is used (which will be the case outside qtbase). Change-Id: I47735bdab2811d17d7d394fbf638ebd14332ea73 Reviewed-by: Lars Knoll (cherry picked from qtbase/26d44fce3dfb9dbd3b5be2a031fff8c1bb903960) Reviewed-by: Jake Petroules --- src/shared/proparser/qmakeglobals.cpp | 11 +++++++++++ src/shared/proparser/qmakeglobals.h | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/shared/proparser/qmakeglobals.cpp b/src/shared/proparser/qmakeglobals.cpp index c7bbe9c1d42..f3600b33e0e 100644 --- a/src/shared/proparser/qmakeglobals.cpp +++ b/src/shared/proparser/qmakeglobals.cpp @@ -133,6 +133,11 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( break; default: if (arg.startsWith(QLatin1Char('-'))) { + if (arg == QLatin1String("--")) { + state.extraargs = args.mid(*pos + 1); + *pos = args.size(); + return ArgumentsOk; + } if (arg == QLatin1String("-after")) state.after = true; else if (arg == QLatin1String("-config")) @@ -178,6 +183,12 @@ 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; + } precmds = state.precmds.join(QLatin1Char('\n')); if (!state.postconfigs.isEmpty()) state.postcmds << (fL1S("CONFIG += ") + state.postconfigs.join(QLatin1Char(' '))); diff --git a/src/shared/proparser/qmakeglobals.h b/src/shared/proparser/qmakeglobals.h index c931e8e9435..9942113681b 100644 --- a/src/shared/proparser/qmakeglobals.h +++ b/src/shared/proparser/qmakeglobals.h @@ -81,7 +81,7 @@ class QMAKE_EXPORT QMakeCmdLineParserState public: QMakeCmdLineParserState(const QString &_pwd) : pwd(_pwd), after(false) {} QString pwd; - QStringList precmds, preconfigs, postcmds, postconfigs; + QStringList precmds, preconfigs, postcmds, postconfigs, extraargs; bool after; void flush() { after = false; }