summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoRcc.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-09-20 20:39:13 (GMT)
committerBrad King <brad.king@kitware.com>2019-09-25 14:07:09 (GMT)
commitd867e058924d348ee5ec5bba867965e8f1f276e2 (patch)
tree630f67b2bcce99327a769ef591b1f1698cf76742 /Source/cmQtAutoRcc.cxx
parent881e3cfbf96c7b4f48304d3dfc07899c2e6703de (diff)
downloadCMake-d867e058924d348ee5ec5bba867965e8f1f276e2.zip
CMake-d867e058924d348ee5ec5bba867965e8f1f276e2.tar.gz
CMake-d867e058924d348ee5ec5bba867965e8f1f276e2.tar.bz2
Autogen: Use JSON instead of CMake script for info files
We used to store information for the _autogen target in a CMake script file AutogenInfo.cmake, which was imported by a temporary cmake instance in the _autogen target. This introduced the overhead of creating a temporary cmake instance and inherited the limitations of the CMake language which only supports lists. This patch introduces JSON files to pass information to AUTORCC and autogen_ targets. JSON files are more flexible for passing data, e.g. they support nested lists. The patch has the side effects that - AutogenInfo.cmake is renamed to AutogenInfo.json - AutogenOldSettings.txt is renamed to AutogenUsed.txt - RCC<qrcBaseName><checksum>Info.cmake is renamed to AutoRcc_<qrcBaseName>_<checksum>_Info.json - RCC<qrcBaseName><checksum>.lock is renamed to AutoRcc_<qrcBaseName>_<checksum>_Lock.lock - RCC<qrcBaseName><checksum>Settings.txt is renamed to AutoRcc_<qrcBaseName>_<checksum>_Used.txt
Diffstat (limited to 'Source/cmQtAutoRcc.cxx')
-rw-r--r--Source/cmQtAutoRcc.cxx116
1 files changed, 26 insertions, 90 deletions
diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx
index 1bf8ca4..b0b15d4 100644
--- a/Source/cmQtAutoRcc.cxx
+++ b/Source/cmQtAutoRcc.cxx
@@ -6,7 +6,6 @@
#include "cmCryptoHash.h"
#include "cmDuration.h"
#include "cmFileLockResult.h"
-#include "cmMakefile.h"
#include "cmProcessOutput.h"
#include "cmQtAutoGen.h"
#include "cmStringAlgorithms.h"
@@ -16,112 +15,49 @@
#include <algorithm>
-cmQtAutoRcc::cmQtAutoRcc() = default;
+cmQtAutoRcc::cmQtAutoRcc()
+ : cmQtAutoGenerator(GenT::RCC)
+{
+}
cmQtAutoRcc::~cmQtAutoRcc() = default;
-bool cmQtAutoRcc::Init(cmMakefile* makefile)
+bool cmQtAutoRcc::InitFromInfo()
{
- // -- Utility lambdas
- auto InfoGet = [makefile](cm::string_view key) {
- return makefile->GetSafeDefinition(std::string(key));
- };
- auto InfoGetList =
- [makefile](cm::string_view key) -> std::vector<std::string> {
- return cmExpandedList(makefile->GetSafeDefinition(std::string(key)));
- };
- auto InfoGetConfig = [makefile, this](cm::string_view key) -> std::string {
- if (const char* valueConf =
- makefile->GetDefinition(cmStrCat(key, '_', InfoConfig()))) {
- return std::string(valueConf);
- }
- return makefile->GetSafeDefinition(std::string(key));
- };
- auto InfoGetConfigList =
- [&InfoGetConfig](cm::string_view key) -> std::vector<std::string> {
- return cmExpandedList(InfoGetConfig(key));
- };
- auto LogInfoError = [this](cm::string_view msg) -> bool {
- this->Log().Error(
- GenT::RCC, cmStrCat("In ", MessagePath(this->InfoFile()), ":\n", msg));
+ // -- Required settings
+ if (!InfoBool("MULTI_CONFIG", MultiConfig_, true) ||
+ !InfoString("BUILD_DIR", AutogenBuildDir_, true) ||
+ !InfoStringConfig("INCLUDE_DIR", IncludeDir_, true) ||
+ !InfoString("RCC_EXECUTABLE", RccExecutable_, true) ||
+ !InfoArray("RCC_LIST_OPTIONS", RccListOptions_, false) ||
+ !InfoString("LOCK_FILE", LockFile_, true) ||
+ !InfoStringConfig("SETTINGS_FILE", SettingsFile_, true) ||
+ !InfoString("SOURCE", QrcFile_, true) ||
+ !InfoString("OUTPUT_CHECKSUM", RccPathChecksum_, true) ||
+ !InfoString("OUTPUT_NAME", RccFileName_, true) ||
+ !InfoArray("OPTIONS", Options_, false) ||
+ !InfoArray("INPUTS", Inputs_, false)) {
return false;
- };
-
- // -- Read info file
- if (!makefile->ReadListFile(InfoFile())) {
- return LogInfoError("File processing failed.");
}
- // - Configurations
- Logger_.RaiseVerbosity(InfoGet("ARCC_VERBOSITY"));
- MultiConfig_ = makefile->IsOn("ARCC_MULTI_CONFIG");
-
- // - Directories
- ProjectDirsRef().Source = InfoGet("ARCC_CMAKE_SOURCE_DIR");
- ProjectDirsRef().Binary = InfoGet("ARCC_CMAKE_BINARY_DIR");
- AutogenBuildDir_ = InfoGet("ARCC_BUILD_DIR");
- if (AutogenBuildDir_.empty()) {
- return LogInfoError("Build directory empty.");
- }
-
- IncludeDir_ = InfoGetConfig("ARCC_INCLUDE_DIR");
- if (IncludeDir_.empty()) {
- return LogInfoError("Include directory empty.");
- }
-
- // - Rcc executable
- RccExecutable_ = InfoGet("ARCC_RCC_EXECUTABLE");
- if (!RccExecutableTime_.Load(RccExecutable_)) {
- return LogInfoError(cmStrCat(
- "The rcc executable ", MessagePath(RccExecutable_), " does not exist."));
- }
- RccListOptions_ = InfoGetList("ARCC_RCC_LIST_OPTIONS");
-
- // - Job
- LockFile_ = InfoGet("ARCC_LOCK_FILE");
- QrcFile_ = InfoGet("ARCC_SOURCE");
+ // -- Derive information
QrcFileName_ = cmSystemTools::GetFilenameName(QrcFile_);
QrcFileDir_ = cmSystemTools::GetFilenamePath(QrcFile_);
- RccPathChecksum_ = InfoGet("ARCC_OUTPUT_CHECKSUM");
- RccFileName_ = InfoGet("ARCC_OUTPUT_NAME");
- Options_ = InfoGetConfigList("ARCC_OPTIONS");
- Inputs_ = InfoGetList("ARCC_INPUTS");
-
- // - Settings file
- SettingsFile_ = InfoGetConfig("ARCC_SETTINGS_FILE");
-
- // - Validity checks
- if (LockFile_.empty()) {
- return LogInfoError("Lock file name missing.");
- }
- if (SettingsFile_.empty()) {
- return LogInfoError("Settings file name missing.");
- }
- if (AutogenBuildDir_.empty()) {
- return LogInfoError("Autogen build directory missing.");
- }
- if (RccExecutable_.empty()) {
- return LogInfoError("rcc executable missing.");
- }
- if (QrcFile_.empty()) {
- return LogInfoError("rcc input file missing.");
- }
- if (RccFileName_.empty()) {
- return LogInfoError("rcc output file missing.");
- }
-
- // Init derived information
- // ------------------------
-
RccFilePublic_ =
cmStrCat(AutogenBuildDir_, '/', RccPathChecksum_, '/', RccFileName_);
- // Compute rcc output file name
+ // rcc output file name
if (IsMultiConfig()) {
RccFileOutput_ = cmStrCat(IncludeDir_, '/', MultiConfigOutput());
} else {
RccFileOutput_ = RccFilePublic_;
}
+ // -- Checks
+ if (!RccExecutableTime_.Load(RccExecutable_)) {
+ return LogInfoError(cmStrCat(
+ "The rcc executable ", MessagePath(RccExecutable_), " does not exist."));
+ }
+
return true;
}