mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
Merge topic 'instrumentation-trace-names'
6929baca2f
instrumentation: Fix trace event names
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11250
This commit is contained in:
@@ -944,21 +944,25 @@ void cmInstrumentation::AppendTraceEvent(Json::Value& trace,
|
||||
|
||||
// Provide a useful trace event name depending on what data is available
|
||||
// from the snippet.
|
||||
std::string name = cmStrCat(snippetData["role"].asString(), ": ");
|
||||
std::string nameSuffix;
|
||||
if (snippetData["role"] == "compile") {
|
||||
name.append(snippetData["source"].asString());
|
||||
nameSuffix = snippetData["source"].asString();
|
||||
} else if (snippetData["role"] == "link") {
|
||||
name.append(snippetData["target"].asString());
|
||||
nameSuffix = snippetData["target"].asString();
|
||||
} else if (snippetData["role"] == "install") {
|
||||
cmCMakePath workingDir(snippetData["workingDir"].asCString());
|
||||
std::string lastDirName = workingDir.GetFileName().String();
|
||||
name.append(lastDirName);
|
||||
nameSuffix = workingDir.GetFileName().String();
|
||||
} else if (snippetData["role"] == "custom") {
|
||||
name.append(snippetData["command"].asString());
|
||||
nameSuffix = snippetData["command"].asString();
|
||||
} else if (snippetData["role"] == "test") {
|
||||
name.append(snippetData["testName"].asString());
|
||||
nameSuffix = snippetData["testName"].asString();
|
||||
}
|
||||
if (!nameSuffix.empty()) {
|
||||
snippetTraceEvent["name"] =
|
||||
cmStrCat(snippetData["role"].asString(), ": ", nameSuffix);
|
||||
} else {
|
||||
snippetTraceEvent["name"] = snippetData["role"].asString();
|
||||
}
|
||||
snippetTraceEvent["name"] = name;
|
||||
|
||||
snippetTraceEvent["cat"] = snippetData["role"];
|
||||
snippetTraceEvent["ph"] = "X";
|
||||
|
@@ -49,23 +49,23 @@ function(trace_valid_entry trace entry)
|
||||
json_error("${trace}" "Name is empty: ${entry}")
|
||||
endif()
|
||||
string(JSON cat GET "${entry}" cat)
|
||||
set(expected_name "${cat}: ")
|
||||
set(expected_name "${cat}")
|
||||
if (cat STREQUAL "compile")
|
||||
string(JSON source GET "${args}" source)
|
||||
string(APPEND expected_name "${source}")
|
||||
string(APPEND expected_name ": ${source}")
|
||||
elseif (cat STREQUAL "link")
|
||||
string(JSON target GET "${args}" target)
|
||||
string(APPEND expected_name "${target}")
|
||||
string(APPEND expected_name ": ${target}")
|
||||
elseif (cat STREQUAL "install")
|
||||
string(JSON workingDir GET "${args}" workingDir)
|
||||
cmake_path(GET workingDir FILENAME lastDirName)
|
||||
string(APPEND expected_name "${lastDirName}")
|
||||
string(APPEND expected_name ": ${lastDirName}")
|
||||
elseif (cat STREQUAL "custom")
|
||||
string(JSON command GET "${args}" command)
|
||||
string(APPEND expected_name "${command}")
|
||||
string(APPEND expected_name ": ${command}")
|
||||
elseif (cat STREQUAL "test")
|
||||
string(JSON testName GET "${args}" testName)
|
||||
string(APPEND expected_name "${testName}")
|
||||
string(APPEND expected_name ": ${testName}")
|
||||
endif()
|
||||
if (NOT name STREQUAL expected_name)
|
||||
json_error("${trace}" "Invalid name: ${name}")
|
||||
|
Reference in New Issue
Block a user