diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2021-12-21 19:39:04 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2022-01-06 23:52:30 (GMT) |
commit | fd6ea2f67fc5fd1aee27ae92d6a16bc0fba1209e (patch) | |
tree | c4dbf6fc64a862facea8948d350df173393a2629 /Source | |
parent | 13e71b7c3ec9351f0c25656e72c1c0199ddf771c (diff) | |
download | CMake-fd6ea2f67fc5fd1aee27ae92d6a16bc0fba1209e.zip CMake-fd6ea2f67fc5fd1aee27ae92d6a16bc0fba1209e.tar.gz CMake-fd6ea2f67fc5fd1aee27ae92d6a16bc0fba1209e.tar.bz2 |
Refactor: Rename cmCMakePresetsFile to cmCMakePresetsGraph
And change all references to "file" to say "graph" instead.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeLists.txt | 8 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.cxx | 4 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.h | 2 | ||||
-rw-r--r-- | Source/QtDialog/QCMake.cxx | 22 | ||||
-rw-r--r-- | Source/QtDialog/QCMake.h | 12 | ||||
-rw-r--r-- | Source/QtDialog/QCMakePreset.h | 2 | ||||
-rw-r--r-- | Source/cmCMakePresetsGraph.cxx (renamed from Source/cmCMakePresetsFile.cxx) | 191 | ||||
-rw-r--r-- | Source/cmCMakePresetsGraph.h (renamed from Source/cmCMakePresetsFile.h) | 4 | ||||
-rw-r--r-- | Source/cmCMakePresetsGraphInternal.h (renamed from Source/cmCMakePresetsFileInternal.h) | 24 | ||||
-rw-r--r-- | Source/cmCMakePresetsGraphReadJSON.cxx (renamed from Source/cmCMakePresetsFileReadJSON.cxx) | 94 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 34 | ||||
-rw-r--r-- | Source/cmake.cxx | 42 | ||||
-rw-r--r-- | Source/cmake.h | 6 |
13 files changed, 224 insertions, 221 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 677fd2f..e0c5ed9 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -161,10 +161,10 @@ set(SRCS cmCLocaleEnvironmentScope.cxx cmCMakePath.h cmCMakePath.cxx - cmCMakePresetsFile.cxx - cmCMakePresetsFile.h - cmCMakePresetsFileInternal.h - cmCMakePresetsFileReadJSON.cxx + cmCMakePresetsGraph.cxx + cmCMakePresetsGraph.h + cmCMakePresetsGraphInternal.h + cmCMakePresetsGraphReadJSON.cxx cmCommandArgumentParserHelper.cxx cmCommonTargetGenerator.cxx cmCommonTargetGenerator.h diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 1785571..f90b781 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -730,12 +730,12 @@ void CMakeSetupDialog::updatePreset(const QString& name) } void CMakeSetupDialog::showPresetLoadError( - const QString& dir, cmCMakePresetsFile::ReadFileResult result) + const QString& dir, cmCMakePresetsGraph::ReadFileResult result) { QMessageBox::warning( this, "Error Reading CMake Presets", QString::fromLocal8Bit("Could not read presets from %1: %2") - .arg(dir, cmCMakePresetsFile::ResultToString(result))); + .arg(dir, cmCMakePresetsGraph::ResultToString(result))); } void CMakeSetupDialog::doBinaryBrowse() diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index f0cc929..8aee70d 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -60,7 +60,7 @@ protected slots: void updatePresets(const QVector<QCMakePreset>& presets); void updatePreset(const QString& name); void showPresetLoadError(const QString& dir, - cmCMakePresetsFile::ReadFileResult result); + cmCMakePresetsGraph::ReadFileResult result); void showProgress(const QString& msg, float percent); void setEnabledState(bool); bool setupFirstConfigure(); diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 8ab8656..ffb6157 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -32,7 +32,7 @@ QCMake::QCMake(QObject* p) qRegisterMetaType<QCMakePropertyList>(); qRegisterMetaType<QProcessEnvironment>(); qRegisterMetaType<QVector<QCMakePreset>>(); - qRegisterMetaType<cmCMakePresetsFile::ReadFileResult>(); + qRegisterMetaType<cmCMakePresetsGraph::ReadFileResult>(); cmSystemTools::DisableRunCommandOutput(); cmSystemTools::SetRunCommandHideConsole(true); @@ -69,9 +69,9 @@ QCMake::QCMake(QObject* p) connect(&this->LoadPresetsTimer, &QTimer::timeout, this, [this]() { this->loadPresets(); if (!this->PresetName.isEmpty() && - this->CMakePresetsFile.ConfigurePresets.find( + this->CMakePresetsGraph.ConfigurePresets.find( std::string(this->PresetName.toLocal8Bit())) == - this->CMakePresetsFile.ConfigurePresets.end()) { + this->CMakePresetsGraph.ConfigurePresets.end()) { this->setPreset(QString{}); } }); @@ -159,7 +159,7 @@ void QCMake::setPreset(const QString& name, bool setBinary) if (!name.isNull()) { std::string presetName(name.toLocal8Bit()); auto const& expandedPreset = - this->CMakePresetsFile.ConfigurePresets[presetName].Expanded; + this->CMakePresetsGraph.ConfigurePresets[presetName].Expanded; if (expandedPreset) { if (setBinary && !expandedPreset->BinaryDir.empty()) { QString binaryDir = @@ -427,7 +427,7 @@ QCMakePropertyList QCMake::properties() const if (!this->PresetName.isNull()) { std::string presetName(this->PresetName.toLocal8Bit()); auto const& p = - this->CMakePresetsFile.ConfigurePresets.at(presetName).Expanded; + this->CMakePresetsGraph.ConfigurePresets.at(presetName).Expanded; if (p) { for (auto const& v : p->CacheVariables) { if (!v.second) { @@ -533,17 +533,17 @@ void QCMake::setUpEnvironment() const void QCMake::loadPresets() { - auto result = this->CMakePresetsFile.ReadProjectPresets( + auto result = this->CMakePresetsGraph.ReadProjectPresets( this->SourceDirectory.toLocal8Bit().data(), true); if (result != this->LastLoadPresetsResult && - result != cmCMakePresetsFile::ReadFileResult::READ_OK) { + result != cmCMakePresetsGraph::ReadFileResult::READ_OK) { emit this->presetLoadError(this->SourceDirectory, result); } this->LastLoadPresetsResult = result; QVector<QCMakePreset> presets; - for (auto const& name : this->CMakePresetsFile.ConfigurePresetOrder) { - auto const& it = this->CMakePresetsFile.ConfigurePresets[name]; + for (auto const& name : this->CMakePresetsGraph.ConfigurePresetOrder) { + auto const& it = this->CMakePresetsGraph.ConfigurePresets[name]; auto const& p = it.Unexpanded; if (p.Hidden) { continue; @@ -556,10 +556,10 @@ void QCMake::loadPresets() preset.generator = QString::fromLocal8Bit(p.Generator.data()); preset.architecture = QString::fromLocal8Bit(p.Architecture.data()); preset.setArchitecture = !p.ArchitectureStrategy || - p.ArchitectureStrategy == cmCMakePresetsFile::ArchToolsetStrategy::Set; + p.ArchitectureStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set; preset.toolset = QString::fromLocal8Bit(p.Toolset.data()); preset.setToolset = !p.ToolsetStrategy || - p.ToolsetStrategy == cmCMakePresetsFile::ArchToolsetStrategy::Set; + p.ToolsetStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set; preset.enabled = it.Expanded && it.Expanded->ConditionResult && std::find_if(this->AvailableGenerators.begin(), this->AvailableGenerators.end(), diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index a6751b0..8a7e4cb 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -4,7 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmCMakePresetsFile.h" +#include "cmCMakePresetsGraph.h" #include "cmake.h" #ifdef _MSC_VER @@ -60,7 +60,7 @@ using QCMakePropertyList = QList<QCMakeProperty>; Q_DECLARE_METATYPE(QCMakeProperty) Q_DECLARE_METATYPE(QCMakePropertyList) Q_DECLARE_METATYPE(QProcessEnvironment) -Q_DECLARE_METATYPE(cmCMakePresetsFile::ReadFileResult) +Q_DECLARE_METATYPE(cmCMakePresetsGraph::ReadFileResult) /// Qt API for CMake library. /// Wrapper like class allows for easier integration with @@ -159,7 +159,7 @@ signals: void presetChanged(const QString& name); /// signal when there's an error reading the presets files void presetLoadError(const QString& dir, - cmCMakePresetsFile::ReadFileResult error); + cmCMakePresetsGraph::ReadFileResult error); /// signal when uninitialized warning changes void warnUninitializedModeChanged(bool value); /// signal for progress events @@ -202,9 +202,9 @@ protected: QString Platform; QString Toolset; std::vector<cmake::GeneratorInfo> AvailableGenerators; - cmCMakePresetsFile CMakePresetsFile; - cmCMakePresetsFile::ReadFileResult LastLoadPresetsResult = - cmCMakePresetsFile::ReadFileResult::READ_OK; + cmCMakePresetsGraph CMakePresetsGraph; + cmCMakePresetsGraph::ReadFileResult LastLoadPresetsResult = + cmCMakePresetsGraph::ReadFileResult::READ_OK; QString PresetName; QString CMakeExecutable; QAtomicInt InterruptFlag; diff --git a/Source/QtDialog/QCMakePreset.h b/Source/QtDialog/QCMakePreset.h index 1609fcb..7387655 100644 --- a/Source/QtDialog/QCMakePreset.h +++ b/Source/QtDialog/QCMakePreset.h @@ -5,7 +5,7 @@ #include <QString> #include <QVariant> -#include "cmCMakePresetsFile.h" +#include "cmCMakePresetsGraph.h" class QCMakePreset { diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsGraph.cxx index 4a0742a..ebc243b 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsGraph.cxx @@ -1,6 +1,6 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmCMakePresetsFile.h" +#include "cmCMakePresetsGraph.h" #include <algorithm> #include <cstdlib> @@ -13,7 +13,7 @@ #include "cmsys/RegularExpression.hxx" -#include "cmCMakePresetsFileInternal.h" +#include "cmCMakePresetsGraphInternal.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -38,12 +38,12 @@ enum class CycleStatus Verified, }; -using ReadFileResult = cmCMakePresetsFile::ReadFileResult; -using ConfigurePreset = cmCMakePresetsFile::ConfigurePreset; -using BuildPreset = cmCMakePresetsFile::BuildPreset; -using TestPreset = cmCMakePresetsFile::TestPreset; -using ExpandMacroResult = cmCMakePresetsFileInternal::ExpandMacroResult; -using MacroExpander = cmCMakePresetsFileInternal::MacroExpander; +using ReadFileResult = cmCMakePresetsGraph::ReadFileResult; +using ConfigurePreset = cmCMakePresetsGraph::ConfigurePreset; +using BuildPreset = cmCMakePresetsGraph::BuildPreset; +using TestPreset = cmCMakePresetsGraph::TestPreset; +using ExpandMacroResult = cmCMakePresetsGraphInternal::ExpandMacroResult; +using MacroExpander = cmCMakePresetsGraphInternal::MacroExpander; void InheritString(std::string& child, const std::string& parent) { @@ -77,9 +77,10 @@ void InheritVector(std::vector<T>& child, const std::vector<T>& parent) */ template <class T> ReadFileResult VisitPreset( - T& preset, std::map<std::string, cmCMakePresetsFile::PresetPair<T>>& presets, + T& preset, + std::map<std::string, cmCMakePresetsGraph::PresetPair<T>>& presets, std::map<std::string, CycleStatus> cycleStatus, - const cmCMakePresetsFile& file) + const cmCMakePresetsGraph& graph) { switch (cycleStatus[preset.Name]) { case CycleStatus::InProgress: @@ -109,7 +110,7 @@ ReadFileResult VisitPreset( return ReadFileResult::USER_PRESET_INHERITANCE; } - auto result = VisitPreset(parentPreset, presets, cycleStatus, file); + auto result = VisitPreset(parentPreset, presets, cycleStatus, graph); if (result != ReadFileResult::READ_OK) { return result; } @@ -129,7 +130,7 @@ ReadFileResult VisitPreset( preset.ConditionEvaluator.reset(); } - CHECK_OK(preset.VisitPresetAfterInherit(file.GetVersion(preset))); + CHECK_OK(preset.VisitPresetAfterInherit(graph.GetVersion(preset))); cycleStatus[preset.Name] = CycleStatus::Verified; return ReadFileResult::READ_OK; @@ -137,8 +138,8 @@ ReadFileResult VisitPreset( template <class T> ReadFileResult ComputePresetInheritance( - std::map<std::string, cmCMakePresetsFile::PresetPair<T>>& presets, - const cmCMakePresetsFile& file) + std::map<std::string, cmCMakePresetsGraph::PresetPair<T>>& presets, + const cmCMakePresetsGraph& graph) { std::map<std::string, CycleStatus> cycleStatus; for (auto const& it : presets) { @@ -147,7 +148,7 @@ ReadFileResult ComputePresetInheritance( for (auto& it : presets) { auto& preset = it.second.Unexpanded; - auto result = VisitPreset<T>(preset, presets, cycleStatus, file); + auto result = VisitPreset<T>(preset, presets, cycleStatus, graph); if (result != ReadFileResult::READ_OK) { return result; } @@ -189,17 +190,17 @@ ExpandMacroResult ExpandMacro(std::string& out, const std::vector<MacroExpander>& macroExpanders, int version); -bool ExpandMacros(const cmCMakePresetsFile& file, +bool ExpandMacros(const cmCMakePresetsGraph& graph, const ConfigurePreset& preset, cm::optional<ConfigurePreset>& out, const std::vector<MacroExpander>& macroExpanders) { std::string binaryDir = preset.BinaryDir; - CHECK_EXPAND(out, binaryDir, macroExpanders, file.GetVersion(preset)); + CHECK_EXPAND(out, binaryDir, macroExpanders, graph.GetVersion(preset)); if (!binaryDir.empty()) { if (!cmSystemTools::FileIsFullPath(binaryDir)) { - binaryDir = cmStrCat(file.SourceDir, '/', binaryDir); + binaryDir = cmStrCat(graph.SourceDir, '/', binaryDir); } out->BinaryDir = cmSystemTools::CollapseFullPath(binaryDir); cmSystemTools::ConvertToUnixSlashes(out->BinaryDir); @@ -207,10 +208,10 @@ bool ExpandMacros(const cmCMakePresetsFile& file, if (!preset.InstallDir.empty()) { std::string installDir = preset.InstallDir; - CHECK_EXPAND(out, installDir, macroExpanders, file.GetVersion(preset)); + CHECK_EXPAND(out, installDir, macroExpanders, graph.GetVersion(preset)); if (!cmSystemTools::FileIsFullPath(installDir)) { - installDir = cmStrCat(file.SourceDir, '/', installDir); + installDir = cmStrCat(graph.SourceDir, '/', installDir); } out->InstallDir = cmSystemTools::CollapseFullPath(installDir); cmSystemTools::ConvertToUnixSlashes(out->InstallDir); @@ -218,89 +219,89 @@ bool ExpandMacros(const cmCMakePresetsFile& file, if (!preset.ToolchainFile.empty()) { std::string toolchain = preset.ToolchainFile; - CHECK_EXPAND(out, toolchain, macroExpanders, file.GetVersion(preset)); + CHECK_EXPAND(out, toolchain, macroExpanders, graph.GetVersion(preset)); out->ToolchainFile = toolchain; } for (auto& variable : out->CacheVariables) { if (variable.second) { CHECK_EXPAND(out, variable.second->Value, macroExpanders, - file.GetVersion(preset)); + graph.GetVersion(preset)); } } return true; } -bool ExpandMacros(const cmCMakePresetsFile& file, const BuildPreset& preset, +bool ExpandMacros(const cmCMakePresetsGraph& graph, const BuildPreset& preset, cm::optional<BuildPreset>& out, const std::vector<MacroExpander>& macroExpanders) { for (auto& target : out->Targets) { - CHECK_EXPAND(out, target, macroExpanders, file.GetVersion(preset)); + CHECK_EXPAND(out, target, macroExpanders, graph.GetVersion(preset)); } for (auto& nativeToolOption : out->NativeToolOptions) { CHECK_EXPAND(out, nativeToolOption, macroExpanders, - file.GetVersion(preset)); + graph.GetVersion(preset)); } return true; } -bool ExpandMacros(const cmCMakePresetsFile& file, const TestPreset& preset, +bool ExpandMacros(const cmCMakePresetsGraph& graph, const TestPreset& preset, cm::optional<TestPreset>& out, const std::vector<MacroExpander>& macroExpanders) { for (auto& overwrite : out->OverwriteConfigurationFile) { - CHECK_EXPAND(out, overwrite, macroExpanders, file.GetVersion(preset)); + CHECK_EXPAND(out, overwrite, macroExpanders, graph.GetVersion(preset)); } if (out->Output) { CHECK_EXPAND(out, out->Output->OutputLogFile, macroExpanders, - file.GetVersion(preset)); + graph.GetVersion(preset)); } if (out->Filter) { if (out->Filter->Include) { CHECK_EXPAND(out, out->Filter->Include->Name, macroExpanders, - file.GetVersion(preset)); + graph.GetVersion(preset)); CHECK_EXPAND(out, out->Filter->Include->Label, macroExpanders, - file.GetVersion(preset)); + graph.GetVersion(preset)); if (out->Filter->Include->Index) { CHECK_EXPAND(out, out->Filter->Include->Index->IndexFile, - macroExpanders, file.GetVersion(preset)); + macroExpanders, graph.GetVersion(preset)); } } if (out->Filter->Exclude) { CHECK_EXPAND(out, out->Filter->Exclude->Name, macroExpanders, - file.GetVersion(preset)); + graph.GetVersion(preset)); CHECK_EXPAND(out, out->Filter->Exclude->Label, macroExpanders, - file.GetVersion(preset)); + graph.GetVersion(preset)); if (out->Filter->Exclude->Fixtures) { CHECK_EXPAND(out, out->Filter->Exclude->Fixtures->Any, macroExpanders, - file.GetVersion(preset)); + graph.GetVersion(preset)); CHECK_EXPAND(out, out->Filter->Exclude->Fixtures->Setup, - macroExpanders, file.GetVersion(preset)); + macroExpanders, graph.GetVersion(preset)); CHECK_EXPAND(out, out->Filter->Exclude->Fixtures->Cleanup, - macroExpanders, file.GetVersion(preset)); + macroExpanders, graph.GetVersion(preset)); } } } if (out->Execution) { CHECK_EXPAND(out, out->Execution->ResourceSpecFile, macroExpanders, - file.GetVersion(preset)); + graph.GetVersion(preset)); } return true; } template <class T> -bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, +bool ExpandMacros(const cmCMakePresetsGraph& graph, const T& preset, cm::optional<T>& out) { out.emplace(preset); @@ -313,20 +314,20 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, std::vector<MacroExpander> macroExpanders; MacroExpander defaultMacroExpander = - [&file, &preset](const std::string& macroNamespace, - const std::string& macroName, std::string& macroOut, - int version) -> ExpandMacroResult { + [&graph, &preset](const std::string& macroNamespace, + const std::string& macroName, std::string& macroOut, + int version) -> ExpandMacroResult { if (macroNamespace.empty()) { if (macroName == "sourceDir") { - macroOut += file.SourceDir; + macroOut += graph.SourceDir; return ExpandMacroResult::Ok; } if (macroName == "sourceParentDir") { - macroOut += cmSystemTools::GetParentDirectory(file.SourceDir); + macroOut += cmSystemTools::GetParentDirectory(graph.SourceDir); return ExpandMacroResult::Ok; } if (macroName == "sourceDirName") { - macroOut += cmSystemTools::GetFilenameName(file.SourceDir); + macroOut += cmSystemTools::GetFilenameName(graph.SourceDir); return ExpandMacroResult::Ok; } if (macroName == "presetName") { @@ -336,7 +337,7 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, if (macroName == "generator") { // Generator only makes sense if preset is not hidden. if (!preset.Hidden) { - macroOut += file.GetGeneratorForPreset(preset.Name); + macroOut += graph.GetGeneratorForPreset(preset.Name); } return ExpandMacroResult::Ok; } @@ -393,7 +394,7 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, for (auto& v : out->Environment) { if (v.second) { switch (VisitEnv(*v.second, envCycles[v.first], macroExpanders, - file.GetVersion(preset))) { + graph.GetVersion(preset))) { case ExpandMacroResult::Error: return false; case ExpandMacroResult::Ignore: @@ -408,7 +409,7 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, if (preset.ConditionEvaluator) { cm::optional<bool> result; if (!preset.ConditionEvaluator->Evaluate( - macroExpanders, file.GetVersion(preset), result)) { + macroExpanders, graph.GetVersion(preset), result)) { return false; } if (!result) { @@ -418,7 +419,7 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, out->ConditionResult = *result; } - return ExpandMacros(file, preset, out, macroExpanders); + return ExpandMacros(graph, preset, out, macroExpanders); } ExpandMacroResult VisitEnv(std::string& value, CycleStatus& status, @@ -541,7 +542,7 @@ ExpandMacroResult ExpandMacro(std::string& out, } } -bool cmCMakePresetsFileInternal::EqualsCondition::Evaluate( +bool cmCMakePresetsGraphInternal::EqualsCondition::Evaluate( const std::vector<MacroExpander>& expanders, int version, cm::optional<bool>& out) const { @@ -555,7 +556,7 @@ bool cmCMakePresetsFileInternal::EqualsCondition::Evaluate( return true; } -bool cmCMakePresetsFileInternal::InListCondition::Evaluate( +bool cmCMakePresetsGraphInternal::InListCondition::Evaluate( const std::vector<MacroExpander>& expanders, int version, cm::optional<bool>& out) const { @@ -574,7 +575,7 @@ bool cmCMakePresetsFileInternal::InListCondition::Evaluate( return true; } -bool cmCMakePresetsFileInternal::MatchesCondition::Evaluate( +bool cmCMakePresetsGraphInternal::MatchesCondition::Evaluate( const std::vector<MacroExpander>& expanders, int version, cm::optional<bool>& out) const { @@ -592,7 +593,7 @@ bool cmCMakePresetsFileInternal::MatchesCondition::Evaluate( return true; } -bool cmCMakePresetsFileInternal::AnyAllOfCondition::Evaluate( +bool cmCMakePresetsGraphInternal::AnyAllOfCondition::Evaluate( const std::vector<MacroExpander>& expanders, int version, cm::optional<bool>& out) const { @@ -618,7 +619,7 @@ bool cmCMakePresetsFileInternal::AnyAllOfCondition::Evaluate( return true; } -bool cmCMakePresetsFileInternal::NotCondition::Evaluate( +bool cmCMakePresetsGraphInternal::NotCondition::Evaluate( const std::vector<MacroExpander>& expanders, int version, cm::optional<bool>& out) const { @@ -633,9 +634,9 @@ bool cmCMakePresetsFileInternal::NotCondition::Evaluate( return true; } -cmCMakePresetsFile::ReadFileResult -cmCMakePresetsFile::ConfigurePreset::VisitPresetInherit( - const cmCMakePresetsFile::Preset& parentPreset) +cmCMakePresetsGraph::ReadFileResult +cmCMakePresetsGraph::ConfigurePreset::VisitPresetInherit( + const cmCMakePresetsGraph::Preset& parentPreset) { auto& preset = *this; const ConfigurePreset& parent = @@ -667,8 +668,8 @@ cmCMakePresetsFile::ConfigurePreset::VisitPresetInherit( return ReadFileResult::READ_OK; } -cmCMakePresetsFile::ReadFileResult -cmCMakePresetsFile::ConfigurePreset::VisitPresetBeforeInherit() +cmCMakePresetsGraph::ReadFileResult +cmCMakePresetsGraph::ConfigurePreset::VisitPresetBeforeInherit() { auto& preset = *this; if (preset.Environment.count("") != 0) { @@ -678,8 +679,8 @@ cmCMakePresetsFile::ConfigurePreset::VisitPresetBeforeInherit() return ReadFileResult::READ_OK; } -cmCMakePresetsFile::ReadFileResult -cmCMakePresetsFile::ConfigurePreset::VisitPresetAfterInherit(int version) +cmCMakePresetsGraph::ReadFileResult +cmCMakePresetsGraph::ConfigurePreset::VisitPresetAfterInherit(int version) { auto& preset = *this; if (!preset.Hidden) { @@ -706,9 +707,9 @@ cmCMakePresetsFile::ConfigurePreset::VisitPresetAfterInherit(int version) return ReadFileResult::READ_OK; } -cmCMakePresetsFile::ReadFileResult -cmCMakePresetsFile::BuildPreset::VisitPresetInherit( - const cmCMakePresetsFile::Preset& parentPreset) +cmCMakePresetsGraph::ReadFileResult +cmCMakePresetsGraph::BuildPreset::VisitPresetInherit( + const cmCMakePresetsGraph::Preset& parentPreset) { auto& preset = *this; const BuildPreset& parent = static_cast<const BuildPreset&>(parentPreset); @@ -726,8 +727,8 @@ cmCMakePresetsFile::BuildPreset::VisitPresetInherit( return ReadFileResult::READ_OK; } -cmCMakePresetsFile::ReadFileResult -cmCMakePresetsFile::BuildPreset::VisitPresetAfterInherit(int /* version */) +cmCMakePresetsGraph::ReadFileResult +cmCMakePresetsGraph::BuildPreset::VisitPresetAfterInherit(int /* version */) { auto& preset = *this; if (!preset.Hidden && preset.ConfigurePreset.empty()) { @@ -736,9 +737,9 @@ cmCMakePresetsFile::BuildPreset::VisitPresetAfterInherit(int /* version */) return ReadFileResult::READ_OK; } -cmCMakePresetsFile::ReadFileResult -cmCMakePresetsFile::TestPreset::VisitPresetInherit( - const cmCMakePresetsFile::Preset& parentPreset) +cmCMakePresetsGraph::ReadFileResult +cmCMakePresetsGraph::TestPreset::VisitPresetInherit( + const cmCMakePresetsGraph::Preset& parentPreset) { auto& preset = *this; const TestPreset& parent = static_cast<const TestPreset&>(parentPreset); @@ -836,8 +837,8 @@ cmCMakePresetsFile::TestPreset::VisitPresetInherit( return ReadFileResult::READ_OK; } -cmCMakePresetsFile::ReadFileResult -cmCMakePresetsFile::TestPreset::VisitPresetAfterInherit(int /* version */) +cmCMakePresetsGraph::ReadFileResult +cmCMakePresetsGraph::TestPreset::VisitPresetAfterInherit(int /* version */) { auto& preset = *this; if (!preset.Hidden && preset.ConfigurePreset.empty()) { @@ -846,17 +847,17 @@ cmCMakePresetsFile::TestPreset::VisitPresetAfterInherit(int /* version */) return ReadFileResult::READ_OK; } -std::string cmCMakePresetsFile::GetFilename(const std::string& sourceDir) +std::string cmCMakePresetsGraph::GetFilename(const std::string& sourceDir) { return cmStrCat(sourceDir, "/CMakePresets.json"); } -std::string cmCMakePresetsFile::GetUserFilename(const std::string& sourceDir) +std::string cmCMakePresetsGraph::GetUserFilename(const std::string& sourceDir) { return cmStrCat(sourceDir, "/CMakeUserPresets.json"); } -cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadProjectPresets( +cmCMakePresetsGraph::ReadFileResult cmCMakePresetsGraph::ReadProjectPresets( const std::string& sourceDir, bool allowNoFiles) { this->SourceDir = sourceDir; @@ -870,8 +871,8 @@ cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadProjectPresets( return result; } -cmCMakePresetsFile::ReadFileResult -cmCMakePresetsFile::ReadProjectPresetsInternal(bool allowNoFiles) +cmCMakePresetsGraph::ReadFileResult +cmCMakePresetsGraph::ReadProjectPresetsInternal(bool allowNoFiles) { bool haveOneFile = false; @@ -951,7 +952,7 @@ cmCMakePresetsFile::ReadProjectPresetsInternal(bool allowNoFiles) return ReadFileResult::READ_OK; } -const char* cmCMakePresetsFile::ResultToString(ReadFileResult result) +const char* cmCMakePresetsGraph::ResultToString(ReadFileResult result) { switch (result) { case ReadFileResult::READ_OK: @@ -1006,7 +1007,7 @@ const char* cmCMakePresetsFile::ResultToString(ReadFileResult result) return "Unknown error"; } -void cmCMakePresetsFile::ClearPresets() +void cmCMakePresetsGraph::ClearPresets() { this->ConfigurePresets.clear(); this->BuildPresets.clear(); @@ -1017,8 +1018,8 @@ void cmCMakePresetsFile::ClearPresets() this->TestPresetOrder.clear(); } -void cmCMakePresetsFile::PrintPresets( - const std::vector<const cmCMakePresetsFile::Preset*>& presets) +void cmCMakePresetsGraph::PrintPresets( + const std::vector<const cmCMakePresetsGraph::Preset*>& presets) { if (presets.empty()) { return; @@ -1026,8 +1027,8 @@ void cmCMakePresetsFile::PrintPresets( auto longestPresetName = std::max_element(presets.begin(), presets.end(), - [](const cmCMakePresetsFile::Preset* a, - const cmCMakePresetsFile::Preset* b) { + [](const cmCMakePresetsGraph::Preset* a, + const cmCMakePresetsGraph::Preset* b) { return a->Name.length() < b->Name.length(); }); auto longestLength = (*longestPresetName)->Name.length(); @@ -1045,67 +1046,67 @@ void cmCMakePresetsFile::PrintPresets( } } -void cmCMakePresetsFile::PrintConfigurePresetList() const +void cmCMakePresetsGraph::PrintConfigurePresetList() const { PrintConfigurePresetList([](const ConfigurePreset&) { return true; }); } -void cmCMakePresetsFile::PrintConfigurePresetList( +void cmCMakePresetsGraph::PrintConfigurePresetList( const std::function<bool(const ConfigurePreset&)>& filter) const { - std::vector<const cmCMakePresetsFile::Preset*> presets; + std::vector<const cmCMakePresetsGraph::Preset*> presets; for (auto const& p : this->ConfigurePresetOrder) { auto const& preset = this->ConfigurePresets.at(p); if (!preset.Unexpanded.Hidden && preset.Expanded && preset.Expanded->ConditionResult && filter(preset.Unexpanded)) { presets.push_back( - static_cast<const cmCMakePresetsFile::Preset*>(&preset.Unexpanded)); + static_cast<const cmCMakePresetsGraph::Preset*>(&preset.Unexpanded)); } } if (!presets.empty()) { std::cout << "Available configure presets:\n\n"; - cmCMakePresetsFile::PrintPresets(presets); + cmCMakePresetsGraph::PrintPresets(presets); } } -void cmCMakePresetsFile::PrintBuildPresetList() const +void cmCMakePresetsGraph::PrintBuildPresetList() const { - std::vector<const cmCMakePresetsFile::Preset*> presets; + std::vector<const cmCMakePresetsGraph::Preset*> presets; for (auto const& p : this->BuildPresetOrder) { auto const& preset = this->BuildPresets.at(p); if (!preset.Unexpanded.Hidden && preset.Expanded && preset.Expanded->ConditionResult) { presets.push_back( - static_cast<const cmCMakePresetsFile::Preset*>(&preset.Unexpanded)); + static_cast<const cmCMakePresetsGraph::Preset*>(&preset.Unexpanded)); } } if (!presets.empty()) { std::cout << "Available build presets:\n\n"; - cmCMakePresetsFile::PrintPresets(presets); + cmCMakePresetsGraph::PrintPresets(presets); } } -void cmCMakePresetsFile::PrintTestPresetList() const +void cmCMakePresetsGraph::PrintTestPresetList() const { - std::vector<const cmCMakePresetsFile::Preset*> presets; + std::vector<const cmCMakePresetsGraph::Preset*> presets; for (auto const& p : this->TestPresetOrder) { auto const& preset = this->TestPresets.at(p); if (!preset.Unexpanded.Hidden && preset.Expanded && preset.Expanded->ConditionResult) { presets.push_back( - static_cast<const cmCMakePresetsFile::Preset*>(&preset.Unexpanded)); + static_cast<const cmCMakePresetsGraph::Preset*>(&preset.Unexpanded)); } } if (!presets.empty()) { std::cout << "Available test presets:\n\n"; - cmCMakePresetsFile::PrintPresets(presets); + cmCMakePresetsGraph::PrintPresets(presets); } } -void cmCMakePresetsFile::PrintAllPresets() const +void cmCMakePresetsGraph::PrintAllPresets() const { this->PrintConfigurePresetList(); std::cout << std::endl; diff --git a/Source/cmCMakePresetsFile.h b/Source/cmCMakePresetsGraph.h index 769fb4e..937b281 100644 --- a/Source/cmCMakePresetsFile.h +++ b/Source/cmCMakePresetsGraph.h @@ -13,7 +13,7 @@ #include <cm/optional> -class cmCMakePresetsFile +class cmCMakePresetsGraph { public: enum class ReadFileResult @@ -363,7 +363,7 @@ public: } static void PrintPresets( - const std::vector<const cmCMakePresetsFile::Preset*>& presets); + const std::vector<const cmCMakePresetsGraph::Preset*>& presets); void PrintConfigurePresetList() const; void PrintConfigurePresetList( const std::function<bool(const ConfigurePreset&)>& filter) const; diff --git a/Source/cmCMakePresetsFileInternal.h b/Source/cmCMakePresetsGraphInternal.h index afb00ce..b2e6791 100644 --- a/Source/cmCMakePresetsFileInternal.h +++ b/Source/cmCMakePresetsGraphInternal.h @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include <memory> -#include "cmCMakePresetsFile.h" +#include "cmCMakePresetsGraph.h" #define CHECK_OK(expr) \ do { \ @@ -11,7 +11,7 @@ return _result; \ } while (false) -namespace cmCMakePresetsFileInternal { +namespace cmCMakePresetsGraphInternal { enum class ExpandMacroResult { Ok, @@ -23,20 +23,20 @@ using MacroExpander = std::function<ExpandMacroResult( const std::string&, const std::string&, std::string&, int version)>; } -class cmCMakePresetsFile::Condition +class cmCMakePresetsGraph::Condition { public: virtual ~Condition() = default; virtual bool Evaluate( - const std::vector<cmCMakePresetsFileInternal::MacroExpander>& expanders, + const std::vector<cmCMakePresetsGraphInternal::MacroExpander>& expanders, int version, cm::optional<bool>& out) const = 0; virtual bool IsNull() const { return false; } }; -namespace cmCMakePresetsFileInternal { +namespace cmCMakePresetsGraphInternal { -class NullCondition : public cmCMakePresetsFile::Condition +class NullCondition : public cmCMakePresetsGraph::Condition { bool Evaluate(const std::vector<MacroExpander>& /*expanders*/, int /*version*/, cm::optional<bool>& out) const override @@ -48,7 +48,7 @@ class NullCondition : public cmCMakePresetsFile::Condition bool IsNull() const override { return true; } }; -class ConstCondition : public cmCMakePresetsFile::Condition +class ConstCondition : public cmCMakePresetsGraph::Condition { public: bool Evaluate(const std::vector<MacroExpander>& /*expanders*/, @@ -61,7 +61,7 @@ public: bool Value; }; -class EqualsCondition : public cmCMakePresetsFile::Condition +class EqualsCondition : public cmCMakePresetsGraph::Condition { public: bool Evaluate(const std::vector<MacroExpander>& expanders, int version, @@ -71,7 +71,7 @@ public: std::string Rhs; }; -class InListCondition : public cmCMakePresetsFile::Condition +class InListCondition : public cmCMakePresetsGraph::Condition { public: bool Evaluate(const std::vector<MacroExpander>& expanders, int version, @@ -81,7 +81,7 @@ public: std::vector<std::string> List; }; -class MatchesCondition : public cmCMakePresetsFile::Condition +class MatchesCondition : public cmCMakePresetsGraph::Condition { public: bool Evaluate(const std::vector<MacroExpander>& expanders, int version, @@ -91,7 +91,7 @@ public: std::string Regex; }; -class AnyAllOfCondition : public cmCMakePresetsFile::Condition +class AnyAllOfCondition : public cmCMakePresetsGraph::Condition { public: bool Evaluate(const std::vector<MacroExpander>& expanders, int version, @@ -101,7 +101,7 @@ public: bool StopValue; }; -class NotCondition : public cmCMakePresetsFile::Condition +class NotCondition : public cmCMakePresetsGraph::Condition { public: bool Evaluate(const std::vector<MacroExpander>& expanders, int version, diff --git a/Source/cmCMakePresetsFileReadJSON.cxx b/Source/cmCMakePresetsGraphReadJSON.cxx index 489551d..8a9e6a0 100644 --- a/Source/cmCMakePresetsFileReadJSON.cxx +++ b/Source/cmCMakePresetsGraphReadJSON.cxx @@ -15,18 +15,18 @@ #include "cmsys/FStream.hxx" -#include "cmCMakePresetsFile.h" -#include "cmCMakePresetsFileInternal.h" +#include "cmCMakePresetsGraph.h" +#include "cmCMakePresetsGraphInternal.h" #include "cmJSONHelpers.h" #include "cmVersion.h" namespace { -using ReadFileResult = cmCMakePresetsFile::ReadFileResult; -using CacheVariable = cmCMakePresetsFile::CacheVariable; -using ConfigurePreset = cmCMakePresetsFile::ConfigurePreset; -using BuildPreset = cmCMakePresetsFile::BuildPreset; -using TestPreset = cmCMakePresetsFile::TestPreset; -using ArchToolsetStrategy = cmCMakePresetsFile::ArchToolsetStrategy; +using ReadFileResult = cmCMakePresetsGraph::ReadFileResult; +using CacheVariable = cmCMakePresetsGraph::CacheVariable; +using ConfigurePreset = cmCMakePresetsGraph::ConfigurePreset; +using BuildPreset = cmCMakePresetsGraph::BuildPreset; +using TestPreset = cmCMakePresetsGraph::TestPreset; +using ArchToolsetStrategy = cmCMakePresetsGraph::ArchToolsetStrategy; constexpr int MIN_VERSION = 1; constexpr int MAX_VERSION = 3; @@ -41,15 +41,15 @@ struct CMakeVersion struct RootPresets { CMakeVersion CMakeMinimumRequired; - std::vector<cmCMakePresetsFile::ConfigurePreset> ConfigurePresets; - std::vector<cmCMakePresetsFile::BuildPreset> BuildPresets; - std::vector<cmCMakePresetsFile::TestPreset> TestPresets; + std::vector<cmCMakePresetsGraph::ConfigurePreset> ConfigurePresets; + std::vector<cmCMakePresetsGraph::BuildPreset> BuildPresets; + std::vector<cmCMakePresetsGraph::TestPreset> TestPresets; }; -std::unique_ptr<cmCMakePresetsFileInternal::NotCondition> InvertCondition( - std::unique_ptr<cmCMakePresetsFile::Condition> condition) +std::unique_ptr<cmCMakePresetsGraphInternal::NotCondition> InvertCondition( + std::unique_ptr<cmCMakePresetsGraph::Condition> condition) { - auto retval = cm::make_unique<cmCMakePresetsFileInternal::NotCondition>(); + auto retval = cm::make_unique<cmCMakePresetsGraphInternal::NotCondition>(); retval->SubCondition = std::move(condition); return retval; } @@ -66,71 +66,72 @@ auto const ConditionStringListHelper = ConditionStringHelper); auto const ConstConditionHelper = - cmJSONObjectHelper<cmCMakePresetsFileInternal::ConstCondition, + cmJSONObjectHelper<cmCMakePresetsGraphInternal::ConstCondition, ReadFileResult>(ReadFileResult::READ_OK, ReadFileResult::INVALID_CONDITION, false) .Bind<std::string>("type"_s, nullptr, ConditionStringHelper, true) - .Bind("value"_s, &cmCMakePresetsFileInternal::ConstCondition::Value, + .Bind("value"_s, &cmCMakePresetsGraphInternal::ConstCondition::Value, ConditionBoolHelper, true); auto const EqualsConditionHelper = - cmJSONObjectHelper<cmCMakePresetsFileInternal::EqualsCondition, + cmJSONObjectHelper<cmCMakePresetsGraphInternal::EqualsCondition, ReadFileResult>(ReadFileResult::READ_OK, ReadFileResult::INVALID_CONDITION, false) .Bind<std::string>("type"_s, nullptr, ConditionStringHelper, true) - .Bind("lhs"_s, &cmCMakePresetsFileInternal::EqualsCondition::Lhs, + .Bind("lhs"_s, &cmCMakePresetsGraphInternal::EqualsCondition::Lhs, ConditionStringHelper, true) - .Bind("rhs"_s, &cmCMakePresetsFileInternal::EqualsCondition::Rhs, + .Bind("rhs"_s, &cmCMakePresetsGraphInternal::EqualsCondition::Rhs, ConditionStringHelper, true); auto const InListConditionHelper = - cmJSONObjectHelper<cmCMakePresetsFileInternal::InListCondition, + cmJSONObjectHelper<cmCMakePresetsGraphInternal::InListCondition, ReadFileResult>(ReadFileResult::READ_OK, ReadFileResult::INVALID_CONDITION, false) .Bind<std::string>("type"_s, nullptr, ConditionStringHelper, true) - .Bind("string"_s, &cmCMakePresetsFileInternal::InListCondition::String, + .Bind("string"_s, &cmCMakePresetsGraphInternal::InListCondition::String, ConditionStringHelper, true) - .Bind("list"_s, &cmCMakePresetsFileInternal::InListCondition::List, + .Bind("list"_s, &cmCMakePresetsGraphInternal::InListCondition::List, ConditionStringListHelper, true); auto const MatchesConditionHelper = - cmJSONObjectHelper<cmCMakePresetsFileInternal::MatchesCondition, + cmJSONObjectHelper<cmCMakePresetsGraphInternal::MatchesCondition, ReadFileResult>(ReadFileResult::READ_OK, ReadFileResult::INVALID_CONDITION, false) .Bind<std::string>("type"_s, nullptr, ConditionStringHelper, true) - .Bind("string"_s, &cmCMakePresetsFileInternal::MatchesCondition::String, + .Bind("string"_s, &cmCMakePresetsGraphInternal::MatchesCondition::String, ConditionStringHelper, true) - .Bind("regex"_s, &cmCMakePresetsFileInternal::MatchesCondition::Regex, + .Bind("regex"_s, &cmCMakePresetsGraphInternal::MatchesCondition::Regex, ConditionStringHelper, true); ReadFileResult SubConditionHelper( - std::unique_ptr<cmCMakePresetsFile::Condition>& out, + std::unique_ptr<cmCMakePresetsGraph::Condition>& out, const Json::Value* value); auto const ListConditionVectorHelper = - cmJSONVectorHelper<std::unique_ptr<cmCMakePresetsFile::Condition>, + cmJSONVectorHelper<std::unique_ptr<cmCMakePresetsGraph::Condition>, ReadFileResult>(ReadFileResult::READ_OK, ReadFileResult::INVALID_CONDITION, SubConditionHelper); auto const AnyAllOfConditionHelper = - cmJSONObjectHelper<cmCMakePresetsFileInternal::AnyAllOfCondition, + cmJSONObjectHelper<cmCMakePresetsGraphInternal::AnyAllOfCondition, ReadFileResult>(ReadFileResult::READ_OK, ReadFileResult::INVALID_CONDITION, false) .Bind<std::string>("type"_s, nullptr, ConditionStringHelper, true) .Bind("conditions"_s, - &cmCMakePresetsFileInternal::AnyAllOfCondition::Conditions, + &cmCMakePresetsGraphInternal::AnyAllOfCondition::Conditions, ListConditionVectorHelper); auto const NotConditionHelper = - cmJSONObjectHelper<cmCMakePresetsFileInternal::NotCondition, ReadFileResult>( - ReadFileResult::READ_OK, ReadFileResult::INVALID_CONDITION, false) + cmJSONObjectHelper<cmCMakePresetsGraphInternal::NotCondition, + ReadFileResult>(ReadFileResult::READ_OK, + ReadFileResult::INVALID_CONDITION, false) .Bind<std::string>("type"_s, nullptr, ConditionStringHelper, true) .Bind("condition"_s, - &cmCMakePresetsFileInternal::NotCondition::SubCondition, + &cmCMakePresetsGraphInternal::NotCondition::SubCondition, SubConditionHelper); ReadFileResult ConditionHelper( - std::unique_ptr<cmCMakePresetsFile::Condition>& out, + std::unique_ptr<cmCMakePresetsGraph::Condition>& out, const Json::Value* value) { if (!value) { @@ -139,14 +140,14 @@ ReadFileResult ConditionHelper( } if (value->isBool()) { - auto c = cm::make_unique<cmCMakePresetsFileInternal::ConstCondition>(); + auto c = cm::make_unique<cmCMakePresetsGraphInternal::ConstCondition>(); c->Value = value->asBool(); out = std::move(c); return ReadFileResult::READ_OK; } if (value->isNull()) { - out = cm::make_unique<cmCMakePresetsFileInternal::NullCondition>(); + out = cm::make_unique<cmCMakePresetsGraphInternal::NullCondition>(); return ReadFileResult::READ_OK; } @@ -161,14 +162,14 @@ ReadFileResult ConditionHelper( auto type = (*value)["type"].asString(); if (type == "const") { - auto c = cm::make_unique<cmCMakePresetsFileInternal::ConstCondition>(); + auto c = cm::make_unique<cmCMakePresetsGraphInternal::ConstCondition>(); CHECK_OK(ConstConditionHelper(*c, value)); out = std::move(c); return ReadFileResult::READ_OK; } if (type == "equals" || type == "notEquals") { - auto c = cm::make_unique<cmCMakePresetsFileInternal::EqualsCondition>(); + auto c = cm::make_unique<cmCMakePresetsGraphInternal::EqualsCondition>(); CHECK_OK(EqualsConditionHelper(*c, value)); out = std::move(c); if (type == "notEquals") { @@ -178,7 +179,7 @@ ReadFileResult ConditionHelper( } if (type == "inList" || type == "notInList") { - auto c = cm::make_unique<cmCMakePresetsFileInternal::InListCondition>(); + auto c = cm::make_unique<cmCMakePresetsGraphInternal::InListCondition>(); CHECK_OK(InListConditionHelper(*c, value)); out = std::move(c); if (type == "notInList") { @@ -188,7 +189,8 @@ ReadFileResult ConditionHelper( } if (type == "matches" || type == "notMatches") { - auto c = cm::make_unique<cmCMakePresetsFileInternal::MatchesCondition>(); + auto c = + cm::make_unique<cmCMakePresetsGraphInternal::MatchesCondition>(); CHECK_OK(MatchesConditionHelper(*c, value)); out = std::move(c); if (type == "notMatches") { @@ -199,7 +201,7 @@ ReadFileResult ConditionHelper( if (type == "anyOf" || type == "allOf") { auto c = - cm::make_unique<cmCMakePresetsFileInternal::AnyAllOfCondition>(); + cm::make_unique<cmCMakePresetsGraphInternal::AnyAllOfCondition>(); c->StopValue = (type == "anyOf"); CHECK_OK(AnyAllOfConditionHelper(*c, value)); out = std::move(c); @@ -207,7 +209,7 @@ ReadFileResult ConditionHelper( } if (type == "not") { - auto c = cm::make_unique<cmCMakePresetsFileInternal::NotCondition>(); + auto c = cm::make_unique<cmCMakePresetsGraphInternal::NotCondition>(); CHECK_OK(NotConditionHelper(*c, value)); out = std::move(c); return ReadFileResult::READ_OK; @@ -218,20 +220,20 @@ ReadFileResult ConditionHelper( } ReadFileResult PresetConditionHelper( - std::shared_ptr<cmCMakePresetsFile::Condition>& out, + std::shared_ptr<cmCMakePresetsGraph::Condition>& out, const Json::Value* value) { - std::unique_ptr<cmCMakePresetsFile::Condition> ptr; + std::unique_ptr<cmCMakePresetsGraph::Condition> ptr; auto result = ConditionHelper(ptr, value); out = std::move(ptr); return result; } ReadFileResult SubConditionHelper( - std::unique_ptr<cmCMakePresetsFile::Condition>& out, + std::unique_ptr<cmCMakePresetsGraph::Condition>& out, const Json::Value* value) { - std::unique_ptr<cmCMakePresetsFile::Condition> ptr; + std::unique_ptr<cmCMakePresetsGraph::Condition> ptr; auto result = ConditionHelper(ptr, value); if (ptr && ptr->IsNull()) { return ReadFileResult::INVALID_CONDITION; @@ -898,7 +900,7 @@ auto const RootPresetsHelper = VendorHelper(ReadFileResult::INVALID_ROOT), false); } -cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadJSONFile( +cmCMakePresetsGraph::ReadFileResult cmCMakePresetsGraph::ReadJSONFile( const std::string& filename, bool user) { cmsys::ifstream fin(filename.c_str()); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 647dd87..a1e920e 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -38,7 +38,7 @@ # include <unistd.h> // IWYU pragma: keep #endif -#include "cmCMakePresetsFile.h" +#include "cmCMakePresetsGraph.h" #include "cmCTestBuildAndTestHandler.h" #include "cmCTestBuildHandler.h" #include "cmCTestConfigureHandler.h" @@ -2327,12 +2327,12 @@ bool cmCTest::SetArgsFromPreset(const std::string& presetName, { const auto workingDirectory = cmSystemTools::GetCurrentWorkingDirectory(); - cmCMakePresetsFile settingsFile; + cmCMakePresetsGraph settingsFile; auto result = settingsFile.ReadProjectPresets(workingDirectory); - if (result != cmCMakePresetsFile::ReadFileResult::READ_OK) { - cmSystemTools::Error(cmStrCat("Could not read presets from ", - workingDirectory, ": ", - cmCMakePresetsFile::ResultToString(result))); + if (result != cmCMakePresetsGraph::ReadFileResult::READ_OK) { + cmSystemTools::Error( + cmStrCat("Could not read presets from ", workingDirectory, ": ", + cmCMakePresetsGraph::ResultToString(result))); return false; } @@ -2422,15 +2422,15 @@ bool cmCTest::SetArgsFromPreset(const std::string& presetName, if (expandedPreset->Output->Verbosity) { const auto& verbosity = *expandedPreset->Output->Verbosity; switch (verbosity) { - case cmCMakePresetsFile::TestPreset::OutputOptions::VerbosityEnum:: + case cmCMakePresetsGraph::TestPreset::OutputOptions::VerbosityEnum:: Extra: this->Impl->ExtraVerbose = true; CM_FALLTHROUGH; - case cmCMakePresetsFile::TestPreset::OutputOptions::VerbosityEnum:: + case cmCMakePresetsGraph::TestPreset::OutputOptions::VerbosityEnum:: Verbose: this->Impl->Verbose = true; break; - case cmCMakePresetsFile::TestPreset::OutputOptions::VerbosityEnum:: + case cmCMakePresetsGraph::TestPreset::OutputOptions::VerbosityEnum:: Default: default: // leave default settings @@ -2548,13 +2548,13 @@ bool cmCTest::SetArgsFromPreset(const std::string& presetName, this->Impl->ShowOnly = true; switch (*expandedPreset->Execution->ShowOnly) { - case cmCMakePresetsFile::TestPreset::ExecutionOptions::ShowOnlyEnum:: + case cmCMakePresetsGraph::TestPreset::ExecutionOptions::ShowOnlyEnum:: JsonV1: this->Impl->Quiet = true; this->Impl->OutputAsJson = true; this->Impl->OutputAsJsonVersion = 1; break; - case cmCMakePresetsFile::TestPreset::ExecutionOptions::ShowOnlyEnum:: + case cmCMakePresetsGraph::TestPreset::ExecutionOptions::ShowOnlyEnum:: Human: // intentional fallthrough (human is the default) default: @@ -2565,15 +2565,15 @@ bool cmCTest::SetArgsFromPreset(const std::string& presetName, if (expandedPreset->Execution->Repeat) { this->Impl->RepeatCount = expandedPreset->Execution->Repeat->Count; switch (expandedPreset->Execution->Repeat->Mode) { - case cmCMakePresetsFile::TestPreset::ExecutionOptions::RepeatOptions:: + case cmCMakePresetsGraph::TestPreset::ExecutionOptions::RepeatOptions:: ModeEnum::UntilFail: this->Impl->RepeatMode = cmCTest::Repeat::UntilFail; break; - case cmCMakePresetsFile::TestPreset::ExecutionOptions::RepeatOptions:: + case cmCMakePresetsGraph::TestPreset::ExecutionOptions::RepeatOptions:: ModeEnum::UntilPass: this->Impl->RepeatMode = cmCTest::Repeat::UntilPass; break; - case cmCMakePresetsFile::TestPreset::ExecutionOptions::RepeatOptions:: + case cmCMakePresetsGraph::TestPreset::ExecutionOptions::RepeatOptions:: ModeEnum::AfterTimeout: this->Impl->RepeatMode = cmCTest::Repeat::AfterTimeout; break; @@ -2599,15 +2599,15 @@ bool cmCTest::SetArgsFromPreset(const std::string& presetName, if (expandedPreset->Execution->NoTestsAction) { switch (*expandedPreset->Execution->NoTestsAction) { - case cmCMakePresetsFile::TestPreset::ExecutionOptions:: + case cmCMakePresetsGraph::TestPreset::ExecutionOptions:: NoTestsActionEnum::Error: this->Impl->NoTestsMode = cmCTest::NoTests::Error; break; - case cmCMakePresetsFile::TestPreset::ExecutionOptions:: + case cmCMakePresetsGraph::TestPreset::ExecutionOptions:: NoTestsActionEnum::Ignore: this->Impl->NoTestsMode = cmCTest::NoTests::Ignore; break; - case cmCMakePresetsFile::TestPreset::ExecutionOptions:: + case cmCMakePresetsGraph::TestPreset::ExecutionOptions:: NoTestsActionEnum::Default: break; default: diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2a3ef9b..c708eb2 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -29,7 +29,7 @@ #include "cm_sys_stat.h" #include "cmCMakePath.h" -#include "cmCMakePresetsFile.h" +#include "cmCMakePresetsGraph.h" #include "cmCommandLineArgument.h" #include "cmCommands.h" #include "cmDocumentation.h" @@ -1239,43 +1239,43 @@ void cmake::SetArgs(const std::vector<std::string>& args) #if !defined(CMAKE_BOOTSTRAP) if (listPresets != ListPresets::None || !presetName.empty()) { - cmCMakePresetsFile settingsFile; - auto result = settingsFile.ReadProjectPresets(this->GetHomeDirectory()); - if (result != cmCMakePresetsFile::ReadFileResult::READ_OK) { + cmCMakePresetsGraph presetsGraph; + auto result = presetsGraph.ReadProjectPresets(this->GetHomeDirectory()); + if (result != cmCMakePresetsGraph::ReadFileResult::READ_OK) { cmSystemTools::Error( cmStrCat("Could not read presets from ", this->GetHomeDirectory(), - ": ", cmCMakePresetsFile::ResultToString(result))); + ": ", cmCMakePresetsGraph::ResultToString(result))); return; } if (listPresets != ListPresets::None) { if (listPresets == ListPresets::Configure) { - this->PrintPresetList(settingsFile); + this->PrintPresetList(presetsGraph); } else if (listPresets == ListPresets::Build) { - settingsFile.PrintBuildPresetList(); + presetsGraph.PrintBuildPresetList(); } else if (listPresets == ListPresets::Test) { - settingsFile.PrintTestPresetList(); + presetsGraph.PrintTestPresetList(); } else if (listPresets == ListPresets::All) { - settingsFile.PrintAllPresets(); + presetsGraph.PrintAllPresets(); } this->SetWorkingMode(WorkingMode::HELP_MODE); return; } - auto preset = settingsFile.ConfigurePresets.find(presetName); - if (preset == settingsFile.ConfigurePresets.end()) { + auto preset = presetsGraph.ConfigurePresets.find(presetName); + if (preset == presetsGraph.ConfigurePresets.end()) { cmSystemTools::Error(cmStrCat("No such preset in ", this->GetHomeDirectory(), ": \"", presetName, '"')); - this->PrintPresetList(settingsFile); + this->PrintPresetList(presetsGraph); return; } if (preset->second.Unexpanded.Hidden) { cmSystemTools::Error(cmStrCat("Cannot use hidden preset in ", this->GetHomeDirectory(), ": \"", presetName, '"')); - this->PrintPresetList(settingsFile); + this->PrintPresetList(presetsGraph); return; } auto const& expandedPreset = preset->second.Expanded; @@ -1319,14 +1319,14 @@ void cmake::SetArgs(const std::vector<std::string>& args) if (!expandedPreset->ArchitectureStrategy || expandedPreset->ArchitectureStrategy == - cmCMakePresetsFile::ArchToolsetStrategy::Set) { + cmCMakePresetsGraph::ArchToolsetStrategy::Set) { if (!this->GeneratorPlatformSet) { this->SetGeneratorPlatform(expandedPreset->Architecture); } } if (!expandedPreset->ToolsetStrategy || expandedPreset->ToolsetStrategy == - cmCMakePresetsFile::ArchToolsetStrategy::Set) { + cmCMakePresetsGraph::ArchToolsetStrategy::Set) { if (!this->GeneratorToolsetSet) { this->SetGeneratorToolset(expandedPreset->Toolset); } @@ -1707,12 +1707,12 @@ bool cmake::CreateAndSetGlobalGenerator(const std::string& name, } #ifndef CMAKE_BOOTSTRAP -void cmake::PrintPresetList(const cmCMakePresetsFile& file) const +void cmake::PrintPresetList(const cmCMakePresetsGraph& graph) const { std::vector<GeneratorInfo> generators; this->GetRegisteredGenerators(generators, false); auto filter = - [&generators](const cmCMakePresetsFile::ConfigurePreset& preset) -> bool { + [&generators](const cmCMakePresetsGraph::ConfigurePreset& preset) -> bool { if (preset.Generator.empty()) { return true; } @@ -1723,7 +1723,7 @@ void cmake::PrintPresetList(const cmCMakePresetsFile& file) const return it != generators.end(); }; - file.PrintConfigurePresetList(filter); + graph.PrintConfigurePresetList(filter); } #endif @@ -3230,12 +3230,12 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets, this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); - cmCMakePresetsFile settingsFile; + cmCMakePresetsGraph settingsFile; auto result = settingsFile.ReadProjectPresets(this->GetHomeDirectory()); - if (result != cmCMakePresetsFile::ReadFileResult::READ_OK) { + if (result != cmCMakePresetsGraph::ReadFileResult::READ_OK) { cmSystemTools::Error( cmStrCat("Could not read presets from ", this->GetHomeDirectory(), - ": ", cmCMakePresetsFile::ResultToString(result))); + ": ", cmCMakePresetsGraph::ResultToString(result))); return 1; } diff --git a/Source/cmake.h b/Source/cmake.h index a356e65..b13cc96 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -31,7 +31,7 @@ # include <cm3p/json/value.h> -# include "cmCMakePresetsFile.h" +# include "cmCMakePresetsGraph.h" #endif class cmExternalMakefileProjectGeneratorFactory; @@ -248,7 +248,7 @@ public: #ifndef CMAKE_BOOTSTRAP //! Print list of configure presets - void PrintPresetList(const cmCMakePresetsFile& file) const; + void PrintPresetList(const cmCMakePresetsGraph& graph) const; #endif //! Return the global generator assigned to this instance of cmake @@ -691,7 +691,7 @@ private: std::string GraphVizFile; InstalledFilesMap InstalledFiles; #ifndef CMAKE_BOOTSTRAP - std::map<std::string, cm::optional<cmCMakePresetsFile::CacheVariable>> + std::map<std::string, cm::optional<cmCMakePresetsGraph::CacheVariable>> UnprocessedPresetVariables; std::map<std::string, cm::optional<std::string>> UnprocessedPresetEnvironment; |