diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2017-01-11 13:45:04 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2017-01-12 23:00:43 (GMT) |
commit | 119791ae528aace81f6c209e05798c80d8926b3d (patch) | |
tree | d735dbc14e0f3d527364d80b26ab0c9f5ffcb07f /Source | |
parent | 95e4cfc5947fb5a324f6dad50cff8d71f928aba8 (diff) | |
download | CMake-119791ae528aace81f6c209e05798c80d8926b3d.zip CMake-119791ae528aace81f6c209e05798c80d8926b3d.tar.gz CMake-119791ae528aace81f6c209e05798c80d8926b3d.tar.bz2 |
Autogen: Generators: Introduce FileAbsentOrOlder function
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 54 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.h | 2 |
2 files changed, 30 insertions, 26 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f3fa047..c766d54 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -91,6 +91,19 @@ static std::string ReadAll(const std::string& filename) return stream.str(); } +/** + * @brief Tests if buildFile doesn't exist or is older than sourceFile + * @return True if buildFile doesn't exist or is older than sourceFile + */ +static bool FileAbsentOrOlder(const std::string& buildFile, + const std::string& sourceFile) +{ + int result = 0; + bool success = + cmsys::SystemTools::FileTimeCompare(buildFile, sourceFile, &result); + return (!success || (result <= 0)); +} + static bool ListContains(const std::vector<std::string>& list, const std::string& entry) { @@ -1284,22 +1297,6 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, return false; } -bool cmQtAutoGenerators::InputFilesNewerThanQrc(const std::string& qrcFile, - const std::string& rccOutput) -{ - std::vector<std::string> const& files = this->RccInputs[qrcFile]; - for (std::vector<std::string>::const_iterator it = files.begin(); - it != files.end(); ++it) { - int inputNewerThanQrc = 0; - bool success = - cmsys::SystemTools::FileTimeCompare(*it, rccOutput, &inputNewerThanQrc); - if (!success || inputNewerThanQrc >= 0) { - return true; - } - } - return false; -} - bool cmQtAutoGenerators::GenerateQrcFiles() { // generate single map with input / output names @@ -1361,14 +1358,23 @@ bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile, const std::string qrcBuildFile = this->CurrentBinaryDir + qrcOutputFile; - int sourceNewerThanQrc = 0; - bool generateQrc = !cmsys::SystemTools::FileTimeCompare( - qrcInputFile, qrcBuildFile, &sourceNewerThanQrc); - generateQrc = generateQrc || (sourceNewerThanQrc >= 0); - generateQrc = - generateQrc || this->InputFilesNewerThanQrc(qrcInputFile, qrcBuildFile); - - if (this->GenerateAll || generateQrc) { + bool generateQrc = this->GenerateAll; + // Test if the resources list file is newer than build file + if (!generateQrc) { + generateQrc = FileAbsentOrOlder(qrcBuildFile, qrcInputFile); + } + // Test if any resource file is newer than the build file + if (!generateQrc) { + const std::vector<std::string>& files = this->RccInputs[qrcInputFile]; + for (std::vector<std::string>::const_iterator it = files.begin(); + it != files.end(); ++it) { + if (FileAbsentOrOlder(qrcBuildFile, *it)) { + generateQrc = true; + break; + } + } + } + if (generateQrc) { { std::string msg = "Generating RCC source "; msg += qrcOutputFile; diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index b9d670a..3223c6d 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -86,8 +86,6 @@ private: const std::string& uiOutputFile); // - Qrc file generation - bool InputFilesNewerThanQrc(const std::string& qrcFile, - const std::string& rccOutput); bool GenerateQrcFiles(); bool GenerateQrc(const std::string& qrcInputFile, const std::string& qrcOutputFile, bool unique_n); |