diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2017-04-22 11:12:58 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2017-04-22 11:21:18 (GMT) |
commit | 5965a589154e64ba3997c28a718652f54a84c631 (patch) | |
tree | e6150ef554f2e651f6b2d64b7b3ca4b7de7552e8 /Source | |
parent | 46ba6abe498f1fd6cd286213ab7a4a9dfa6f15fb (diff) | |
download | CMake-5965a589154e64ba3997c28a718652f54a84c631.zip CMake-5965a589154e64ba3997c28a718652f54a84c631.tar.gz CMake-5965a589154e64ba3997c28a718652f54a84c631.tar.bz2 |
Autogen: Determine settings file name only once
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 38 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.h | 6 |
2 files changed, 20 insertions, 24 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 2c65db8..89b90b2 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -76,14 +76,6 @@ static void InfoGet(cmMakefile* makefile, const char* key, cmSystemTools::ExpandListArgument(valueConf, list); } -static std::string SettingsFile(const std::string& targetDirectory) -{ - std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); - cmSystemTools::ConvertToUnixSlashes(filename); - filename += "/AutogenOldSettings.cmake"; - return filename; -} - inline static bool SettingsMatch(cmMakefile* makefile, const char* key, const std::string& value) { @@ -286,12 +278,12 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, bool success = false; if (this->ReadAutogenInfoFile(mf.get(), targetDirectory, config)) { // Read old settings - this->SettingsFileRead(mf.get(), targetDirectory); + this->SettingsFileRead(mf.get()); // Init and run this->Init(mf.get()); if (this->RunAutogen()) { // Write current settings - if (this->SettingsFileWrite(targetDirectory)) { + if (this->SettingsFileWrite()) { success = true; } } @@ -338,6 +330,13 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( return false; } + // - Old settings file + { + this->SettingsFile = cmSystemTools::CollapseFullPath(targetDirectory); + cmSystemTools::ConvertToUnixSlashes(this->SettingsFile); + this->SettingsFile += "/AutogenOldSettings.cmake"; + } + // - Target names InfoGet(makefile, "AM_TARGET_NAME", this->AutogenTargetName); InfoGet(makefile, "AM_ORIGIN_TARGET_NAME", this->OriginTargetName); @@ -489,8 +488,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( return true; } -void cmQtAutoGenerators::SettingsFileRead(cmMakefile* makefile, - const std::string& targetDirectory) +void cmQtAutoGenerators::SettingsFileRead(cmMakefile* makefile) { // Compose current settings strings if (this->MocEnabled()) { @@ -518,8 +516,7 @@ void cmQtAutoGenerators::SettingsFileRead(cmMakefile* makefile, } // Read old settings - const std::string filename = SettingsFile(targetDirectory); - if (makefile->ReadListFile(filename.c_str())) { + if (makefile->ReadListFile(this->SettingsFile.c_str())) { if (!SettingsMatch(makefile, SettingsKeyMoc, this->SettingsStringMoc)) { this->MocSettingsChanged = true; } @@ -533,7 +530,7 @@ void cmQtAutoGenerators::SettingsFileRead(cmMakefile* makefile, // This triggers a full rebuild on the next run if the current // build is aborted before writing the current settings in the end. if (this->AnySettingsChanged()) { - cmSystemTools::RemoveFile(filename); + cmSystemTools::RemoveFile(this->SettingsFile); } } else { // If the file could not be read re-generate everythiung. @@ -543,17 +540,16 @@ void cmQtAutoGenerators::SettingsFileRead(cmMakefile* makefile, } } -bool cmQtAutoGenerators::SettingsFileWrite(const std::string& targetDirectory) +bool cmQtAutoGenerators::SettingsFileWrite() { bool success = true; // Only write if any setting changed if (this->AnySettingsChanged()) { - const std::string filename = SettingsFile(targetDirectory); if (this->Verbose) { - this->LogInfo("AutoGen: Writing settings file " + filename); + this->LogInfo("AutoGen: Writing settings file " + this->SettingsFile); } cmsys::ofstream outfile; - outfile.open(filename.c_str(), std::ios::trunc); + outfile.open(this->SettingsFile.c_str(), std::ios::trunc); if (outfile) { SettingWrite(outfile, SettingsKeyMoc, this->SettingsStringMoc); SettingWrite(outfile, SettingsKeyUic, this->SettingsStringUic); @@ -563,9 +559,9 @@ bool cmQtAutoGenerators::SettingsFileWrite(const std::string& targetDirectory) } else { success = false; // Remove old settings file to trigger full rebuild on next run - cmSystemTools::RemoveFile(filename); + cmSystemTools::RemoveFile(this->SettingsFile); this->LogError("AutoGen: Error: Writing old settings file failed: " + - filename); + this->SettingsFile); } } return success; diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index a15efc1..7ef2d6e 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -44,9 +44,8 @@ private: bool RccEnabled() const { return !this->RccExecutable.empty(); } // -- Settings file - void SettingsFileRead(cmMakefile* makefile, - const std::string& targetDirectory); - bool SettingsFileWrite(const std::string& targetDirectory); + void SettingsFileRead(cmMakefile* makefile); + bool SettingsFileWrite(); bool AnySettingsChanged() const { @@ -176,6 +175,7 @@ private: bool IncludeProjectDirsBefore; bool Verbose; bool ColorOutput; + std::string SettingsFile; std::string SettingsStringMoc; std::string SettingsStringUic; std::string SettingsStringRcc; |