mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 13:51:33 -06:00
presets: Add trace options to configure presets
Add JSON schema version 7 to support them. Fixes: #22543
This commit is contained in:
@@ -63,6 +63,9 @@ The root object recognizes the following fields:
|
||||
``6``
|
||||
.. versionadded:: 3.25
|
||||
|
||||
``7``
|
||||
.. versionadded:: 3.27
|
||||
|
||||
``cmakeMinimumRequired``
|
||||
An optional object representing the minimum version of CMake needed to
|
||||
build this project. This object consists of the following fields:
|
||||
@@ -359,6 +362,52 @@ that may contain the following fields:
|
||||
An optional boolean. Setting this to ``true`` is equivalent to passing
|
||||
:option:`--debug-find <cmake --debug-find>` on the command line.
|
||||
|
||||
``trace``
|
||||
An optional object specifying trace options. This is allowed in preset
|
||||
files specifying version ``7``. The object may contain the following fields:
|
||||
|
||||
``mode``
|
||||
An optional string that specifies the trace mode. Valid values are:
|
||||
|
||||
``on``
|
||||
Causes a trace of all calls made and from where to be printed.
|
||||
Equivalent to passing :option:`--trace <cmake --trace>` on the command
|
||||
line.
|
||||
|
||||
``off``
|
||||
A trace of all calls will not be printed.
|
||||
|
||||
``expand``
|
||||
Causes a trace with variables expanded of all calls made and from where
|
||||
to be printed. Equivalent to passing :option:`--trace-expand <cmake --trace-expand>`
|
||||
on the command line.
|
||||
|
||||
``format``
|
||||
An optional string that specifies the format output of the trace.
|
||||
Valid values are:
|
||||
|
||||
``human``
|
||||
Prints each trace line in a human-readable format.
|
||||
This is the default format. Equivalent to passing
|
||||
:option:`--trace-format=human <cmake --trace-format>`
|
||||
on the command line.
|
||||
|
||||
``json-v1``
|
||||
Prints each line as a separate JSON document. Equivalent to passing
|
||||
:option:`--trace-format=json-v1 <cmake --trace-format>`
|
||||
on the command line.
|
||||
|
||||
``source``
|
||||
An optional array of strings representing the paths of source files to
|
||||
be traced. This field can also be a string, which is equivalent to an
|
||||
array containing one string. Equivalent to passing
|
||||
:option:`--trace-source <cmake --trace-source>` on the command line.
|
||||
|
||||
``redirect``
|
||||
An optional string specifying a path to a trace output file. Equivalent
|
||||
to passing :option:`--trace-redirect <cmake --trace-redirect>`
|
||||
on the command line.
|
||||
|
||||
Build Preset
|
||||
^^^^^^^^^^^^
|
||||
|
||||
|
||||
@@ -89,6 +89,23 @@
|
||||
"include": { "$ref": "#/definitions/include"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"version": {
|
||||
"const": 7,
|
||||
"description": "A required integer representing the version of the JSON schema."
|
||||
},
|
||||
"cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"},
|
||||
"vendor": { "$ref": "#/definitions/vendor" },
|
||||
"configurePresets": { "$ref": "#/definitions/configurePresetsV7"},
|
||||
"buildPresets": { "$ref": "#/definitions/buildPresetsV4"},
|
||||
"testPresets": { "$ref": "#/definitions/testPresetsV6"},
|
||||
"packagePresets": { "$ref": "#/definitions/packagePresetsV6"},
|
||||
"workflowPresets": { "$ref": "#/definitions/workflowPresetsV6" },
|
||||
"include": { "$ref": "#/definitions/include"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
],
|
||||
"required": [
|
||||
@@ -119,6 +136,59 @@
|
||||
"description": "An optional map containing vendor-specific information. CMake does not interpret the contents of this field except to verify that it is a map if it does exist. However, the keys should be a vendor-specific domain name followed by a /-separated path. For example, the Example IDE 1.0 could use example.com/ExampleIDE/1.0. The value of each field can be anything desired by the vendor, though will typically be a map.",
|
||||
"properties": {}
|
||||
},
|
||||
"configurePresetsItemsV7": {
|
||||
"type": "array",
|
||||
"description": "A configure preset object.",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"description": "A configure preset object.",
|
||||
"properties": {
|
||||
"trace": {
|
||||
"type": "object",
|
||||
"description": "An optional object specifying trace options.",
|
||||
"properties": {
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"description": "An optional string that specifies the trace mode.",
|
||||
"enum": [
|
||||
"on", "off", "expand"
|
||||
]
|
||||
},
|
||||
"format": {
|
||||
"type": "string",
|
||||
"description": "An optional string that specifies the trace output format.",
|
||||
"enum": [
|
||||
"human", "json-v1"
|
||||
]
|
||||
},
|
||||
"source": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "An optional string representing the path to one source file to be traced.",
|
||||
"minLength": 1
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"description": "An optional array of strings representing the paths to source files to be traced.",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"description": "A string representing the path to one source file to be traced.",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"redirect": {
|
||||
"type": "string",
|
||||
"description": "An optional string specifying a path to a trace output file."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"configurePresetsItemsV3": {
|
||||
"type": "array",
|
||||
"description": "A configure preset object.",
|
||||
@@ -393,6 +463,43 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"configurePresetsV7": {
|
||||
"type": "array",
|
||||
"description": "An optional array of configure preset objects.",
|
||||
"allOf": [
|
||||
{ "$ref": "#/definitions/configurePresetsItemsV1" },
|
||||
{ "$ref": "#/definitions/configurePresetsItemsV3" },
|
||||
{ "$ref": "#/definitions/configurePresetsItemsV7" }
|
||||
],
|
||||
"items": {
|
||||
"properties": {
|
||||
"name": {},
|
||||
"hidden": {},
|
||||
"inherits": {},
|
||||
"vendor": {},
|
||||
"displayName": {},
|
||||
"description": {},
|
||||
"generator": {},
|
||||
"architecture": {},
|
||||
"toolset": {},
|
||||
"toolchainFile": {},
|
||||
"binaryDir": {},
|
||||
"installDir": {},
|
||||
"cmakeExecutable": {},
|
||||
"cacheVariables": {},
|
||||
"environment": {},
|
||||
"warnings": {},
|
||||
"errors": {},
|
||||
"debug": {},
|
||||
"condition": {},
|
||||
"trace": {}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"configurePresetsV3": {
|
||||
"type": "array",
|
||||
"description": "An optional array of configure preset objects.",
|
||||
|
||||
@@ -176,6 +176,9 @@ const auto CTEST_JUNIT_UNSUPPORTED = [](cmJSONState* state) -> void {
|
||||
state->AddError(
|
||||
"File version must be 6 or higher for CTest JUnit output support");
|
||||
};
|
||||
const auto TRACE_UNSUPPORTED = [](cmJSONState* state) -> void {
|
||||
state->AddError("File version must be 7 or higher for trace preset support");
|
||||
};
|
||||
const auto UNRECOGNIZED_CMAKE_VERSION = [](const std::string& version,
|
||||
int current, int required) {
|
||||
return [version, current, required](const Json::Value* value,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <cm/optional>
|
||||
|
||||
#include "cmJSONState.h"
|
||||
#include "cmStateTypes.h"
|
||||
|
||||
#include "CTest/cmCTestTypes.h"
|
||||
|
||||
@@ -32,6 +33,13 @@ public:
|
||||
External,
|
||||
};
|
||||
|
||||
enum class TraceEnableMode
|
||||
{
|
||||
Disable,
|
||||
Default,
|
||||
Expand,
|
||||
};
|
||||
|
||||
class CacheVariable
|
||||
{
|
||||
public:
|
||||
@@ -129,6 +137,11 @@ public:
|
||||
cm::optional<bool> DebugTryCompile;
|
||||
cm::optional<bool> DebugFind;
|
||||
|
||||
cm::optional<TraceEnableMode> TraceMode;
|
||||
cm::optional<cmTraceEnums::TraceOutputFormat> TraceFormat;
|
||||
std::vector<std::string> TraceSource;
|
||||
std::string TraceRedirect;
|
||||
|
||||
bool VisitPresetInherit(const Preset& parent) override;
|
||||
bool VisitPresetBeforeInherit() override;
|
||||
bool VisitPresetAfterInherit(int version, cmJSONState* state) override;
|
||||
|
||||
@@ -35,7 +35,7 @@ using ArchToolsetStrategy = cmCMakePresetsGraph::ArchToolsetStrategy;
|
||||
using JSONHelperBuilder = cmJSONHelperBuilder;
|
||||
|
||||
constexpr int MIN_VERSION = 1;
|
||||
constexpr int MAX_VERSION = 6;
|
||||
constexpr int MAX_VERSION = 7;
|
||||
|
||||
struct CMakeVersion
|
||||
{
|
||||
@@ -557,6 +557,14 @@ bool cmCMakePresetsGraph::ReadJSONFile(const std::string& filename,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Support for trace presets added in version 7.
|
||||
if (v < 7 &&
|
||||
(preset.TraceMode.has_value() || preset.TraceFormat.has_value() ||
|
||||
!preset.TraceRedirect.empty() || !preset.TraceSource.empty())) {
|
||||
cmCMakePresetErrors::TRACE_UNSUPPORTED(&this->parseState);
|
||||
return false;
|
||||
}
|
||||
|
||||
this->ConfigurePresetOrder.push_back(preset.Name);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ void cmMakefile::PrintCommandTrace(cmListFileFunction const& lff,
|
||||
cm::optional<std::string> const& deferId = bt.Top().DeferId;
|
||||
|
||||
switch (this->GetCMakeInstance()->GetTraceFormat()) {
|
||||
case cmake::TraceFormat::TRACE_JSON_V1: {
|
||||
case cmake::TraceFormat::JSONv1: {
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
Json::Value val;
|
||||
Json::StreamWriterBuilder builder;
|
||||
@@ -367,7 +367,7 @@ void cmMakefile::PrintCommandTrace(cmListFileFunction const& lff,
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case cmake::TraceFormat::TRACE_HUMAN:
|
||||
case cmake::TraceFormat::Human:
|
||||
msg << full_path << "(" << lff.Line() << "):";
|
||||
if (deferId) {
|
||||
msg << "DEFERRED:" << *deferId << ":";
|
||||
@@ -379,8 +379,8 @@ void cmMakefile::PrintCommandTrace(cmListFileFunction const& lff,
|
||||
}
|
||||
msg << ")";
|
||||
break;
|
||||
case cmake::TraceFormat::TRACE_UNDEFINED:
|
||||
msg << "INTERNAL ERROR: Trace format is TRACE_UNDEFINED";
|
||||
case cmake::TraceFormat::Undefined:
|
||||
msg << "INTERNAL ERROR: Trace format is Undefined";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,3 +60,14 @@ enum ArtifactType
|
||||
ImportLibraryArtifact
|
||||
};
|
||||
}
|
||||
|
||||
namespace cmTraceEnums {
|
||||
|
||||
/** \brief Define supported trace formats **/
|
||||
enum class TraceOutputFormat
|
||||
{
|
||||
Undefined,
|
||||
Human,
|
||||
JSONv1
|
||||
};
|
||||
};
|
||||
|
||||
104
Source/cmake.cxx
104
Source/cmake.cxx
@@ -1143,49 +1143,64 @@ void cmake::SetArgs(const std::vector<std::string>& args)
|
||||
std::cout << ".\n";
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{ "--trace", CommandArgument::Values::Zero,
|
||||
[](std::string const&, cmake* state) -> bool {
|
||||
std::cout << "Put cmake in trace mode.\n";
|
||||
state->SetTrace(true);
|
||||
state->SetTraceExpand(false);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{ "--trace-expand", CommandArgument::Values::Zero,
|
||||
[](std::string const&, cmake* state) -> bool {
|
||||
std::cout << "Running with expanded trace output on.\n";
|
||||
std::cout << "Put cmake in trace mode, but with "
|
||||
"variables expanded.\n";
|
||||
state->SetTrace(true);
|
||||
state->SetTraceExpand(true);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{ "--trace-format", CommandArgument::Values::One,
|
||||
[](std::string const& value, cmake* state) -> bool {
|
||||
state->SetTrace(true);
|
||||
const auto traceFormat = StringToTraceFormat(value);
|
||||
if (traceFormat == TraceFormat::TRACE_UNDEFINED) {
|
||||
cmSystemTools::Error(
|
||||
"Invalid format specified for --trace-format. "
|
||||
"Valid formats are human, json-v1.");
|
||||
return false;
|
||||
CommandArgument{
|
||||
"--trace-format", "Invalid format specified for --trace-format",
|
||||
CommandArgument::Values::One,
|
||||
[](std::string const& value, cmake* state) -> bool {
|
||||
std::cout << "Put cmake in trace mode and sets the "
|
||||
"trace output format.\n";
|
||||
state->SetTrace(true);
|
||||
const auto traceFormat = StringToTraceFormat(value);
|
||||
if (traceFormat == TraceFormat::Undefined) {
|
||||
cmSystemTools::Error("Invalid format specified for --trace-format. "
|
||||
"Valid formats are human, json-v1.");
|
||||
return false;
|
||||
}
|
||||
state->SetTraceFormat(traceFormat);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{ "--trace-source", "No file specified for --trace-source",
|
||||
CommandArgument::Values::OneOrMore,
|
||||
[](std::string const& values, cmake* state) -> bool {
|
||||
std::cout << "Put cmake in trace mode, but output only "
|
||||
"lines of a specified file. Multiple "
|
||||
"options are allowed.\n";
|
||||
for (auto file :
|
||||
cmSystemTools::SplitString(values, ';')) {
|
||||
cmSystemTools::ConvertToUnixSlashes(file);
|
||||
state->AddTraceSource(file);
|
||||
}
|
||||
state->SetTraceFormat(traceFormat);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{ "--trace-source", CommandArgument::Values::One,
|
||||
[](std::string const& value, cmake* state) -> bool {
|
||||
std::string file(value);
|
||||
cmSystemTools::ConvertToUnixSlashes(file);
|
||||
state->AddTraceSource(file);
|
||||
state->SetTrace(true);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{ "--trace-redirect", CommandArgument::Values::One,
|
||||
CommandArgument{ "--trace-redirect",
|
||||
"No file specified for --trace-redirect",
|
||||
CommandArgument::Values::One,
|
||||
[](std::string const& value, cmake* state) -> bool {
|
||||
std::cout
|
||||
<< "Put cmake in trace mode and redirect trace "
|
||||
"output to a file instead of stderr.\n";
|
||||
std::string file(value);
|
||||
cmSystemTools::ConvertToUnixSlashes(file);
|
||||
state->SetTraceFile(file);
|
||||
state->SetTrace(true);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{ "--trace", CommandArgument::Values::Zero,
|
||||
[](std::string const&, cmake* state) -> bool {
|
||||
std::cout << "Running with trace output on.\n";
|
||||
state->SetTrace(true);
|
||||
state->SetTraceExpand(false);
|
||||
return true;
|
||||
} },
|
||||
CommandArgument{ "--warn-uninitialized", CommandArgument::Values::Zero,
|
||||
[](std::string const&, cmake* state) -> bool {
|
||||
std::cout << "Warn about uninitialized values.\n";
|
||||
@@ -1530,6 +1545,29 @@ void cmake::SetArgs(const std::vector<std::string>& args)
|
||||
if (expandedPreset->DebugFind == true) {
|
||||
this->SetDebugFindOutput(true);
|
||||
}
|
||||
if (expandedPreset->TraceMode &&
|
||||
expandedPreset->TraceMode !=
|
||||
cmCMakePresetsGraph::TraceEnableMode::Disable) {
|
||||
this->SetTrace(true);
|
||||
if (expandedPreset->TraceMode ==
|
||||
cmCMakePresetsGraph::TraceEnableMode::Expand) {
|
||||
this->SetTraceExpand(true);
|
||||
}
|
||||
}
|
||||
if (expandedPreset->TraceFormat) {
|
||||
this->SetTrace(true);
|
||||
this->SetTraceFormat(*expandedPreset->TraceFormat);
|
||||
}
|
||||
if (!expandedPreset->TraceSource.empty()) {
|
||||
this->SetTrace(true);
|
||||
for (std::string const& filePaths : expandedPreset->TraceSource) {
|
||||
this->AddTraceSource(filePaths);
|
||||
}
|
||||
}
|
||||
if (!expandedPreset->TraceRedirect.empty()) {
|
||||
this->SetTrace(true);
|
||||
this->SetTraceFile(expandedPreset->TraceRedirect);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1586,8 +1624,8 @@ cmake::TraceFormat cmake::StringToTraceFormat(const std::string& traceStr)
|
||||
{
|
||||
using TracePair = std::pair<std::string, TraceFormat>;
|
||||
static const std::vector<TracePair> levels = {
|
||||
{ "human", TraceFormat::TRACE_HUMAN },
|
||||
{ "json-v1", TraceFormat::TRACE_JSON_V1 },
|
||||
{ "human", TraceFormat::Human },
|
||||
{ "json-v1", TraceFormat::JSONv1 },
|
||||
};
|
||||
|
||||
const auto traceStrLowCase = cmSystemTools::LowerCase(traceStr);
|
||||
@@ -1596,7 +1634,7 @@ cmake::TraceFormat cmake::StringToTraceFormat(const std::string& traceStr)
|
||||
[&traceStrLowCase](const TracePair& p) {
|
||||
return p.first == traceStrLowCase;
|
||||
});
|
||||
return (it != levels.cend()) ? it->second : TraceFormat::TRACE_UNDEFINED;
|
||||
return (it != levels.cend()) ? it->second : TraceFormat::Undefined;
|
||||
}
|
||||
|
||||
void cmake::SetTraceFile(const std::string& file)
|
||||
@@ -1622,7 +1660,7 @@ void cmake::PrintTraceFormatVersion()
|
||||
std::string msg;
|
||||
|
||||
switch (this->GetTraceFormat()) {
|
||||
case TraceFormat::TRACE_JSON_V1: {
|
||||
case TraceFormat::JSONv1: {
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
Json::Value val;
|
||||
Json::Value version;
|
||||
@@ -1635,11 +1673,11 @@ void cmake::PrintTraceFormatVersion()
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case TraceFormat::TRACE_HUMAN:
|
||||
case TraceFormat::Human:
|
||||
msg = "";
|
||||
break;
|
||||
case TraceFormat::TRACE_UNDEFINED:
|
||||
msg = "INTERNAL ERROR: Trace format is TRACE_UNDEFINED";
|
||||
case TraceFormat::Undefined:
|
||||
msg = "INTERNAL ERROR: Trace format is Undefined";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,13 +118,7 @@ public:
|
||||
FIND_PACKAGE_MODE
|
||||
};
|
||||
|
||||
/** \brief Define supported trace formats **/
|
||||
enum TraceFormat
|
||||
{
|
||||
TRACE_UNDEFINED,
|
||||
TRACE_HUMAN,
|
||||
TRACE_JSON_V1,
|
||||
};
|
||||
using TraceFormat = cmTraceEnums::TraceOutputFormat;
|
||||
|
||||
struct GeneratorInfo
|
||||
{
|
||||
@@ -719,7 +713,7 @@ private:
|
||||
bool DebugFindOutput = false;
|
||||
bool Trace = false;
|
||||
bool TraceExpand = false;
|
||||
TraceFormat TraceFormatVar = TRACE_HUMAN;
|
||||
TraceFormat TraceFormatVar = TraceFormat::Human;
|
||||
cmGeneratedFileStream TraceFile;
|
||||
cmake* TraceRedirect = nullptr;
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
|
||||
0
Tests/RunCMake/CMakePresets/ExplicitNoTrace.cmake
Normal file
0
Tests/RunCMake/CMakePresets/ExplicitNoTrace.cmake
Normal file
0
Tests/RunCMake/CMakePresets/NoTrace.cmake
Normal file
0
Tests/RunCMake/CMakePresets/NoTrace.cmake
Normal file
@@ -150,6 +150,7 @@ run_cmake_presets(InvalidRegex)
|
||||
set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
|
||||
run_cmake_presets(ConditionFuture)
|
||||
run_cmake_presets(SubConditionNull)
|
||||
run_cmake_presets(TraceNotSupported)
|
||||
|
||||
# Test cmakeMinimumRequired field
|
||||
run_cmake_presets(MinimumRequiredInvalid)
|
||||
@@ -326,6 +327,18 @@ set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Debug.json.in")
|
||||
run_cmake_presets(NoDebug)
|
||||
run_cmake_presets(Debug)
|
||||
|
||||
# Test trace
|
||||
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Trace.json.in")
|
||||
run_cmake_presets(NoTrace)
|
||||
run_cmake_presets(ExplicitNoTrace)
|
||||
run_cmake_presets(Trace)
|
||||
run_cmake_presets(TraceExpand)
|
||||
run_cmake_presets(TraceFormatJSON)
|
||||
run_cmake_presets(TraceFormatHuman)
|
||||
run_cmake_presets(TraceSource)
|
||||
run_cmake_presets(TraceRedirect)
|
||||
run_cmake_presets(TraceAll)
|
||||
|
||||
# Test ${hostSystemName} macro
|
||||
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/HostSystemName.json.in")
|
||||
run_cmake_presets(HostSystemName)
|
||||
|
||||
4
Tests/RunCMake/CMakePresets/Trace-stderr.txt
Normal file
4
Tests/RunCMake/CMakePresets/Trace-stderr.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
^[^
|
||||
]*/Tests/RunCMake/CMakePresets/Trace/CMakeLists.txt\(1\): cmake_minimum_required\(VERSION 3.18 \)
|
||||
[^
|
||||
]*/Tests/RunCMake/CMakePresets/Trace/CMakeLists.txt\(2\): project\(\${RunCMake_TEST} NONE \)
|
||||
0
Tests/RunCMake/CMakePresets/Trace.cmake
Normal file
0
Tests/RunCMake/CMakePresets/Trace.cmake
Normal file
69
Tests/RunCMake/CMakePresets/Trace.json.in
Normal file
69
Tests/RunCMake/CMakePresets/Trace.json.in
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"version": 7,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "NoTrace",
|
||||
"generator": "@RunCMake_GENERATOR@",
|
||||
"binaryDir": "${sourceDir}/build"
|
||||
},
|
||||
{
|
||||
"name": "ExplicitNoTrace",
|
||||
"inherits": "NoTrace",
|
||||
"trace": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Trace",
|
||||
"inherits": "NoTrace",
|
||||
"trace": {
|
||||
"mode": "on"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "TraceExpand",
|
||||
"inherits": "NoTrace",
|
||||
"trace": {
|
||||
"mode": "expand"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "TraceFormatJSON",
|
||||
"inherits": "NoTrace",
|
||||
"trace": {
|
||||
"format": "json-v1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "TraceFormatHuman",
|
||||
"inherits": "NoTrace",
|
||||
"trace": {
|
||||
"format": "human"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "TraceSource",
|
||||
"inherits": "NoTrace",
|
||||
"trace": {
|
||||
"source": "TraceSourceFile.txt"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "TraceRedirect",
|
||||
"inherits": "NoTrace",
|
||||
"trace": {
|
||||
"redirect": "TraceRedirectFile.txt"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "TraceAll",
|
||||
"inherits": "NoTrace",
|
||||
"trace": {
|
||||
"mode": "expand",
|
||||
"format": "json-v1",
|
||||
"source": "TraceSourceFile.txt",
|
||||
"redirect": "TraceRedirectFile.json"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
4
Tests/RunCMake/CMakePresets/TraceAll.cmake
Normal file
4
Tests/RunCMake/CMakePresets/TraceAll.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/TraceExpand.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/TraceFormatJSON.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/TraceSource.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/TraceRedirect.cmake)
|
||||
4
Tests/RunCMake/CMakePresets/TraceExpand-stderr.txt
Normal file
4
Tests/RunCMake/CMakePresets/TraceExpand-stderr.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
^[^
|
||||
]*/Tests/RunCMake/CMakePresets/TraceExpand/CMakeLists.txt\(1\): cmake_minimum_required\(VERSION 3.18 \)
|
||||
[^
|
||||
]*/Tests/RunCMake/CMakePresets/TraceExpand/CMakeLists.txt\(2\): project\(TraceExpand NONE \)
|
||||
0
Tests/RunCMake/CMakePresets/TraceExpand.cmake
Normal file
0
Tests/RunCMake/CMakePresets/TraceExpand.cmake
Normal file
4
Tests/RunCMake/CMakePresets/TraceFormatHuman-stderr.txt
Normal file
4
Tests/RunCMake/CMakePresets/TraceFormatHuman-stderr.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
^[^
|
||||
]*/Tests/RunCMake/CMakePresets/TraceFormatHuman/CMakeLists.txt\(1\): cmake_minimum_required\(VERSION 3.18 \)
|
||||
[^
|
||||
]*/Tests/RunCMake/CMakePresets/TraceFormatHuman/CMakeLists.txt\(2\): project\(\${RunCMake_TEST} NONE \)
|
||||
0
Tests/RunCMake/CMakePresets/TraceFormatHuman.cmake
Normal file
0
Tests/RunCMake/CMakePresets/TraceFormatHuman.cmake
Normal file
3
Tests/RunCMake/CMakePresets/TraceFormatJSON-stderr.txt
Normal file
3
Tests/RunCMake/CMakePresets/TraceFormatJSON-stderr.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
^{"version":{"major":1,"minor":2}}
|
||||
{"args":\["VERSION","3\.18"\],"cmd":"cmake_minimum_required","file":"[^"]*/Tests/RunCMake/CMakePresets/TraceFormatJSON/CMakeLists\.txt","frame":1,"global_frame":1,"line":1,"time":[0-9.]+}
|
||||
{"args":\["\${RunCMake_TEST}","NONE"\],"cmd":"project","file":"[^"]*/Tests/RunCMake/CMakePresets/TraceFormatJSON/CMakeLists\.txt","frame":1,"global_frame":1,"line":2,"time":[0-9.]+}
|
||||
0
Tests/RunCMake/CMakePresets/TraceFormatJSON.cmake
Normal file
0
Tests/RunCMake/CMakePresets/TraceFormatJSON.cmake
Normal file
1
Tests/RunCMake/CMakePresets/TraceNotSupported-result.txt
Normal file
1
Tests/RunCMake/CMakePresets/TraceNotSupported-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
3
Tests/RunCMake/CMakePresets/TraceNotSupported-stderr.txt
Normal file
3
Tests/RunCMake/CMakePresets/TraceNotSupported-stderr.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
^CMake Error: Could not read presets from [^
|
||||
]*/Tests/RunCMake/CMakePresets/TraceNotSupported:
|
||||
File version must be 7 or higher for trace preset support$
|
||||
13
Tests/RunCMake/CMakePresets/TraceNotSupported.json.in
Normal file
13
Tests/RunCMake/CMakePresets/TraceNotSupported.json.in
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 6,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "TraceNotSupported",
|
||||
"generator": "@RunCMake_GENERATOR@",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"trace": {
|
||||
"mode": "expand"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
0
Tests/RunCMake/CMakePresets/TraceRedirect.cmake
Normal file
0
Tests/RunCMake/CMakePresets/TraceRedirect.cmake
Normal file
0
Tests/RunCMake/CMakePresets/TraceSource.cmake
Normal file
0
Tests/RunCMake/CMakePresets/TraceSource.cmake
Normal file
Reference in New Issue
Block a user