mirror of
https://github.com/Kitware/CMake.git
synced 2026-06-24 16:58:07 +00:00
@@ -1,12 +1,7 @@
|
||||
cmake_instrumentation
|
||||
---------------------
|
||||
|
||||
.. versionadded:: 4.0
|
||||
|
||||
.. note::
|
||||
|
||||
This command is only available when experimental support for instrumentation
|
||||
has been enabled by the ``CMAKE_EXPERIMENTAL_INSTRUMENTATION`` gate.
|
||||
.. versionadded:: 4.3
|
||||
|
||||
Enables interacting with the
|
||||
:manual:`CMake Instrumentation API <cmake-instrumentation(7)>`.
|
||||
|
||||
@@ -140,26 +140,6 @@ When activated, this experimental feature provides the following:
|
||||
* Targets with the property set to a true value will have their C++ build
|
||||
information exported to the build database.
|
||||
|
||||
Instrumentation
|
||||
===============
|
||||
|
||||
In order to activate support for the :command:`cmake_instrumentation` command,
|
||||
set
|
||||
|
||||
* variable ``CMAKE_EXPERIMENTAL_INSTRUMENTATION`` to
|
||||
* value ``ec7aa2dc-b87f-45a3-8022-fe01c5f59984``.
|
||||
|
||||
To enable instrumentation at the user-level, files should be placed under
|
||||
either
|
||||
``<CMAKE_CONFIG_DIR>/instrumentation-ec7aa2dc-b87f-45a3-8022-fe01c5f59984`` or
|
||||
``<CMAKE_BINARY_DIR>/.cmake/instrumentation-ec7aa2dc-b87f-45a3-8022-fe01c5f59984``.
|
||||
|
||||
To include instrumentation data in CTest XML files (for submission to CDash),
|
||||
you need to set the following environment variables:
|
||||
|
||||
* ``CTEST_USE_INSTRUMENTATION=1``
|
||||
* ``CTEST_EXPERIMENTAL_INSTRUMENTATION=ec7aa2dc-b87f-45a3-8022-fe01c5f59984``
|
||||
|
||||
Software Bill Of Materials |SBOM|
|
||||
=================================
|
||||
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
CTEST_USE_INSTRUMENTATION
|
||||
-------------------------
|
||||
|
||||
.. versionadded:: 4.0
|
||||
.. versionadded:: 4.3
|
||||
|
||||
.. include:: include/ENV_VAR.rst
|
||||
|
||||
.. note::
|
||||
|
||||
This feature is only available when experimental support for instrumentation
|
||||
has been enabled by the ``CMAKE_EXPERIMENTAL_INSTRUMENTATION`` gate.
|
||||
|
||||
Setting this environment variable to ``1``, ``True``, or ``ON`` enables
|
||||
:manual:`instrumentation <cmake-instrumentation(7)>` for CTest in
|
||||
:ref:`Dashboard Client` mode.
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
CTEST_USE_VERBOSE_INSTRUMENTATION
|
||||
---------------------------------
|
||||
|
||||
.. versionadded:: 4.0
|
||||
.. versionadded:: 4.3
|
||||
|
||||
.. include:: include/ENV_VAR.rst
|
||||
|
||||
.. note::
|
||||
|
||||
This feature is only available when experimental support for instrumentation
|
||||
has been enabled by the ``CMAKE_EXPERIMENTAL_INSTRUMENTATION`` gate.
|
||||
|
||||
Setting this environment variable to ``1``, ``True``, or ``ON`` causes CTest to
|
||||
report the full command line (including arguments) to CDash for each
|
||||
instrumented command. By default, CTest truncates the command line at the first
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
cmake-instrumentation(7)
|
||||
************************
|
||||
|
||||
.. versionadded:: 4.0
|
||||
.. versionadded:: 4.3
|
||||
|
||||
.. only:: html
|
||||
|
||||
@@ -12,11 +12,6 @@ cmake-instrumentation(7)
|
||||
Introduction
|
||||
============
|
||||
|
||||
.. note::
|
||||
|
||||
This feature is only available when experimental support for instrumentation
|
||||
has been enabled by the ``CMAKE_EXPERIMENTAL_INSTRUMENTATION`` gate.
|
||||
|
||||
The CMake Instrumentation API allows for the collection of timing data, target
|
||||
information and system diagnostic information during the configure, generate,
|
||||
build, test and install steps for a CMake project.
|
||||
|
||||
12
Help/release/dev/instrumentation.rst
Normal file
12
Help/release/dev/instrumentation.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
instrumentation
|
||||
---------------
|
||||
|
||||
* :manual:`cmake-instrumentation(7)` introduces a new API for the collection of
|
||||
timing data, target information and system diagnostic information during the
|
||||
configure, generate, build, test and install steps for a CMake project.
|
||||
* When CMake instrumentation is enabled, instrumentation data will be sent
|
||||
as part of submissions to CDash.
|
||||
* CMake can generate Google Trace Event Format files to visualize
|
||||
instrumentation data.
|
||||
* The :command:`cmake_instrumentation` was added for adding project-level
|
||||
instrumentation queries.
|
||||
@@ -72,14 +72,6 @@ cmExperimental::FeatureData const LookupTable[] = {
|
||||
"meant only for experimentation and feedback to CMake developers.",
|
||||
{},
|
||||
cmExperimental::TryCompileCondition::Never },
|
||||
// Instrumentation
|
||||
{ "Instrumentation",
|
||||
"ec7aa2dc-b87f-45a3-8022-fe01c5f59984",
|
||||
"CMAKE_EXPERIMENTAL_INSTRUMENTATION",
|
||||
"CMake's support for collecting instrumentation data is experimental. It "
|
||||
"is meant only for experimentation and feedback to CMake developers.",
|
||||
{},
|
||||
cmExperimental::TryCompileCondition::Never },
|
||||
{ "GenerateSbom",
|
||||
"ca494ed3-b261-4205-a01f-603c95e4cae0",
|
||||
"CMAKE_EXPERIMENTAL_GENERATE_SBOM",
|
||||
|
||||
@@ -23,7 +23,6 @@ public:
|
||||
ExportPackageInfo,
|
||||
MappedPackageInfo,
|
||||
ExportBuildDatabase,
|
||||
Instrumentation,
|
||||
GenerateSbom,
|
||||
|
||||
Sentinel,
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "cmCMakePath.h"
|
||||
#include "cmCryptoHash.h"
|
||||
#include "cmExperimental.h"
|
||||
#include "cmFileLock.h"
|
||||
#include "cmFileLockResult.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
@@ -94,18 +93,13 @@ std::map<std::string, std::string> cmInstrumentation::cdashSnippetsMap = {
|
||||
cmInstrumentation::cmInstrumentation(std::string const& binary_dir,
|
||||
LoadQueriesAfter loadQueries)
|
||||
{
|
||||
std::string const uuid =
|
||||
cmExperimental::DataForFeature(cmExperimental::Feature::Instrumentation)
|
||||
.Uuid;
|
||||
this->binaryDir = binary_dir;
|
||||
this->timingDirv1 =
|
||||
cmStrCat(this->binaryDir, "/.cmake/instrumentation-", uuid, "/v1");
|
||||
this->timingDirv1 = cmStrCat(this->binaryDir, "/.cmake/instrumentation/v1");
|
||||
this->cdashDir = cmStrCat(this->timingDirv1, "/cdash");
|
||||
this->dataDir = cmStrCat(this->timingDirv1, "/data");
|
||||
if (cm::optional<std::string> configDir =
|
||||
cmSystemTools::GetCMakeConfigDirectory()) {
|
||||
this->userTimingDirv1 =
|
||||
cmStrCat(configDir.value(), "/instrumentation-", uuid, "/v1");
|
||||
this->userTimingDirv1 = cmStrCat(configDir.value(), "/instrumentation/v1");
|
||||
}
|
||||
if (loadQueries == LoadQueriesAfter::Yes) {
|
||||
this->LoadQueries();
|
||||
@@ -131,23 +125,15 @@ void cmInstrumentation::CheckCDashVariable()
|
||||
std::string envVal;
|
||||
if (cmSystemTools::GetEnv("CTEST_USE_INSTRUMENTATION", envVal) &&
|
||||
!cmIsOff(envVal)) {
|
||||
if (cmSystemTools::GetEnv("CTEST_EXPERIMENTAL_INSTRUMENTATION", envVal)) {
|
||||
std::string const uuid = cmExperimental::DataForFeature(
|
||||
cmExperimental::Feature::Instrumentation)
|
||||
.Uuid;
|
||||
if (envVal == uuid) {
|
||||
std::set<cmInstrumentationQuery::Option> options_ = {
|
||||
cmInstrumentationQuery::Option::CDashSubmit
|
||||
};
|
||||
if (cmSystemTools::GetEnv("CTEST_USE_VERBOSE_INSTRUMENTATION",
|
||||
envVal) &&
|
||||
!cmIsOff(envVal)) {
|
||||
options_.insert(cmInstrumentationQuery::Option::CDashVerbose);
|
||||
}
|
||||
std::set<cmInstrumentationQuery::Hook> hooks_;
|
||||
this->WriteJSONQuery(options_, hooks_, {});
|
||||
}
|
||||
std::set<cmInstrumentationQuery::Option> options_ = {
|
||||
cmInstrumentationQuery::Option::CDashSubmit
|
||||
};
|
||||
if (cmSystemTools::GetEnv("CTEST_USE_VERBOSE_INSTRUMENTATION", envVal) &&
|
||||
!cmIsOff(envVal)) {
|
||||
options_.insert(cmInstrumentationQuery::Option::CDashVerbose);
|
||||
}
|
||||
std::set<cmInstrumentationQuery::Hook> hooks_;
|
||||
this->WriteJSONQuery(options_, hooks_, {});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#include "cmArgumentParser.h"
|
||||
#include "cmArgumentParserTypes.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmExperimental.h"
|
||||
#include "cmInstrumentation.h"
|
||||
#include "cmInstrumentationQuery.h"
|
||||
#include "cmList.h"
|
||||
@@ -68,14 +67,6 @@ std::function<bool(std::string const&, E&)> EnumParser(
|
||||
bool cmInstrumentationCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
// if (status->GetMakefile().GetPropertyKeys) {
|
||||
if (!cmExperimental::HasSupportEnabled(
|
||||
status.GetMakefile(), cmExperimental::Feature::Instrumentation)) {
|
||||
status.SetError(
|
||||
"requires the experimental Instrumentation flag to be enabled");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.empty()) {
|
||||
status.SetError("must be called with arguments.");
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply)
|
||||
set(RunCMake_TEST_FAILED "Failed to read FileAPI query from user config directory")
|
||||
endif()
|
||||
if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/.cmake/instrumentation-ec7aa2dc-b87f-45a3-8022-fe01c5f59984/v1/data)
|
||||
if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/.cmake/instrumentation/v1/data)
|
||||
set(RunCMake_TEST_FAILED "Failed to read Instrumentation query from user config directory")
|
||||
endif()
|
||||
|
||||
@@ -12,7 +12,6 @@ function(instrument test)
|
||||
"INSTALL_PARALLEL"
|
||||
"TEST"
|
||||
"WORKFLOW"
|
||||
"EXPERIMENTAL_WARNING"
|
||||
"COPY_QUERIES"
|
||||
"COPY_QUERIES_GENERATED"
|
||||
"STATIC_QUERY"
|
||||
@@ -26,8 +25,7 @@ function(instrument test)
|
||||
)
|
||||
cmake_parse_arguments(ARGS "${OPTIONS}" "CHECK_SCRIPT;CONFIGURE_ARG" "" ${ARGN})
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test})
|
||||
set(uuid "ec7aa2dc-b87f-45a3-8022-fe01c5f59984")
|
||||
set(v1 ${RunCMake_TEST_BINARY_DIR}/.cmake/instrumentation-${uuid}/v1)
|
||||
set(v1 ${RunCMake_TEST_BINARY_DIR}/.cmake/instrumentation/v1)
|
||||
set(v1 ${v1} PARENT_SCOPE)
|
||||
set(query_dir ${CMAKE_CURRENT_LIST_DIR}/query)
|
||||
configure_file(${RunCMake_SOURCE_DIR}/initial.cmake.in ${RunCMake_BINARY_DIR}/initial.cmake)
|
||||
@@ -93,9 +91,6 @@ function(instrument test)
|
||||
|
||||
# Configure Test Case
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
if (NOT ARGS_EXPERIMENTAL_WARNING)
|
||||
list(APPEND ARGS_CONFIGURE_ARG "-Wno-dev")
|
||||
endif()
|
||||
if (ARGS_FAIL)
|
||||
list(APPEND ARGS_CONFIGURE_ARG "-DFAIL=ON")
|
||||
endif()
|
||||
@@ -121,7 +116,7 @@ function(instrument test)
|
||||
COPYONLY
|
||||
)
|
||||
endforeach()
|
||||
set(v1 ${RunCMake_TEST_BINARY_DIR}/build/.cmake/instrumentation-${uuid}/v1)
|
||||
set(v1 ${RunCMake_TEST_BINARY_DIR}/build/.cmake/instrumentation/v1)
|
||||
run_cmake_command(${test}-workflow ${CMAKE_COMMAND} --workflow default)
|
||||
set(ARGS_NO_CONFIGURE TRUE)
|
||||
endif()
|
||||
@@ -231,9 +226,6 @@ instrument(cmake-command-data
|
||||
COPY_QUERIES BUILD INSTALL TEST DYNAMIC_QUERY
|
||||
CHECK_SCRIPT check-data-dir.cmake
|
||||
)
|
||||
instrument(cmake-command-experimental-warning
|
||||
EXPERIMENTAL_WARNING
|
||||
)
|
||||
instrument(cmake-command-bad-api-version)
|
||||
instrument(cmake-command-bad-data-version)
|
||||
instrument(cmake-command-missing-version)
|
||||
|
||||
@@ -3,4 +3,4 @@ CMake Error at [^
|
||||
cmake_instrumentation given an unsupported API_VERSION "0" \(the only
|
||||
currently supported version is 1\)\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:6 \(include\)
|
||||
CMakeLists\.txt:5 \(include\)
|
||||
|
||||
@@ -2,4 +2,4 @@ CMake Error at [^
|
||||
]* \(cmake_instrumentation\):
|
||||
cmake_instrumentation given unknown argument "UNKNOWN_ARG"\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:6 \(include\)
|
||||
CMakeLists\.txt:5 \(include\)
|
||||
|
||||
@@ -2,4 +2,4 @@ CMake Error at [^
|
||||
]*\(cmake_instrumentation\):
|
||||
cmake_instrumentation given a non-integer DATA_VERSION\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:6 \(include\)
|
||||
CMakeLists\.txt:5 \(include\)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
CMake Warning \(dev\) at .*
|
||||
CMake's support for collecting instrumentation data is experimental. It is
|
||||
meant only for experimentation and feedback to CMake developers.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:6 \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
@@ -1,4 +0,0 @@
|
||||
CMake Warning \(dev\) at .*
|
||||
CMake's support for collecting instrumentation data is experimental. It is
|
||||
meant only for experimentation and feedback to CMake developers.
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
@@ -3,4 +3,4 @@ CMake Error at [^
|
||||
cmake_instrumentation given an unsupported DATA_VERSION "" \(the only
|
||||
currently supported version is 1\)\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:6 \(include\)
|
||||
CMakeLists\.txt:5 \(include\)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
set(CMAKE_EXPERIMENTAL_INSTRUMENTATION @uuid@)
|
||||
cmake_instrumentation(
|
||||
API_VERSION 1
|
||||
DATA_VERSION 1
|
||||
|
||||
@@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.30)
|
||||
project(instrumentation)
|
||||
enable_testing()
|
||||
if (EXISTS ${INSTRUMENT_COMMAND_FILE})
|
||||
set(CMAKE_EXPERIMENTAL_INSTRUMENTATION "ec7aa2dc-b87f-45a3-8022-fe01c5f59984")
|
||||
include(${INSTRUMENT_COMMAND_FILE})
|
||||
endif()
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ add_executable(main main.c)
|
||||
add_test(NAME main COMMAND main)
|
||||
|
||||
if($ENV{USE_INSTRUMENTATION_CMD})
|
||||
set(CMAKE_EXPERIMENTAL_INSTRUMENTATION "ec7aa2dc-b87f-45a3-8022-fe01c5f59984")
|
||||
cmake_instrumentation(
|
||||
API_VERSION 1
|
||||
DATA_VERSION 1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
set(timingDir "${RunCMake_TEST_BINARY_DIR}/.cmake/instrumentation-ec7aa2dc-b87f-45a3-8022-fe01c5f59984/v1")
|
||||
set(timingDir "${RunCMake_TEST_BINARY_DIR}/.cmake/instrumentation/v1")
|
||||
file(READ "${timingDir}/query/generated/query-0.json" jsonData)
|
||||
string(JSON options GET "${jsonData}" options)
|
||||
if (options MATCHES cdashVerbose AND NOT ${RunCMake_USE_VERBOSE_INSTRUMENTATION})
|
||||
|
||||
@@ -10,10 +10,8 @@ function(run_InstrumentationInCTestXML CASE_NAME)
|
||||
set(RunCMake_USE_VERBOSE_INSTRUMENTATION 0)
|
||||
endif()
|
||||
if(ARGS_USE_INSTRUMENTATION_ENV_VARS)
|
||||
set(ENV{CTEST_EXPERIMENTAL_INSTRUMENTATION} "ec7aa2dc-b87f-45a3-8022-fe01c5f59984")
|
||||
set(ENV{CTEST_USE_INSTRUMENTATION} "1")
|
||||
else()
|
||||
set(ENV{CTEST_EXPERIMENTAL_INSTRUMENTATION} "0")
|
||||
set(ENV{CTEST_USE_INSTRUMENTATION} "0")
|
||||
endif()
|
||||
if (ARGS_USE_INSTRUMENTATION_CMD)
|
||||
|
||||
@@ -38,7 +38,6 @@ file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyThirdPartyDependency"
|
||||
if(USE_INSTRUMENTATION)
|
||||
set(CASE_CMAKELISTS_SUFFIX_CODE [[
|
||||
add_subdirectory(MyThirdPartyDependency)
|
||||
set(CMAKE_EXPERIMENTAL_INSTRUMENTATION "ec7aa2dc-b87f-45a3-8022-fe01c5f59984")
|
||||
cmake_instrumentation(DATA_VERSION 1 API_VERSION 1)
|
||||
]])
|
||||
set(RunCMake-check-file CTestScriptVariableCommandLine-check.cmake)
|
||||
|
||||
Reference in New Issue
Block a user