mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-18 08:51:52 +08:00
instrumentation: Add Config value to snippet data
This commit is contained in:
@@ -263,6 +263,10 @@ and contain the following data:
|
||||
``testName``
|
||||
The name of the test being executed. Only included when ``role`` is ``test``.
|
||||
|
||||
``config``
|
||||
The type of build, such as ``Release`` or ``Debug``. Only included when
|
||||
``role`` is ``compile``, ``link`` or ``test``.
|
||||
|
||||
``dynamicSystemInformation``
|
||||
Specifies the dynamic information collected about the host machine
|
||||
CMake is being run from. Data is collected for every snippet file
|
||||
@@ -294,7 +298,8 @@ Example:
|
||||
"language" : "C++",
|
||||
"outputs" : [ "CMakeFiles/main.dir/main.cxx.o" ],
|
||||
"outputSizes" : [ 0 ],
|
||||
"source" : "<src>/main.cxx"
|
||||
"source" : "<src>/main.cxx",
|
||||
"config" : "Debug",
|
||||
"dynamicSystemInformation" :
|
||||
{
|
||||
"afterCPULoadAverage" : 2.3500000000000001,
|
||||
|
@@ -70,7 +70,8 @@ bool cmCTestLaunch::ParseArguments(int argc, char const* const* argv)
|
||||
DoingBuildDir,
|
||||
DoingCurrentBuildDir,
|
||||
DoingCount,
|
||||
DoingFilterPrefix
|
||||
DoingFilterPrefix,
|
||||
DoingConfig
|
||||
};
|
||||
Doing doing = DoingNone;
|
||||
int arg0 = 0;
|
||||
@@ -100,6 +101,8 @@ bool cmCTestLaunch::ParseArguments(int argc, char const* const* argv)
|
||||
doing = DoingCurrentBuildDir;
|
||||
} else if (strcmp(arg, "--filter-prefix") == 0) {
|
||||
doing = DoingFilterPrefix;
|
||||
} else if (strcmp(arg, "--config") == 0) {
|
||||
doing = DoingConfig;
|
||||
} else if (doing == DoingOutput) {
|
||||
this->Reporter.OptionOutput = arg;
|
||||
doing = DoingNone;
|
||||
@@ -136,6 +139,9 @@ bool cmCTestLaunch::ParseArguments(int argc, char const* const* argv)
|
||||
} else if (doing == DoingRole) {
|
||||
this->Reporter.OptionRole = arg;
|
||||
doing = DoingNone;
|
||||
} else if (doing == DoingConfig) {
|
||||
this->Reporter.OptionConfig = arg;
|
||||
doing = DoingNone;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,6 +273,7 @@ int cmCTestLaunch::Run()
|
||||
options["language"] = this->Reporter.OptionLanguage;
|
||||
options["targetType"] = this->Reporter.OptionTargetType;
|
||||
options["role"] = this->Reporter.OptionRole;
|
||||
options["config"] = this->Reporter.OptionConfig;
|
||||
std::map<std::string, std::string> arrayOptions;
|
||||
arrayOptions["outputs"] = this->Reporter.OptionOutput;
|
||||
arrayOptions["targetLabels"] = this->Reporter.OptionTargetLabels;
|
||||
|
@@ -42,6 +42,7 @@ public:
|
||||
std::string OptionFilterPrefix;
|
||||
std::string OptionCommandType;
|
||||
std::string OptionRole;
|
||||
std::string OptionConfig;
|
||||
|
||||
// The real command line appearing after launcher arguments.
|
||||
std::string CWD;
|
||||
|
@@ -1020,7 +1020,8 @@ void cmCTestRunTest::FinalizeTest(bool started)
|
||||
this->Instrumentation.InstrumentTest(
|
||||
this->TestProperties->Name, this->ActualCommand, this->Arguments,
|
||||
this->TestProcess->GetExitValue(), this->TestProcess->GetStartTime(),
|
||||
this->TestProcess->GetSystemStartTime());
|
||||
this->TestProcess->GetSystemStartTime(),
|
||||
this->GetCTest()->GetConfigType());
|
||||
}
|
||||
this->MultiTestHandler.FinishTestProcess(this->TestProcess->GetRunner(),
|
||||
started);
|
||||
|
@@ -312,7 +312,7 @@ int cmInstrumentation::InstrumentTest(
|
||||
std::string const& name, std::string const& command,
|
||||
std::vector<std::string> const& args, int64_t result,
|
||||
std::chrono::steady_clock::time_point steadyStart,
|
||||
std::chrono::system_clock::time_point systemStart)
|
||||
std::chrono::system_clock::time_point systemStart, std::string config)
|
||||
{
|
||||
// Store command info
|
||||
Json::Value root(this->preTestStats);
|
||||
@@ -323,6 +323,7 @@ int cmInstrumentation::InstrumentTest(
|
||||
root["testName"] = name;
|
||||
root["binaryDir"] = this->binaryDir;
|
||||
root["result"] = static_cast<Json::Value::Int64>(result);
|
||||
root["config"] = config;
|
||||
|
||||
// Post-Command
|
||||
this->InsertTimingData(root, steadyStart, systemStart);
|
||||
@@ -417,6 +418,13 @@ int cmInstrumentation::InstrumentCommand(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create empty config entry if config not found
|
||||
if (!root.isMember("config") &&
|
||||
(command_type == "compile" || command_type == "link")) {
|
||||
root["config"] = "";
|
||||
}
|
||||
|
||||
if (arrayOptions.has_value()) {
|
||||
for (auto const& item : arrayOptions.value()) {
|
||||
if (item.first == "targetLabels" && command_type != "link") {
|
||||
|
@@ -32,7 +32,8 @@ public:
|
||||
int InstrumentTest(std::string const& name, std::string const& command,
|
||||
std::vector<std::string> const& args, int64_t result,
|
||||
std::chrono::steady_clock::time_point steadyStart,
|
||||
std::chrono::system_clock::time_point systemStart);
|
||||
std::chrono::system_clock::time_point systemStart,
|
||||
std::string config);
|
||||
void GetPreTestStats();
|
||||
void LoadQueries();
|
||||
bool HasQuery() const;
|
||||
|
@@ -554,6 +554,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
|
||||
cmOutputConverter::SHELL, useWatcomQuote);
|
||||
vars.Target = target.c_str();
|
||||
vars.TargetPDB = targetOutPathPDB.c_str();
|
||||
vars.Config = this->GetConfigName().c_str();
|
||||
|
||||
// Setup the target version.
|
||||
std::string targetVersionMajor;
|
||||
|
@@ -809,8 +809,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
|
||||
vars.TargetSOName = targetOutSOName.c_str();
|
||||
}
|
||||
vars.LinkFlags = linkFlags.c_str();
|
||||
|
||||
vars.Manifests = manifests.c_str();
|
||||
vars.Config = this->GetConfigName().c_str();
|
||||
|
||||
// Compute the directory portion of the install_name setting.
|
||||
std::string install_name_dir;
|
||||
|
@@ -952,6 +952,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
|
||||
vars.ObjectFileDir = objectFileDir.c_str();
|
||||
vars.Flags = flags.c_str();
|
||||
vars.ISPCHeader = ispcHeaderForShell.c_str();
|
||||
vars.Config = this->GetConfigName().c_str();
|
||||
|
||||
std::string definesString = cmStrCat("$(", lang, "_DEFINES)");
|
||||
|
||||
@@ -1700,6 +1701,7 @@ void cmMakefileTargetGenerator::WriteDeviceLinkRule(
|
||||
vars.Object = output.c_str();
|
||||
vars.Fatbinary = fatbinaryOutput.c_str();
|
||||
vars.RegisterFile = registerFile.c_str();
|
||||
vars.Config = this->GetConfigName().c_str();
|
||||
|
||||
std::string linkFlags;
|
||||
this->GetDeviceLinkFlags(linkFlags, "CUDA");
|
||||
|
@@ -342,6 +342,7 @@ void cmNinjaNormalTargetGenerator::WriteNvidiaDeviceLinkRule(
|
||||
vars.Flags = "$FLAGS";
|
||||
vars.LinkFlags = "$LINK_FLAGS";
|
||||
vars.Manifests = "$MANIFESTS";
|
||||
vars.Config = "$CONFIG";
|
||||
|
||||
vars.LanguageCompileFlags = "$LANGUAGE_COMPILE_FLAGS";
|
||||
|
||||
@@ -416,6 +417,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRules(
|
||||
|
||||
std::string flags = this->GetFlags("CUDA", config);
|
||||
vars.Flags = flags.c_str();
|
||||
vars.Config = "$CONFIG";
|
||||
|
||||
std::string compileCmd = this->GetMakefile()->GetRequiredDefinition(
|
||||
"CMAKE_CUDA_DEVICE_LINK_COMPILE");
|
||||
@@ -557,6 +559,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile,
|
||||
vars.Flags = "$FLAGS";
|
||||
vars.LinkFlags = "$LINK_FLAGS";
|
||||
vars.Manifests = "$MANIFESTS";
|
||||
vars.Config = "$CONFIG";
|
||||
|
||||
std::string langFlags;
|
||||
if (targetType != cmStateEnums::EXECUTABLE) {
|
||||
@@ -1313,6 +1316,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
|
||||
vars["AIX_EXPORTS"] = this->GetAIXExports(config);
|
||||
|
||||
vars["LINK_PATH"] = frameworkPath + linkPath;
|
||||
vars["CONFIG"] = config;
|
||||
|
||||
// Compute architecture specific link flags. Yes, these go into a different
|
||||
// variable for executables, probably due to a mistake made when duplicating
|
||||
|
@@ -630,6 +630,7 @@ cmNinjaRule GetScanRule(
|
||||
scanVars.DynDepFile = "$DYNDEP_INTERMEDIATE_FILE";
|
||||
scanVars.DependencyFile = rule.DepFile.c_str();
|
||||
scanVars.DependencyTarget = "$out";
|
||||
scanVars.Config = vars.Config;
|
||||
|
||||
// Scanning needs the same preprocessor settings as direct compilation would.
|
||||
scanVars.Source = vars.Source;
|
||||
@@ -695,6 +696,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(std::string const& lang,
|
||||
vars.ObjectFileDir = "$OBJECT_FILE_DIR";
|
||||
vars.CudaCompileMode = "$CUDA_COMPILE_MODE";
|
||||
vars.ISPCHeader = "$ISPC_HEADER_FILE";
|
||||
vars.Config = "$CONFIG";
|
||||
|
||||
cmMakefile* mf = this->GetMakefile();
|
||||
|
||||
@@ -1440,6 +1442,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
|
||||
this->ComputeFlagsForObject(source, language, config, objectFileName);
|
||||
vars["DEFINES"] = this->ComputeDefines(source, language, config);
|
||||
vars["INCLUDES"] = this->ComputeIncludes(source, language, config);
|
||||
vars["CONFIG"] = config;
|
||||
|
||||
auto compilerLauncher = this->GetCompilerLauncher(language, config);
|
||||
|
||||
@@ -1793,6 +1796,7 @@ void cmNinjaTargetGenerator::WriteCxxModuleBmiBuildStatement(
|
||||
this->ComputeFlagsForObject(source, language, config, bmiFileName);
|
||||
vars["DEFINES"] = this->ComputeDefines(source, language, config);
|
||||
vars["INCLUDES"] = this->ComputeIncludes(source, language, config);
|
||||
vars["CONFIG"] = config;
|
||||
|
||||
if (this->GetMakefile()->GetSafeDefinition(
|
||||
cmStrCat("CMAKE_", language, "_DEPFILE_FORMAT")) != "msvc"_s) {
|
||||
@@ -2035,6 +2039,7 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement(
|
||||
this->GetFlags(language, config));
|
||||
vars["DEFINES"] = this->GetDefines(language, config);
|
||||
vars["INCLUDES"] = this->GetIncludes(language, config);
|
||||
vars["CONFIG"] = config;
|
||||
|
||||
// target-level object filename
|
||||
std::string const targetObjectFilename = this->ConvertToNinjaPath(cmStrCat(
|
||||
|
@@ -283,6 +283,12 @@ std::string cmRulePlaceholderExpander::ExpandVariable(
|
||||
}
|
||||
return "";
|
||||
}
|
||||
if (variable == "CONFIG") {
|
||||
if (this->ReplaceValues->Config) {
|
||||
return this->ReplaceValues->Config;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
auto compIt = this->Compilers.find(variable);
|
||||
|
||||
|
@@ -75,6 +75,7 @@ public:
|
||||
char const* RegisterFile = nullptr;
|
||||
char const* Launcher = nullptr;
|
||||
char const* Role = nullptr;
|
||||
char const* Config = nullptr;
|
||||
};
|
||||
|
||||
// Expand rule variables in CMake of the type found in language rules
|
||||
|
@@ -2690,13 +2690,13 @@ int cmake::ActualConfigure()
|
||||
this->State->SetGlobalProperty(
|
||||
"RULE_LAUNCH_COMPILE",
|
||||
cmStrCat(
|
||||
launcher, "--command-type compile", common_args,
|
||||
launcher, "--command-type compile", common_args, "--config <CONFIG> ",
|
||||
"--output <OBJECT> --source <SOURCE> --language <LANGUAGE> -- "));
|
||||
this->State->SetGlobalProperty(
|
||||
"RULE_LAUNCH_LINK",
|
||||
cmStrCat(
|
||||
launcher, "--command-type link", common_args,
|
||||
"--output <TARGET> --target-type <TARGET_TYPE> ",
|
||||
"--output <TARGET> --target-type <TARGET_TYPE> --config <CONFIG> ",
|
||||
"--language <LANGUAGE> --target-labels \"<TARGET_LABELS>\" -- "));
|
||||
this->State->SetGlobalProperty(
|
||||
"RULE_LAUNCH_CUSTOM",
|
||||
|
@@ -52,7 +52,10 @@ function(instrument test)
|
||||
list(APPEND ARGS_CONFIGURE_ARG "-Wno-dev")
|
||||
endif()
|
||||
set(RunCMake_TEST_SOURCE_DIR ${RunCMake_SOURCE_DIR}/project)
|
||||
run_cmake_with_options(${test} ${ARGS_CONFIGURE_ARG})
|
||||
if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
set(maybe_CMAKE_BUILD_TYPE -DCMAKE_BUILD_TYPE=Debug)
|
||||
endif()
|
||||
run_cmake_with_options(${test} ${ARGS_CONFIGURE_ARG} ${maybe_CMAKE_BUILD_TYPE})
|
||||
|
||||
# Follow-up Commands
|
||||
if (ARGS_BUILD)
|
||||
|
@@ -99,6 +99,14 @@ foreach(snippet IN LISTS snippets)
|
||||
snippet_error("${snippet}" "Unexpected testName: ${testName}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Verify that Config is Debug
|
||||
if (filename MATCHES "^test|^compile|^link")
|
||||
string(JSON config GET "${contents}" config)
|
||||
if (NOT config STREQUAL "Debug")
|
||||
snippet_error(${snippet} "Unexpected config: ${config}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Verify that listed snippets match expected roles
|
||||
|
@@ -37,18 +37,21 @@ function(snippet_has_fields snippet contents)
|
||||
has_key("${snippet}" "${contents}" outputSizes)
|
||||
has_key("${snippet}" "${contents}" targetType)
|
||||
has_key("${snippet}" "${contents}" targetLabels)
|
||||
has_key("${snippet}" "${contents}" config)
|
||||
elseif (filename MATCHES "^compile-*")
|
||||
has_key("${snippet}" "${contents}" target)
|
||||
has_key("${snippet}" "${contents}" outputs)
|
||||
has_key("${snippet}" "${contents}" outputSizes)
|
||||
has_key("${snippet}" "${contents}" source)
|
||||
has_key("${snippet}" "${contents}" language)
|
||||
has_key("${snippet}" "${contents}" config)
|
||||
elseif (filename MATCHES "^custom-*")
|
||||
has_key("${snippet}" "${contents}" target)
|
||||
has_key("${snippet}" "${contents}" outputs)
|
||||
has_key("${snippet}" "${contents}" outputSizes)
|
||||
elseif (filename MATCHES "^test-*")
|
||||
has_key("${snippet}" "${contents}" testName)
|
||||
has_key("${snippet}" "${contents}" config)
|
||||
endif()
|
||||
if(ARGS_DYNAMIC_QUERY)
|
||||
has_key("${snippet}" "${contents}" dynamicSystemInformation)
|
||||
|
Reference in New Issue
Block a user