summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2016-12-19 18:56:43 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2016-12-21 16:35:22 +0000
commit5fc2337d740963d019a1e31960a4d12dfec36ea9 (patch)
tree2726cde1657fff5c3f047388592b334c116cdc75 /qmake
parent31f0728ac9cc4d49b93742fbe8e948c45c992b75 (diff)
Fix unnecessary regeneration of mocables in VS projects
Change dcd2f829 introduced fake files with the extension .cbt for custom build tools that generate code from C++ source inputs. The moc_predefs.h header file falls into this category, because it is generated from dummy.cpp. It turns out that these fake files have to exist. Otherwise the custom build step is executed on every build. That means re-moccing all mocables on every build. Fix this by actually creating the fake .cbt files with some explanatory comment in them. Task-number: QTBUG-57695 Change-Id: I251294334425d9914677787d8ba6da1169b4cca5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'qmake')
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp25
-rw-r--r--qmake/generators/win32/msvc_vcproj.h1
2 files changed, 22 insertions, 4 deletions
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index 8a77bbe672..ae1d095629 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -766,6 +766,21 @@ bool VcprojGenerator::hasBuiltinCompiler(const QString &file)
return false;
}
+void VcprojGenerator::createCustomBuildToolFakeFile(const QString &cbtFilePath,
+ const QString &realOutFilePath)
+{
+ QFile file(fileFixify(cbtFilePath, FileFixifyFromOutdir | FileFixifyAbsolute));
+ if (file.exists())
+ return;
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ warn_msg(WarnLogic, "Cannot create '%s'.", qPrintable(file.fileName()));
+ return;
+ }
+ file.write("This is a dummy file needed to create ");
+ file.write(qPrintable(realOutFilePath));
+ file.write("\n");
+}
+
void VcprojGenerator::init()
{
is64Bit = (project->first("QMAKE_TARGET.arch") == "x86_64");
@@ -893,12 +908,14 @@ void VcprojGenerator::init()
if (!hasBuiltinCompiler(file)) {
extraCompilerSources[file] += quc.toQString();
} else {
- // Use a fake file name foo.moc.cbt for the project view.
+ // Create a fake file foo.moc.cbt for the project view.
// This prevents VS from complaining about a circular
// dependency from foo.moc -> foo.moc.
- QString out = Option::fixPathToTargetOS(replaceExtraCompilerVariables(
- compiler_out, file, QString(), NoShell), false);
- out += customBuildToolFilterFileSuffix;
+ QString realOut = replaceExtraCompilerVariables(
+ compiler_out, file, QString(), NoShell);
+ QString out = realOut + customBuildToolFilterFileSuffix;
+ createCustomBuildToolFakeFile(out, realOut);
+ out = Option::fixPathToTargetOS(out, false);
extraCompilerSources[out] += quc.toQString();
extraCompilerOutputs[out] = file;
}
diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h
index e3e67d64b9..4882296b46 100644
--- a/qmake/generators/win32/msvc_vcproj.h
+++ b/qmake/generators/win32/msvc_vcproj.h
@@ -130,6 +130,7 @@ private:
bool isStandardSuffix(const QString &suffix) const;
ProString firstInputFileName(const ProString &extraCompilerName) const;
QString firstExpandedOutputFileName(const ProString &extraCompilerName);
+ void createCustomBuildToolFakeFile(const QString &cbtFilePath, const QString &realOutFilePath);
friend class VCFilter;
};