diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-05-31 10:22:44 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-05-31 10:48:35 +0200 |
commit | 68866b1a7bcade79e425f609fc1680203b89112e (patch) | |
tree | fe852c0e477612cacb8b5e79550fd0ad69206180 /qmake | |
parent | 67c569add0a3db5f730d81b6bcb3fed22d3a4ce6 (diff) |
Fix QMAKE_EXTRA_COMPILER names in VS projects
Use the whole value of 'name', not just the first element, and also
replace variables like ${QMAKE_FILE_IN}.
This fixes the file_copies feature (COPIES) for Visual Studio
projects, because for every entry in COPIES an extra compiler is
created with a name 'COPY ${QMAKE_FILE_IN}'. Before this patch the
name and the generated file filter would be just 'COPY'. However,
duplicate filters are being skipped by the VS project generator. All
but the first COPIES entry was ignored.
Fixes: QTBUG-76010
Change-Id: Icaa5d2cb8d88ae3ef8ce86220198bca1b9e673f5
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/generators/win32/msvc_vcproj.cpp | 28 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_vcproj.h | 2 |
2 files changed, 23 insertions, 7 deletions
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index be0b67a9e6..0115dc1313 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1524,6 +1524,18 @@ void VcprojGenerator::initDistributionFiles() vcProject.DistributionFiles.Config = &(vcProject.Configuration); } +QString VcprojGenerator::extraCompilerName(const ProString &extraCompiler, + const QStringList &inputs, + const QStringList &outputs) +{ + QString name = project->values(ProKey(extraCompiler + ".name")).join(' '); + if (name.isEmpty()) + name = extraCompiler.toQString(); + else + name = replaceExtraCompilerVariables(name, inputs, outputs, NoShell); + return name; +} + void VcprojGenerator::initExtraCompilerOutputs() { ProStringList otherFilters; @@ -1541,13 +1553,16 @@ void VcprojGenerator::initExtraCompilerOutputs() << "YACCSOURCES"; const ProStringList &quc = project->values("QMAKE_EXTRA_COMPILERS"); for (ProStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) { - ProString extracompilerName = project->first(ProKey(*it + ".name")); - if (extracompilerName.isEmpty()) - extracompilerName = (*it); + const ProStringList &inputVars = project->values(ProKey(*it + ".input")); + ProStringList inputFiles; + for (auto var : inputVars) + inputFiles.append(project->values(var.toKey())); + const ProStringList &outputs = project->values(ProKey(*it + ".output")); // Create an extra compiler filter and add the files VCFilter extraCompile; - extraCompile.Name = extracompilerName.toQString(); + extraCompile.Name = extraCompilerName(it->toQString(), inputFiles.toQStringList(), + outputs.toQStringList()); extraCompile.ParseFiles = _False; extraCompile.Filter = ""; extraCompile.Guid = QString(_GUIDExtraCompilerFiles) + "-" + (*it); @@ -1560,14 +1575,14 @@ void VcprojGenerator::initExtraCompilerOutputs() if (!outputVar.isEmpty() && otherFilters.contains(outputVar)) continue; - QString tmp_out = project->first(ProKey(*it + ".output")).toQString(); + QString tmp_out = project->first(outputs.first().toKey()).toQString(); if (project->values(ProKey(*it + ".CONFIG")).indexOf("combine") != -1) { // Combined output, only one file result extraCompile.addFile(Option::fixPathToTargetOS( replaceExtraCompilerVariables(tmp_out, QString(), QString(), NoShell), false)); } else { // One output file per input - const ProStringList &tmp_in = project->values(project->first(ProKey(*it + ".input")).toKey()); + const ProStringList &tmp_in = project->values(inputVars.first().toKey()); for (int i = 0; i < tmp_in.count(); ++i) { const QString &filename = tmp_in.at(i).toQString(); if (extraCompilerSources.contains(filename) && !otherFiltersContain(filename)) @@ -1580,7 +1595,6 @@ void VcprojGenerator::initExtraCompilerOutputs() // build steps there. So, we turn it around and add it to the input files instead, // provided that the input file variable is not handled already (those in otherFilters // are handled, so we avoid them). - const ProStringList &inputVars = project->values(ProKey(*it + ".input")); for (const ProString &inputVar : inputVars) { if (!otherFilters.contains(inputVar)) { const ProStringList &tmp_in = project->values(inputVar.toKey()); diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h index 0b9770e962..e87eb733fc 100644 --- a/qmake/generators/win32/msvc_vcproj.h +++ b/qmake/generators/win32/msvc_vcproj.h @@ -73,6 +73,8 @@ protected: bool doDepends() const override { return false; } // Never necessary using Win32MakefileGenerator::replaceExtraCompilerVariables; QString replaceExtraCompilerVariables(const QString &, const QStringList &, const QStringList &, ReplaceFor) override; + QString extraCompilerName(const ProString &extraCompiler, const QStringList &inputs, + const QStringList &outputs); bool supportsMetaBuild() override { return true; } bool supportsMergedBuilds() override { return true; } bool mergeBuildProject(MakefileGenerator *other) override; |