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 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
ad51c8aa0a
commit
4adc1012e1
@ -326,8 +326,8 @@ ProjectGenerator::writeMakefile(QTextStream &t)
|
|||||||
t << "######################################################################" << endl;
|
t << "######################################################################" << endl;
|
||||||
t << "# Automatically generated by qmake (" QMAKE_VERSION_STR ") " << QDateTime::currentDateTime().toString() << endl;
|
t << "# Automatically generated by qmake (" QMAKE_VERSION_STR ") " << QDateTime::currentDateTime().toString() << endl;
|
||||||
t << "######################################################################" << endl << endl;
|
t << "######################################################################" << endl << endl;
|
||||||
if (!Option::globals->precmds.isEmpty())
|
if (!Option::globals->extra_cmds[QMakeEvalBefore].isEmpty())
|
||||||
t << Option::globals->precmds << endl;
|
t << Option::globals->extra_cmds[QMakeEvalBefore] << endl;
|
||||||
t << getWritableVar("TEMPLATE_ASSIGN", false);
|
t << getWritableVar("TEMPLATE_ASSIGN", false);
|
||||||
if(project->first("TEMPLATE_ASSIGN") == "subdirs") {
|
if(project->first("TEMPLATE_ASSIGN") == "subdirs") {
|
||||||
t << endl << "# Directories" << "\n"
|
t << endl << "# Directories" << "\n"
|
||||||
@ -353,8 +353,8 @@ ProjectGenerator::writeMakefile(QTextStream &t)
|
|||||||
<< getWritableVar("RESOURCES")
|
<< getWritableVar("RESOURCES")
|
||||||
<< getWritableVar("TRANSLATIONS");
|
<< getWritableVar("TRANSLATIONS");
|
||||||
}
|
}
|
||||||
if (!Option::globals->postcmds.isEmpty())
|
if (!Option::globals->extra_cmds[QMakeEvalAfter].isEmpty())
|
||||||
t << Option::globals->postcmds << endl;
|
t << Option::globals->extra_cmds[QMakeEvalAfter] << endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,8 +664,8 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
|
|||||||
// Make sure that all temp projects are configured
|
// Make sure that all temp projects are configured
|
||||||
// for release so that the depends are created
|
// for release so that the depends are created
|
||||||
// without the debug <lib>dxxx.lib name mangling
|
// without the debug <lib>dxxx.lib name mangling
|
||||||
QString old_after_vars = Option::globals->postcmds;
|
QString old_after_vars = Option::globals->extra_cmds[QMakeEvalAfter];
|
||||||
Option::globals->postcmds.append("\nCONFIG+=release");
|
Option::globals->extra_cmds[QMakeEvalAfter].append("\nCONFIG+=release");
|
||||||
|
|
||||||
QHash<QString, QString> profileLookup;
|
QHash<QString, QString> profileLookup;
|
||||||
QHash<QString, QString> projGuids;
|
QHash<QString, QString> projGuids;
|
||||||
@ -719,7 +719,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
|
|||||||
t << slnConf;
|
t << slnConf;
|
||||||
|
|
||||||
// Restore previous after_user_var options
|
// Restore previous after_user_var options
|
||||||
Option::globals->postcmds = old_after_vars;
|
Option::globals->extra_cmds[QMakeEvalAfter] = old_after_vars;
|
||||||
|
|
||||||
t << _slnProjConfBeg;
|
t << _slnProjConfBeg;
|
||||||
for(QList<VcsolutionDepend*>::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) {
|
for(QList<VcsolutionDepend*>::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) {
|
||||||
|
@ -1443,6 +1443,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile(
|
|||||||
if (flags & LoadPreFiles) {
|
if (flags & LoadPreFiles) {
|
||||||
setupProject();
|
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();
|
for (ProValueMap::ConstIterator it = m_extraVars.constBegin();
|
||||||
it != m_extraVars.constEnd(); ++it)
|
it != m_extraVars.constEnd(); ++it)
|
||||||
m_valuemapStack.first().insert(it.key(), it.value());
|
m_valuemapStack.first().insert(it.key(), it.value());
|
||||||
@ -1454,8 +1457,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile(
|
|||||||
if ((vr = evaluateFeatureFile(QLatin1String("default_pre.prf"))) == ReturnError)
|
if ((vr = evaluateFeatureFile(QLatin1String("default_pre.prf"))) == ReturnError)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
if (!m_option->precmds.isEmpty()) {
|
if (!m_option->extra_cmds[QMakeEvalBefore].isEmpty()) {
|
||||||
evaluateCommand(m_option->precmds, fL1S("(command line)"));
|
evaluateCommand(m_option->extra_cmds[QMakeEvalBefore], fL1S("(command line)"));
|
||||||
|
|
||||||
// Again, after user configs, to override them
|
// Again, after user configs, to override them
|
||||||
applyExtraConfigs();
|
applyExtraConfigs();
|
||||||
@ -1468,7 +1471,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile(
|
|||||||
debugMsg(1, "done visiting file %s", qPrintable(pro->fileName()));
|
debugMsg(1, "done visiting file %s", qPrintable(pro->fileName()));
|
||||||
|
|
||||||
if (flags & LoadPostFiles) {
|
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.
|
// Again, to ensure the project does not mess with us.
|
||||||
// Specifically, do not allow a project to override debug/release within a
|
// Specifically, do not allow a project to override debug/release within a
|
||||||
@ -1478,6 +1481,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile(
|
|||||||
if ((vr = evaluateFeatureFile(QLatin1String("default_post.prf"))) == ReturnError)
|
if ((vr = evaluateFeatureFile(QLatin1String("default_post.prf"))) == ReturnError)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
|
if (!m_option->extra_cmds[QMakeEvalLate].isEmpty())
|
||||||
|
evaluateCommand(m_option->extra_cmds[QMakeEvalLate], fL1S("(command line -late)"));
|
||||||
|
|
||||||
if ((vr = evaluateConfigFeatures()) == ReturnError)
|
if ((vr = evaluateConfigFeatures()) == ReturnError)
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -111,10 +111,7 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments(
|
|||||||
QString arg = args.at(*pos);
|
QString arg = args.at(*pos);
|
||||||
switch (argState) {
|
switch (argState) {
|
||||||
case ArgConfig:
|
case ArgConfig:
|
||||||
if (state.after)
|
state.configs[state.phase] << arg;
|
||||||
state.postconfigs << arg;
|
|
||||||
else
|
|
||||||
state.preconfigs << arg;
|
|
||||||
break;
|
break;
|
||||||
case ArgSpec:
|
case ArgSpec:
|
||||||
qmakespec = args[*pos] = cleanSpec(state, arg);
|
qmakespec = args[*pos] = cleanSpec(state, arg);
|
||||||
@ -141,8 +138,14 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments(
|
|||||||
args.erase(args.begin() + *pos, args.end());
|
args.erase(args.begin() + *pos, args.end());
|
||||||
return ArgumentsOk;
|
return ArgumentsOk;
|
||||||
}
|
}
|
||||||
if (arg == QLatin1String("-after"))
|
if (arg == QLatin1String("-early"))
|
||||||
state.after = true;
|
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"))
|
else if (arg == QLatin1String("-config"))
|
||||||
argState = ArgConfig;
|
argState = ArgConfig;
|
||||||
else if (arg == QLatin1String("-nocache"))
|
else if (arg == QLatin1String("-nocache"))
|
||||||
@ -166,10 +169,7 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments(
|
|||||||
else
|
else
|
||||||
return ArgumentUnknown;
|
return ArgumentUnknown;
|
||||||
} else if (arg.contains(QLatin1Char('='))) {
|
} else if (arg.contains(QLatin1Char('='))) {
|
||||||
if (state.after)
|
state.cmds[state.phase] << arg;
|
||||||
state.postcmds << arg;
|
|
||||||
else
|
|
||||||
state.precmds << arg;
|
|
||||||
} else {
|
} else {
|
||||||
return ArgumentUnknown;
|
return ArgumentUnknown;
|
||||||
}
|
}
|
||||||
@ -184,18 +184,17 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments(
|
|||||||
|
|
||||||
void QMakeGlobals::commitCommandLineArguments(QMakeCmdLineParserState &state)
|
void QMakeGlobals::commitCommandLineArguments(QMakeCmdLineParserState &state)
|
||||||
{
|
{
|
||||||
if (!state.preconfigs.isEmpty())
|
|
||||||
state.precmds << (fL1S("CONFIG += ") + state.preconfigs.join(QLatin1Char(' ')));
|
|
||||||
if (!state.extraargs.isEmpty()) {
|
if (!state.extraargs.isEmpty()) {
|
||||||
QString extra = fL1S("QMAKE_EXTRA_ARGS =");
|
QString extra = fL1S("QMAKE_EXTRA_ARGS =");
|
||||||
for (const QString &ea : qAsConst(state.extraargs))
|
for (const QString &ea : qAsConst(state.extraargs))
|
||||||
extra += QLatin1Char(' ') + QMakeEvaluator::quoteValue(ProString(ea));
|
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())
|
if (xqmakespec.isEmpty())
|
||||||
xqmakespec = qmakespec;
|
xqmakespec = qmakespec;
|
||||||
|
@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
class QMakeEvaluator;
|
class QMakeEvaluator;
|
||||||
|
|
||||||
|
enum QMakeEvalPhase { QMakeEvalEarly, QMakeEvalBefore, QMakeEvalAfter, QMakeEvalLate };
|
||||||
|
|
||||||
class QMakeBaseKey
|
class QMakeBaseKey
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -83,12 +85,13 @@ public:
|
|||||||
class QMAKE_EXPORT QMakeCmdLineParserState
|
class QMAKE_EXPORT QMakeCmdLineParserState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QMakeCmdLineParserState(const QString &_pwd) : pwd(_pwd), after(false) {}
|
QMakeCmdLineParserState(const QString &_pwd) : pwd(_pwd), phase(QMakeEvalBefore) {}
|
||||||
QString pwd;
|
QString pwd;
|
||||||
QStringList precmds, preconfigs, postcmds, postconfigs, extraargs;
|
QStringList cmds[4], configs[4];
|
||||||
bool after;
|
QStringList extraargs;
|
||||||
|
QMakeEvalPhase phase;
|
||||||
|
|
||||||
void flush() { after = false; }
|
void flush() { phase = QMakeEvalBefore; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class QMAKE_EXPORT QMakeGlobals
|
class QMAKE_EXPORT QMakeGlobals
|
||||||
@ -110,7 +113,7 @@ public:
|
|||||||
QString qtconf;
|
QString qtconf;
|
||||||
QString qmakespec, xqmakespec;
|
QString qmakespec, xqmakespec;
|
||||||
QString user_template, user_template_prefix;
|
QString user_template, user_template_prefix;
|
||||||
QString precmds, postcmds;
|
QString extra_cmds[4];
|
||||||
|
|
||||||
#ifdef PROEVALUATOR_DEBUG
|
#ifdef PROEVALUATOR_DEBUG
|
||||||
int debugLevel;
|
int debugLevel;
|
||||||
|
@ -151,17 +151,23 @@ bool usage(const char *a0)
|
|||||||
" -Wdeprecated Turn on deprecation warnings (on by default)\n"
|
" -Wdeprecated Turn on deprecation warnings (on by default)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" * You can place any variable assignment in options and it will be *\n"
|
" * You can place any variable assignment in options and it will be *\n"
|
||||||
" * processed as if it was in [files]. These assignments will be parsed *\n"
|
" * processed as if it was in [files]. These assignments will be *\n"
|
||||||
" * before [files]. *\n"
|
" * processed before [files] by default. *\n"
|
||||||
" -o file Write output to file\n"
|
" -o file Write output to file\n"
|
||||||
" -d Increase debug level\n"
|
" -d Increase debug level\n"
|
||||||
" -t templ Overrides TEMPLATE as templ\n"
|
" -t templ Overrides TEMPLATE as templ\n"
|
||||||
" -tp prefix Overrides TEMPLATE so that prefix is prefixed into the value\n"
|
" -tp prefix Overrides TEMPLATE so that prefix is prefixed into the value\n"
|
||||||
" -help This help\n"
|
" -help This help\n"
|
||||||
" -v Version information\n"
|
" -v Version information\n"
|
||||||
" -after All variable assignments after this will be\n"
|
" -early All subsequent variable assignments will be\n"
|
||||||
|
" parsed right before default_pre.prf\n"
|
||||||
|
" -before All subsequent variable assignments will be\n"
|
||||||
|
" parsed right before [files] (the default)\n"
|
||||||
|
" -after All subsequent variable assignments will be\n"
|
||||||
" parsed after [files]\n"
|
" parsed after [files]\n"
|
||||||
|
" -late All subsequent variable assignments will be\n"
|
||||||
|
" parsed right after default_post.prf\n"
|
||||||
" -norecursive Don't do a recursive search\n"
|
" -norecursive Don't do a recursive search\n"
|
||||||
" -recursive Do a recursive search\n"
|
" -recursive Do a recursive search\n"
|
||||||
" -set <prop> <value> Set persistent property\n"
|
" -set <prop> <value> Set persistent property\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user