summaryrefslogtreecommitdiffstats
path: root/Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx
diff options
context:
space:
mode:
authorArtin Alavi <1361714+Arastais@users.noreply.github.com>2023-02-07 07:30:21 (GMT)
committerBrad King <brad.king@kitware.com>2023-03-30 13:18:53 (GMT)
commit8e579b0228ae410aa83a4c45f1fbb790c4a6cf12 (patch)
tree8ce47bf63d0ff0a515b10593c5e3cdf75df9260e /Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx
parent4901fdb201bc6264e976e105780a490d9c0eba19 (diff)
downloadCMake-8e579b0228ae410aa83a4c45f1fbb790c4a6cf12.zip
CMake-8e579b0228ae410aa83a4c45f1fbb790c4a6cf12.tar.gz
CMake-8e579b0228ae410aa83a4c45f1fbb790c4a6cf12.tar.bz2
presets: Add trace options to configure presets
Add JSON schema version 7 to support them. Fixes: #22543
Diffstat (limited to 'Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx')
-rw-r--r--Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx68
1 files changed, 68 insertions, 0 deletions
diff --git a/Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx b/Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx
index a1774be..66ec6a4 100644
--- a/Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx
+++ b/Source/cmCMakePresetsGraphReadJSONConfigurePresets.cxx
@@ -17,12 +17,15 @@
#include "cmCMakePresetsGraphInternal.h"
#include "cmJSONHelpers.h"
#include "cmJSONState.h"
+#include "cmStateTypes.h"
namespace {
using CacheVariable = cmCMakePresetsGraph::CacheVariable;
using ConfigurePreset = cmCMakePresetsGraph::ConfigurePreset;
using ArchToolsetStrategy = cmCMakePresetsGraph::ArchToolsetStrategy;
using JSONHelperBuilder = cmJSONHelperBuilder;
+using TraceEnableMode = cmCMakePresetsGraph::TraceEnableMode;
+using TraceOutputFormat = cmTraceEnums::TraceOutputFormat;
bool ArchToolsetStrategyHelper(cm::optional<ArchToolsetStrategy>& out,
const Json::Value* value, cmJSONState* state)
@@ -91,6 +94,58 @@ auto const ArchitectureHelper = ArchToolsetHelper(
auto const ToolsetHelper = ArchToolsetHelper(
&ConfigurePreset::Toolset, &ConfigurePreset::ToolsetStrategy);
+bool TraceEnableModeHelper(cm::optional<TraceEnableMode>& out,
+ const Json::Value* value, cmJSONState* state)
+{
+ if (!value) {
+ out = cm::nullopt;
+ return true;
+ }
+
+ if (!value->isString()) {
+ cmCMakePresetErrors::INVALID_PRESET(value, state);
+ return false;
+ }
+
+ if (value->asString() == "on") {
+ out = TraceEnableMode::Default;
+ } else if (value->asString() == "off") {
+ out = TraceEnableMode::Disable;
+ } else if (value->asString() == "expand") {
+ out = TraceEnableMode::Expand;
+ } else {
+ cmCMakePresetErrors::INVALID_PRESET(value, state);
+ return false;
+ }
+
+ return true;
+}
+
+bool TraceOutputFormatHelper(cm::optional<TraceOutputFormat>& out,
+ const Json::Value* value, cmJSONState* state)
+{
+ if (!value) {
+ out = cm::nullopt;
+ return true;
+ }
+
+ if (!value->isString()) {
+ cmCMakePresetErrors::INVALID_PRESET(value, state);
+ return false;
+ }
+
+ if (value->asString() == "human") {
+ out = TraceOutputFormat::Human;
+ } else if (value->asString() == "json-v1") {
+ out = TraceOutputFormat::JSONv1;
+ } else {
+ cmCMakePresetErrors::INVALID_PRESET(value, state);
+ return false;
+ }
+
+ return true;
+}
+
auto const VariableStringHelper = JSONHelperBuilder::String();
bool VariableValueHelper(std::string& out, const Json::Value* value,
@@ -180,6 +235,18 @@ auto const PresetDebugHelper =
.Bind("find"_s, &ConfigurePreset::DebugFind,
cmCMakePresetsGraphInternal::PresetOptionalBoolHelper, false);
+auto const PresetTraceHelper =
+ JSONHelperBuilder::Object<ConfigurePreset>(
+ cmCMakePresetErrors::INVALID_PRESET_OBJECT, false)
+ .Bind("mode"_s, &ConfigurePreset::TraceMode, TraceEnableModeHelper, false)
+ .Bind("format"_s, &ConfigurePreset::TraceFormat, TraceOutputFormatHelper,
+ false)
+ .Bind("source"_s, &ConfigurePreset::TraceSource,
+ cmCMakePresetsGraphInternal::PresetVectorOneOrMoreStringHelper,
+ false)
+ .Bind("redirect"_s, &ConfigurePreset::TraceRedirect,
+ cmCMakePresetsGraphInternal::PresetStringHelper, false);
+
auto const ConfigurePresetHelper =
JSONHelperBuilder::Object<ConfigurePreset>(
cmCMakePresetErrors::INVALID_PRESET_OBJECT, false)
@@ -217,6 +284,7 @@ auto const ConfigurePresetHelper =
.Bind("warnings"_s, PresetWarningsHelper, false)
.Bind("errors"_s, PresetErrorsHelper, false)
.Bind("debug"_s, PresetDebugHelper, false)
+ .Bind("trace"_s, PresetTraceHelper, false)
.Bind("condition"_s, &ConfigurePreset::ConditionEvaluator,
cmCMakePresetsGraphInternal::PresetConditionHelper, false);
}