1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 22:37:30 +08:00

instrumentation: Rename install and custom trace events

Follow the format of other trace events to produce a pretty name for
install events (as the last component of the install script directory)
and a slightly prettier name for custom events (still limited by the
nature of custom targets).
This commit is contained in:
Tyler Yankee
2025-09-04 10:02:58 -04:00
parent 89f4471c4c
commit 933176c2d1
2 changed files with 25 additions and 27 deletions

View File

@@ -20,6 +20,7 @@
#include "cmsys/FStream.hxx" #include "cmsys/FStream.hxx"
#include "cmsys/SystemInformation.hxx" #include "cmsys/SystemInformation.hxx"
#include "cmCMakePath.h"
#include "cmCryptoHash.h" #include "cmCryptoHash.h"
#include "cmExperimental.h" #include "cmExperimental.h"
#include "cmFileLock.h" #include "cmFileLock.h"
@@ -946,16 +947,19 @@ void cmInstrumentation::AppendTraceEvent(Json::Value& trace,
// Provide a useful trace event name depending on what data is available // Provide a useful trace event name depending on what data is available
// from the snippet. // from the snippet.
std::string name = snippetData["role"].asString(); std::string name = cmStrCat(snippetData["role"].asString(), ": ");
if (snippetData["role"] == "compile") { if (snippetData["role"] == "compile") {
name = cmStrCat("compile: ", snippetData["source"].asString()); name.append(snippetData["source"].asString());
} else if (snippetData["role"] == "link") { } else if (snippetData["role"] == "link") {
name = cmStrCat("link: ", snippetData["target"].asString()); name.append(snippetData["target"].asString());
} else if (snippetData["role"] == "custom" || } else if (snippetData["role"] == "install") {
snippetData["role"] == "install") { cmCMakePath workingDir(snippetData["workingDir"].asCString());
name = snippetData["command"].asString(); std::string lastDirName = workingDir.GetFileName().String();
name.append(lastDirName);
} else if (snippetData["role"] == "custom") {
name.append(snippetData["command"].asString());
} else if (snippetData["role"] == "test") { } else if (snippetData["role"] == "test") {
name = cmStrCat("test: ", snippetData["testName"].asString()); name.append(snippetData["testName"].asString());
} }
snippetTraceEvent["name"] = name; snippetTraceEvent["name"] = name;

View File

@@ -45,35 +45,29 @@ function(trace_valid_entry trace entry)
# Check the formation of the "name" based on the snippet data # Check the formation of the "name" based on the snippet data
string(JSON name GET "${entry}" name) string(JSON name GET "${entry}" name)
if (NOT name)
json_error("${trace}" "Name is empty: ${entry}")
endif()
string(JSON cat GET "${entry}" cat) string(JSON cat GET "${entry}" cat)
set(error_name OFF) set(expected_name "${cat}: ")
if (cat STREQUAL "compile") if (cat STREQUAL "compile")
string(JSON source GET "${args}" source) string(JSON source GET "${args}" source)
if (NOT name STREQUAL "compile: ${source}") string(APPEND expected_name "${source}")
set(error_name ON)
endif()
elseif (cat STREQUAL "link") elseif (cat STREQUAL "link")
string(JSON target GET "${args}" target) string(JSON target GET "${args}" target)
if (NOT name STREQUAL "link: ${target}") string(APPEND expected_name "${target}")
set(error_name ON) elseif (cat STREQUAL "install")
endif() string(JSON workingDir GET "${args}" workingDir)
elseif (cat STREQUAL "custom" OR cat STREQUAL "install") cmake_path(GET workingDir FILENAME lastDirName)
string(APPEND expected_name "${lastDirName}")
elseif (cat STREQUAL "custom")
string(JSON command GET "${args}" command) string(JSON command GET "${args}" command)
if (NOT name STREQUAL command) string(APPEND expected_name "${command}")
set(error_name ON)
endif()
elseif (cat STREQUAL "test") elseif (cat STREQUAL "test")
string(JSON testName GET "${args}" testName) string(JSON testName GET "${args}" testName)
if (NOT name STREQUAL "test: ${testName}") string(APPEND expected_name "${testName}")
set(error_name ON)
endif() endif()
else() if (NOT name STREQUAL expected_name)
string(JSON role GET "${args}" role)
if (NOT name STREQUAL role)
set(error_name ON)
endif()
endif()
if (error_name)
json_error("${trace}" "Invalid name: ${name}") json_error("${trace}" "Invalid name: ${name}")
endif() endif()