summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2016-12-19 18:56:43 +0100
committerJani Heikkinen <jani.heikkinen@qt.io>2017-01-13 10:40:58 +0000
commitbe00e37bb35eadcb990b1b9a71b668c83cb89eaf (patch)
tree51a2ecd86b974aed23edc52228dc69654ba1aa33 /qmake
parent4a738424aaef7958917b92bd64a08eb6208d9c06 (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> (cherry picked from commit 5fc2337d740963d019a1e31960a4d12dfec36ea9) Reviewed-by: Maurice Kalinowski <maurice.kalinowski@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 21bdad1bbf..9d04a66ff4 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -760,6 +760,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");
@@ -887,12 +902,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;
};