summaryrefslogtreecommitdiffstats
path: root/Source/cmCMakePresetsGraphReadJSON.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2022-09-08 22:24:28 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2022-09-26 14:53:28 (GMT)
commite3168128841485a0a579ad3b9125fdae5e12eec8 (patch)
tree4753c54dc85043daaecd4839871a6c59bae96c0d /Source/cmCMakePresetsGraphReadJSON.cxx
parenteb6e2ef7f61de1dd4ff6ec39e886d5fa8cf9aea7 (diff)
downloadCMake-e3168128841485a0a579ad3b9125fdae5e12eec8.zip
CMake-e3168128841485a0a579ad3b9125fdae5e12eec8.tar.gz
CMake-e3168128841485a0a579ad3b9125fdae5e12eec8.tar.bz2
CMakePresets.json: Add workflow presets to schema
Diffstat (limited to 'Source/cmCMakePresetsGraphReadJSON.cxx')
-rw-r--r--Source/cmCMakePresetsGraphReadJSON.cxx37
1 files changed, 33 insertions, 4 deletions
diff --git a/Source/cmCMakePresetsGraphReadJSON.cxx b/Source/cmCMakePresetsGraphReadJSON.cxx
index 4fba7d9..5aa4284 100644
--- a/Source/cmCMakePresetsGraphReadJSON.cxx
+++ b/Source/cmCMakePresetsGraphReadJSON.cxx
@@ -30,6 +30,8 @@ using CacheVariable = cmCMakePresetsGraph::CacheVariable;
using ConfigurePreset = cmCMakePresetsGraph::ConfigurePreset;
using BuildPreset = cmCMakePresetsGraph::BuildPreset;
using TestPreset = cmCMakePresetsGraph::TestPreset;
+using PackagePreset = cmCMakePresetsGraph::PackagePreset;
+using WorkflowPreset = cmCMakePresetsGraph::WorkflowPreset;
using ArchToolsetStrategy = cmCMakePresetsGraph::ArchToolsetStrategy;
using JSONHelperBuilder = cmJSONHelperBuilder<ReadFileResult>;
@@ -46,10 +48,11 @@ struct CMakeVersion
struct RootPresets
{
CMakeVersion CMakeMinimumRequired;
- std::vector<cmCMakePresetsGraph::ConfigurePreset> ConfigurePresets;
- std::vector<cmCMakePresetsGraph::BuildPreset> BuildPresets;
- std::vector<cmCMakePresetsGraph::TestPreset> TestPresets;
- std::vector<cmCMakePresetsGraph::PackagePreset> PackagePresets;
+ std::vector<ConfigurePreset> ConfigurePresets;
+ std::vector<BuildPreset> BuildPresets;
+ std::vector<TestPreset> TestPresets;
+ std::vector<PackagePreset> PackagePresets;
+ std::vector<WorkflowPreset> WorkflowPresets;
std::vector<std::string> Include;
};
@@ -284,6 +287,8 @@ auto const RootPresetsHelper =
cmCMakePresetsGraphInternal::TestPresetsHelper, false)
.Bind("packagePresets"_s, &RootPresets::PackagePresets,
cmCMakePresetsGraphInternal::PackagePresetsHelper, false)
+ .Bind("workflowPresets"_s, &RootPresets::WorkflowPresets,
+ cmCMakePresetsGraphInternal::WorkflowPresetsHelper, false)
.Bind("cmakeMinimumRequired"_s, &RootPresets::CMakeMinimumRequired,
CMakeVersionHelper, false)
.Bind("include"_s, &RootPresets::Include, IncludeVectorHelper, false)
@@ -466,6 +471,11 @@ cmCMakePresetsGraph::ReadFileResult cmCMakePresetsGraph::ReadJSONFile(
return ReadFileResult::PACKAGE_PRESETS_UNSUPPORTED;
}
+ // Support for workflow presets added in version 6.
+ if (v < 6 && root.isMember("workflowPresets")) {
+ return ReadFileResult::WORKFLOW_PRESETS_UNSUPPORTED;
+ }
+
// Support for include added in version 4.
if (v < 4 && root.isMember("include")) {
return ReadFileResult::INCLUDE_UNSUPPORTED;
@@ -600,6 +610,25 @@ cmCMakePresetsGraph::ReadFileResult cmCMakePresetsGraph::ReadJSONFile(
this->PackagePresetOrder.push_back(preset.Name);
}
+ for (auto& preset : presets.WorkflowPresets) {
+ preset.OriginFile = file;
+ if (preset.Name.empty()) {
+ return ReadFileResult::INVALID_PRESET;
+ }
+
+ PresetPair<WorkflowPreset> presetPair;
+ presetPair.Unexpanded = preset;
+ presetPair.Expanded = cm::nullopt;
+ if (!this->WorkflowPresets.emplace(preset.Name, presetPair).second) {
+ return ReadFileResult::DUPLICATE_PRESETS;
+ }
+
+ // Support for conditions added in version 3, but this requires version 6
+ // already, so no action needed.
+
+ this->WorkflowPresetOrder.push_back(preset.Name);
+ }
+
auto const includeFile = [this, &inProgressFiles, file](
const std::string& include, RootType rootType2,
ReadReason readReason2,