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 <joerg.bornemann@nokia.com>
This commit is contained in:
parent
1447b6c55b
commit
4350054ab8
@ -2147,50 +2147,12 @@ QString MakefileGenerator::fixifySpecdir(const QString &spec, const QString &out
|
|||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MakefileGenerator::buildArgs(const QString &outdir)
|
QString MakefileGenerator::buildArgs()
|
||||||
{
|
{
|
||||||
QString ret;
|
QString ret;
|
||||||
//special variables
|
|
||||||
if(!project->isEmpty("QMAKE_ABSOLUTE_SOURCE_PATH"))
|
|
||||||
ret += " QMAKE_ABSOLUTE_SOURCE_PATH=" + escapeFilePath(project->first("QMAKE_ABSOLUTE_SOURCE_PATH"));
|
|
||||||
|
|
||||||
//warnings
|
foreach (const QString &arg, Option::qmake_args)
|
||||||
else if(Option::warn_level == WarnNone)
|
ret += " " + escapeFilePath(arg);
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2201,7 +2163,7 @@ QString MakefileGenerator::build_args(const QString &outdir)
|
|||||||
QString ret = "$(QMAKE)";
|
QString ret = "$(QMAKE)";
|
||||||
|
|
||||||
// general options and arguments
|
// general options and arguments
|
||||||
ret += buildArgs(outdir);
|
ret += buildArgs();
|
||||||
|
|
||||||
//output
|
//output
|
||||||
QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.fileName()));
|
QString ofile = Option::fixPathToTargetOS(fileFixify(Option::output.fileName()));
|
||||||
@ -2358,7 +2320,7 @@ MakefileGenerator::writeSubTargetCall(QTextStream &t,
|
|||||||
if (!in_directory.isEmpty())
|
if (!in_directory.isEmpty())
|
||||||
t << "\n\t" << mkdir_p_asstring(out_directory);
|
t << "\n\t" << mkdir_p_asstring(out_directory);
|
||||||
pfx = "( " + chkfile + " " + out + " " + chkglue
|
pfx = "( " + chkfile + " " + out + " " + chkglue
|
||||||
+ "$(QMAKE) " + in + buildArgs(in_directory) + " -o " + out
|
+ "$(QMAKE) " + in + buildArgs() + " -o " + out
|
||||||
+ " ) && ";
|
+ " ) && ";
|
||||||
}
|
}
|
||||||
writeSubMakeCall(t, out_directory_cdin + pfx, makefilein);
|
writeSubMakeCall(t, out_directory_cdin + pfx, makefilein);
|
||||||
@ -2447,7 +2409,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT
|
|||||||
t << mkdir_p_asstring(out_directory)
|
t << mkdir_p_asstring(out_directory)
|
||||||
<< out_directory_cdin;
|
<< out_directory_cdin;
|
||||||
}
|
}
|
||||||
t << "$(QMAKE) " << in << buildArgs(in_directory) << " -o " << out;
|
t << "$(QMAKE) " << in << buildArgs() << " -o " << out;
|
||||||
if (!dont_recurse)
|
if (!dont_recurse)
|
||||||
writeSubMakeCall(t, out_directory_cdin, makefilein + " qmake_all");
|
writeSubMakeCall(t, out_directory_cdin, makefilein + " qmake_all");
|
||||||
else
|
else
|
||||||
|
@ -194,7 +194,7 @@ protected:
|
|||||||
QString specdir();
|
QString specdir();
|
||||||
|
|
||||||
//subclasses can use these to query information about how the generator was "run"
|
//subclasses can use these to query information about how the generator was "run"
|
||||||
QString buildArgs(const QString &outdir=QString());
|
QString buildArgs();
|
||||||
QString fixifySpecdir(const QString &spec, const QString &outdir);
|
QString fixifySpecdir(const QString &spec, const QString &outdir);
|
||||||
|
|
||||||
virtual QStringList &findDependencies(const QString &file);
|
virtual QStringList &findDependencies(const QString &file);
|
||||||
|
@ -79,6 +79,7 @@ Option::QMAKE_MODE Option::qmake_mode = Option::QMAKE_GENERATE_NOTHING;
|
|||||||
|
|
||||||
//all modes
|
//all modes
|
||||||
QString Option::qmake_abslocation;
|
QString Option::qmake_abslocation;
|
||||||
|
QStringList Option::qmake_args;
|
||||||
int Option::warn_level = WarnLogic | WarnDeprecated;
|
int Option::warn_level = WarnLogic | WarnDeprecated;
|
||||||
int Option::debug_level = 0;
|
int Option::debug_level = 0;
|
||||||
QFile Option::output;
|
QFile Option::output;
|
||||||
@ -110,8 +111,6 @@ QString Option::mkfile::source_root;
|
|||||||
QString Option::mkfile::build_root;
|
QString Option::mkfile::build_root;
|
||||||
QString Option::mkfile::cachefile;
|
QString Option::mkfile::cachefile;
|
||||||
QStringList Option::mkfile::project_files;
|
QStringList Option::mkfile::project_files;
|
||||||
QString Option::mkfile::qmakespec_commandline;
|
|
||||||
QString Option::mkfile::xqmakespec_commandline;
|
|
||||||
|
|
||||||
static Option::QMAKE_MODE default_mode(QString progname)
|
static Option::QMAKE_MODE default_mode(QString progname)
|
||||||
{
|
{
|
||||||
@ -223,7 +222,9 @@ Option::parseCommandLine(QStringList &args)
|
|||||||
if (arg.size() > 1 && arg.startsWith('-')) { /* options */
|
if (arg.size() > 1 && arg.startsWith('-')) { /* options */
|
||||||
QString opt = arg.mid(1);
|
QString opt = arg.mid(1);
|
||||||
if(opt == "o" || opt == "output") {
|
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") {
|
} else if(opt == "after") {
|
||||||
before = false;
|
before = false;
|
||||||
} else if(opt == "t" || opt == "template") {
|
} else if(opt == "t" || opt == "template") {
|
||||||
@ -260,8 +261,12 @@ Option::parseCommandLine(QStringList &args)
|
|||||||
Option::warn_level = WarnNone;
|
Option::warn_level = WarnNone;
|
||||||
} else if(opt == "r" || opt == "recursive") {
|
} else if(opt == "r" || opt == "recursive") {
|
||||||
Option::recursive = true;
|
Option::recursive = true;
|
||||||
|
args.removeAt(x);
|
||||||
|
continue;
|
||||||
} else if(opt == "nr" || opt == "norecursive") {
|
} else if(opt == "nr" || opt == "norecursive") {
|
||||||
Option::recursive = false;
|
Option::recursive = false;
|
||||||
|
args.removeAt(x);
|
||||||
|
continue;
|
||||||
} else if(opt == "config") {
|
} else if(opt == "config") {
|
||||||
user_configs += args.at(++x);
|
user_configs += args.at(++x);
|
||||||
} else {
|
} else {
|
||||||
@ -282,11 +287,9 @@ Option::parseCommandLine(QStringList &args)
|
|||||||
} else if(opt == "cache") {
|
} else if(opt == "cache") {
|
||||||
Option::mkfile::cachefile = args.at(++x);
|
Option::mkfile::cachefile = args.at(++x);
|
||||||
} else if(opt == "platform" || opt == "spec") {
|
} else if(opt == "platform" || opt == "spec") {
|
||||||
Option::mkfile::qmakespec = cleanSpec(args.at(++x));
|
Option::mkfile::qmakespec = args[x] = cleanSpec(args.at(++x));
|
||||||
Option::mkfile::qmakespec_commandline = args.at(x);
|
|
||||||
} else if (opt == "xplatform" || opt == "xspec") {
|
} else if (opt == "xplatform" || opt == "xspec") {
|
||||||
Option::mkfile::xqmakespec = cleanSpec(args.at(++x));
|
Option::mkfile::xqmakespec = args[x] = cleanSpec(args.at(x));
|
||||||
Option::mkfile::xqmakespec_commandline = args.at(x);
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "***Unknown option -%s\n", opt.toLatin1().constData());
|
fprintf(stderr, "***Unknown option -%s\n", opt.toLatin1().constData());
|
||||||
return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR;
|
return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR;
|
||||||
@ -333,6 +336,8 @@ Option::parseCommandLine(QStringList &args)
|
|||||||
if(!handled) {
|
if(!handled) {
|
||||||
return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR;
|
return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR;
|
||||||
}
|
}
|
||||||
|
args.removeAt(x);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x++;
|
x++;
|
||||||
@ -474,6 +479,7 @@ Option::init(int argc, char **argv)
|
|||||||
return ret;
|
return ret;
|
||||||
//return ret == QMAKE_CMDLINE_SHOW_USAGE ? usage(argv[0]) : false;
|
//return ret == QMAKE_CMDLINE_SHOW_USAGE ? usage(argv[0]) : false;
|
||||||
}
|
}
|
||||||
|
Option::qmake_args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
//last chance for defaults
|
//last chance for defaults
|
||||||
|
@ -161,6 +161,7 @@ struct Option
|
|||||||
|
|
||||||
//all modes
|
//all modes
|
||||||
static QString qmake_abslocation;
|
static QString qmake_abslocation;
|
||||||
|
static QStringList qmake_args;
|
||||||
static QFile output;
|
static QFile output;
|
||||||
static QString output_dir;
|
static QString output_dir;
|
||||||
static int debug_level;
|
static int debug_level;
|
||||||
@ -195,8 +196,6 @@ struct Option
|
|||||||
static QString cachefile;
|
static QString cachefile;
|
||||||
static int cachefile_depth;
|
static int cachefile_depth;
|
||||||
static QStringList project_files;
|
static QStringList project_files;
|
||||||
static QString qmakespec_commandline;
|
|
||||||
static QString xqmakespec_commandline;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user