Fix dependency resolution for extra compilers in VS projects
De-duplicate the code that calls the extra compiler's depend_command by using the central function callExtraCompilerDependCommand. This one actually tries to resolve dependencies unlike the removed code that blindly resolved relative paths to the build directory. This fixes dependencies reported by uic which need to be resolved against what is in DEPENDPATH. Fixes: QTBUG-80579 Change-Id: If482e50ff3eff716fefffee82004acc076b3a547 Reviewed-by: Kai Koehne <kai.koehne@qt.io> (cherry picked from commit 9d7ed92f6e63cd2d1a1388874e54b37b5cfd01b7) Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
96df877ebc
commit
ed54545d0d
@ -1877,10 +1877,13 @@ void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCom
|
|||||||
const QString &tmp_out,
|
const QString &tmp_out,
|
||||||
bool dep_lines,
|
bool dep_lines,
|
||||||
QStringList *deps,
|
QStringList *deps,
|
||||||
bool existingDepsOnly)
|
bool existingDepsOnly,
|
||||||
|
bool checkCommandAvailability)
|
||||||
{
|
{
|
||||||
char buff[256];
|
char buff[256];
|
||||||
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell);
|
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 = dep_cd_cmd + fixEnvVariables(dep_cmd);
|
||||||
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
|
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
|
||||||
QByteArray depData;
|
QByteArray depData;
|
||||||
|
@ -87,7 +87,8 @@ protected:
|
|||||||
void callExtraCompilerDependCommand(const ProString &extraCompiler, const QString &dep_cd_cmd,
|
void callExtraCompilerDependCommand(const ProString &extraCompiler, const QString &dep_cd_cmd,
|
||||||
const QString &tmp_dep_cmd, const QString &inpf,
|
const QString &tmp_dep_cmd, const QString &inpf,
|
||||||
const QString &tmp_out, bool dep_lines, QStringList *deps,
|
const QString &tmp_out, bool dep_lines, QStringList *deps,
|
||||||
bool existingDepsOnly);
|
bool existingDepsOnly,
|
||||||
|
bool checkCommandAvailability = false);
|
||||||
void writeExtraCompilerTargets(QTextStream &t);
|
void writeExtraCompilerTargets(QTextStream &t);
|
||||||
void writeExtraCompilerVariables(QTextStream &t);
|
void writeExtraCompilerVariables(QTextStream &t);
|
||||||
bool writeDummyMakefile(QTextStream &t);
|
bool writeDummyMakefile(QTextStream &t);
|
||||||
|
@ -2350,33 +2350,15 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
|
|||||||
if (!tmp_dep.isEmpty())
|
if (!tmp_dep.isEmpty())
|
||||||
deps = tmp_dep;
|
deps = tmp_dep;
|
||||||
if (!tmp_dep_cmd.isEmpty()) {
|
if (!tmp_dep_cmd.isEmpty()) {
|
||||||
// Execute dependency command, and add every line as a dep
|
const QString dep_cd_cmd = QLatin1String("cd ")
|
||||||
char buff[256];
|
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
|
||||||
QString dep_cmd = Project->replaceExtraCompilerVariables(
|
+ QLatin1String(" && ");
|
||||||
tmp_dep_cmd, inFile, out, MakefileGenerator::LocalShell);
|
Project->callExtraCompilerDependCommand(extraCompilerName, dep_cd_cmd, tmp_dep_cmd,
|
||||||
if(Project->canExecute(dep_cmd)) {
|
inFile, out,
|
||||||
dep_cmd.prepend(QLatin1String("cd ")
|
true, // dep_lines
|
||||||
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
|
&deps,
|
||||||
+ QLatin1String(" && "));
|
configs.contains("dep_existing_only"),
|
||||||
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
|
true /* checkCommandAvailability */);
|
||||||
QString indeps;
|
|
||||||
while(!feof(proc)) {
|
|
||||||
int read_in = (int)fread(buff, 1, 255, proc);
|
|
||||||
if(!read_in)
|
|
||||||
break;
|
|
||||||
indeps += QByteArray(buff, read_in);
|
|
||||||
}
|
|
||||||
QT_PCLOSE(proc);
|
|
||||||
if(!indeps.isEmpty()) {
|
|
||||||
QStringList extradeps = indeps.split(QLatin1Char('\n'));
|
|
||||||
for (int i = 0; i < extradeps.count(); ++i) {
|
|
||||||
QString dd = extradeps.at(i).simplified();
|
|
||||||
if (!dd.isEmpty())
|
|
||||||
deps += Project->fileFixify(dd, MakefileGenerator::FileFixifyFromOutdir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < deps.count(); ++i)
|
for (int i = 0; i < deps.count(); ++i)
|
||||||
deps[i] = Option::fixPathToTargetOS(
|
deps[i] = Option::fixPathToTargetOS(
|
||||||
|
@ -68,6 +68,8 @@ public:
|
|||||||
bool usePCH;
|
bool usePCH;
|
||||||
VCProjectWriter *projectWriter;
|
VCProjectWriter *projectWriter;
|
||||||
|
|
||||||
|
using Win32MakefileGenerator::callExtraCompilerDependCommand;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual VCProjectWriter *createProjectWriter();
|
virtual VCProjectWriter *createProjectWriter();
|
||||||
bool doDepends() const override { return false; } // Never necessary
|
bool doDepends() const override { return false; } // Never necessary
|
||||||
|
Loading…
x
Reference in New Issue
Block a user