mirror of
https://github.com/reactos/CMake.git
synced 2025-02-20 20:00:52 +00:00
Autogen: Only touch an unchanged moc_compilation.cpp
This commit is contained in:
parent
03df033bfa
commit
347572cf5e
@ -1070,6 +1070,9 @@ bool cmQtAutoGenerators::MocGenerateAll(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mocCompFileGenerated = false;
|
||||||
|
bool mocCompChanged = false;
|
||||||
|
|
||||||
// look for name collisions
|
// look for name collisions
|
||||||
{
|
{
|
||||||
std::multimap<std::string, std::string> collisions;
|
std::multimap<std::string, std::string> collisions;
|
||||||
@ -1089,8 +1092,7 @@ bool cmQtAutoGenerators::MocGenerateAll(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Generate moc files that are included by source files.
|
||||||
// generate moc files that are included by source files.
|
|
||||||
{
|
{
|
||||||
const std::string subDir = "include/";
|
const std::string subDir = "include/";
|
||||||
for (std::map<std::string, std::string>::const_iterator it =
|
for (std::map<std::string, std::string>::const_iterator it =
|
||||||
@ -1103,16 +1105,14 @@ bool cmQtAutoGenerators::MocGenerateAll(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Generate moc files that are _not_ included by source files.
|
||||||
// generate moc files that are _not_ included by source files.
|
|
||||||
bool automocCppChanged = false;
|
|
||||||
{
|
{
|
||||||
const std::string subDir;
|
const std::string subDir;
|
||||||
for (std::map<std::string, std::string>::const_iterator it =
|
for (std::map<std::string, std::string>::const_iterator it =
|
||||||
mocsNotIncluded.begin();
|
mocsNotIncluded.begin();
|
||||||
it != mocsNotIncluded.end(); ++it) {
|
it != mocsNotIncluded.end(); ++it) {
|
||||||
if (this->MocGenerateFile(it->first, it->second, subDir, mocDepends)) {
|
if (this->MocGenerateFile(it->first, it->second, subDir, mocDepends)) {
|
||||||
automocCppChanged = true;
|
mocCompFileGenerated = true;
|
||||||
} else {
|
} else {
|
||||||
if (this->RunMocFailed) {
|
if (this->RunMocFailed) {
|
||||||
return false;
|
return false;
|
||||||
@ -1141,46 +1141,47 @@ bool cmQtAutoGenerators::MocGenerateAll(
|
|||||||
automocSource = outStream.str();
|
automocSource = outStream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we even need to update moc_compilation.cpp
|
// Check if the content of moc_compilation.cpp changed
|
||||||
if (!automocCppChanged) {
|
{
|
||||||
// compare contents of the moc_compilation.cpp file
|
|
||||||
const std::string oldContents = ReadAll(this->MocCppFilenameAbs);
|
const std::string oldContents = ReadAll(this->MocCppFilenameAbs);
|
||||||
if (oldContents == automocSource) {
|
mocCompChanged = (oldContents != automocSource);
|
||||||
// nothing changed: don't touch the moc_compilation.cpp file
|
|
||||||
if (this->Verbose) {
|
|
||||||
std::ostringstream err;
|
|
||||||
err << "AutoMoc: " << this->MocCppFilenameRel << " still up to date"
|
|
||||||
<< std::endl;
|
|
||||||
this->LogInfo(err.str());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually write moc_compilation.cpp
|
bool success = true;
|
||||||
this->LogBold("Generating MOC compilation " + this->MocCppFilenameRel);
|
if (mocCompChanged) {
|
||||||
|
// Actually write moc_compilation.cpp
|
||||||
|
this->LogBold("Generating MOC compilation " + this->MocCppFilenameRel);
|
||||||
|
|
||||||
// Make sure the parent directory exists
|
// Make sure the parent directory exists
|
||||||
bool success = this->MakeParentDirectory(this->MocCppFilenameAbs);
|
success = this->MakeParentDirectory(this->MocCppFilenameAbs);
|
||||||
if (success) {
|
if (success) {
|
||||||
cmsys::ofstream outfile;
|
cmsys::ofstream outfile;
|
||||||
outfile.open(this->MocCppFilenameAbs.c_str(), std::ios::trunc);
|
outfile.open(this->MocCppFilenameAbs.c_str(), std::ios::trunc);
|
||||||
if (!outfile) {
|
if (!outfile) {
|
||||||
success = false;
|
|
||||||
std::ostringstream err;
|
|
||||||
err << "AutoMoc: error opening " << this->MocCppFilenameAbs << "\n";
|
|
||||||
this->LogError(err.str());
|
|
||||||
} else {
|
|
||||||
outfile << automocSource;
|
|
||||||
// Check for write errors
|
|
||||||
if (!outfile.good()) {
|
|
||||||
success = false;
|
success = false;
|
||||||
std::ostringstream err;
|
std::ostringstream err;
|
||||||
err << "AutoMoc: error writing " << this->MocCppFilenameAbs << "\n";
|
err << "AutoMoc: error opening " << this->MocCppFilenameAbs << "\n";
|
||||||
this->LogError(err.str());
|
this->LogError(err.str());
|
||||||
|
} else {
|
||||||
|
outfile << automocSource;
|
||||||
|
// Check for write errors
|
||||||
|
if (!outfile.good()) {
|
||||||
|
success = false;
|
||||||
|
std::ostringstream err;
|
||||||
|
err << "AutoMoc: error writing " << this->MocCppFilenameAbs << "\n";
|
||||||
|
this->LogError(err.str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (mocCompFileGenerated) {
|
||||||
|
// Only touch moc_compilation.cpp
|
||||||
|
if (this->Verbose) {
|
||||||
|
this->LogInfo("Touching MOC compilation " + this->MocCppFilenameRel +
|
||||||
|
"\n");
|
||||||
|
}
|
||||||
|
cmSystemTools::Touch(this->MocCppFilenameAbs, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user