Purge the dep_cd_cmd parameter from callExtraCompilerDependCommand

We always pass the same value. The builtins are also using exactly this
"cd command" unconditionally.

This deduplicates the code at the call sites of
callExtraCompilerDependCommand a bit.

Change-Id: I5c412c815d50afdac55e1b45021f37f2545ce8f0
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Joerg Bornemann 2020-01-02 14:28:39 +01:00
parent 16885a6033
commit 41b919919e
4 changed files with 8 additions and 19 deletions

View File

@ -1851,7 +1851,6 @@ QString MakefileGenerator::resolveDependency(const QDir &outDir, const QString &
}
void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCompiler,
const QString &dep_cd_cmd,
const QString &tmp_dep_cmd,
const QString &inpf,
const QString &tmp_out,
@ -1864,7 +1863,10 @@ void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCom
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell);
if (checkCommandAvailability && !canExecute(dep_cmd))
return;
dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd);
dep_cmd = QLatin1String("cd ")
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
+ QLatin1String(" && ")
+ fixEnvVariables(dep_cmd);
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
QByteArray depData;
while (int read_in = feof(proc) ? 0 : (int)fread(buff, 1, 255, proc))
@ -1916,12 +1918,6 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
FileFixifyFromOutdir);
const QString tmp_cmd = project->values(ProKey(*it + ".commands")).join(' ');
const QString tmp_dep_cmd = project->values(ProKey(*it + ".depend_command")).join(' ');
QString dep_cd_cmd;
if (!tmp_dep_cmd.isEmpty()) {
dep_cd_cmd = QLatin1String("cd ")
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
+ QLatin1String(" && ");
}
const bool dep_lines = (config.indexOf("dep_lines") != -1);
const ProStringList &vars = project->values(ProKey(*it + ".variables"));
if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
@ -2035,7 +2031,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
deps += findDependencies(inpf);
inputs += Option::fixPathToTargetOS(inpf, false);
if(!tmp_dep_cmd.isEmpty() && doDepends()) {
callExtraCompilerDependCommand(*it, dep_cd_cmd, tmp_dep_cmd, inpf,
callExtraCompilerDependCommand(*it, tmp_dep_cmd, inpf,
tmp_out, dep_lines, &deps, existingDepsOnly);
}
}
@ -2084,7 +2080,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
for (ProStringList::ConstIterator it3 = vars.constBegin(); it3 != vars.constEnd(); ++it3)
cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
if(!tmp_dep_cmd.isEmpty() && doDepends()) {
callExtraCompilerDependCommand(*it, dep_cd_cmd, tmp_dep_cmd, inpf,
callExtraCompilerDependCommand(*it, tmp_dep_cmd, inpf,
tmp_out, dep_lines, &deps, existingDepsOnly);
//use the depend system to find includes of these included files
QStringList inc_deps;

View File

@ -84,7 +84,7 @@ protected:
void writeExtraVariables(QTextStream &t);
void writeExtraTargets(QTextStream &t);
QString resolveDependency(const QDir &outDir, const QString &file);
void callExtraCompilerDependCommand(const ProString &extraCompiler, const QString &dep_cd_cmd,
void callExtraCompilerDependCommand(const ProString &extraCompiler,
const QString &tmp_dep_cmd, const QString &inpf,
const QString &tmp_out, bool dep_lines, QStringList *deps,
bool existingDepsOnly,

View File

@ -2351,10 +2351,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
if (!tmp_dep.isEmpty())
deps = tmp_dep;
if (!tmp_dep_cmd.isEmpty()) {
const QString dep_cd_cmd = QLatin1String("cd ")
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
+ QLatin1String(" && ");
Project->callExtraCompilerDependCommand(extraCompilerName, dep_cd_cmd, tmp_dep_cmd,
Project->callExtraCompilerDependCommand(extraCompilerName, tmp_dep_cmd,
inFile, out,
true, // dep_lines
&deps,

View File

@ -1483,12 +1483,8 @@ void VcprojGenerator::initResourceFiles()
if(!rcc_dep_cmd.isEmpty()) {
const QStringList qrc_files = project->values("RESOURCES").toQStringList();
QStringList deps;
const QString rcc_dep_cd_cmd = QLatin1String("cd ")
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
+ QLatin1String(" && ");
for (const QString &qrc_file : qrc_files) {
callExtraCompilerDependCommand("rcc",
rcc_dep_cd_cmd,
rcc_dep_cmd,
qrc_file,
QString(),