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 5fc2337d74)
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
This commit is contained in:
Joerg Bornemann 2016-12-19 18:56:43 +01:00 committed by Jani Heikkinen
parent 4a738424aa
commit be00e37bb3
2 changed files with 22 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;
};