mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 20:46:37 +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:
@@ -20,6 +20,7 @@
|
||||
#include "cmsys/FStream.hxx"
|
||||
#include "cmsys/SystemInformation.hxx"
|
||||
|
||||
#include "cmCMakePath.h"
|
||||
#include "cmCryptoHash.h"
|
||||
#include "cmExperimental.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
|
||||
// from the snippet.
|
||||
std::string name = snippetData["role"].asString();
|
||||
std::string name = cmStrCat(snippetData["role"].asString(), ": ");
|
||||
if (snippetData["role"] == "compile") {
|
||||
name = cmStrCat("compile: ", snippetData["source"].asString());
|
||||
name.append(snippetData["source"].asString());
|
||||
} else if (snippetData["role"] == "link") {
|
||||
name = cmStrCat("link: ", snippetData["target"].asString());
|
||||
} else if (snippetData["role"] == "custom" ||
|
||||
snippetData["role"] == "install") {
|
||||
name = snippetData["command"].asString();
|
||||
name.append(snippetData["target"].asString());
|
||||
} else if (snippetData["role"] == "install") {
|
||||
cmCMakePath workingDir(snippetData["workingDir"].asCString());
|
||||
std::string lastDirName = workingDir.GetFileName().String();
|
||||
name.append(lastDirName);
|
||||
} else if (snippetData["role"] == "custom") {
|
||||
name.append(snippetData["command"].asString());
|
||||
} else if (snippetData["role"] == "test") {
|
||||
name = cmStrCat("test: ", snippetData["testName"].asString());
|
||||
name.append(snippetData["testName"].asString());
|
||||
}
|
||||
snippetTraceEvent["name"] = name;
|
||||
|
||||
|
@@ -45,35 +45,29 @@ function(trace_valid_entry trace entry)
|
||||
|
||||
# Check the formation of the "name" based on the snippet data
|
||||
string(JSON name GET "${entry}" name)
|
||||
if (NOT name)
|
||||
json_error("${trace}" "Name is empty: ${entry}")
|
||||
endif()
|
||||
string(JSON cat GET "${entry}" cat)
|
||||
set(error_name OFF)
|
||||
set(expected_name "${cat}: ")
|
||||
if (cat STREQUAL "compile")
|
||||
string(JSON source GET "${args}" source)
|
||||
if (NOT name STREQUAL "compile: ${source}")
|
||||
set(error_name ON)
|
||||
endif()
|
||||
string(APPEND expected_name "${source}")
|
||||
elseif (cat STREQUAL "link")
|
||||
string(JSON target GET "${args}" target)
|
||||
if (NOT name STREQUAL "link: ${target}")
|
||||
set(error_name ON)
|
||||
endif()
|
||||
elseif (cat STREQUAL "custom" OR cat STREQUAL "install")
|
||||
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}")
|
||||
elseif (cat STREQUAL "custom")
|
||||
string(JSON command GET "${args}" command)
|
||||
if (NOT name STREQUAL command)
|
||||
set(error_name ON)
|
||||
endif()
|
||||
string(APPEND expected_name "${command}")
|
||||
elseif (cat STREQUAL "test")
|
||||
string(JSON testName GET "${args}" testName)
|
||||
if (NOT name STREQUAL "test: ${testName}")
|
||||
set(error_name ON)
|
||||
endif()
|
||||
else()
|
||||
string(JSON role GET "${args}" role)
|
||||
if (NOT name STREQUAL role)
|
||||
set(error_name ON)
|
||||
endif()
|
||||
string(APPEND expected_name "${testName}")
|
||||
endif()
|
||||
if (error_name)
|
||||
if (NOT name STREQUAL expected_name)
|
||||
json_error("${trace}" "Invalid name: ${name}")
|
||||
endif()
|
||||
|
||||
|
Reference in New Issue
Block a user