diff --git a/Help/manual/cmake-instrumentation.7.rst b/Help/manual/cmake-instrumentation.7.rst index 2a16a552d5..e20d8a69f3 100644 --- a/Help/manual/cmake-instrumentation.7.rst +++ b/Help/manual/cmake-instrumentation.7.rst @@ -236,11 +236,11 @@ Example: } In this example, after every ``cmake --build`` or ``cmake --install`` -invocation, an index file ``index-.json`` will be generated in +invocation, an index file ``index-.json`` will be generated in ``/.cmake/instrumentation/v1/data`` containing a list of data snippet files created since the previous indexing. The commands -``/usr/bin/python callback.py index-.json`` and -``/usr/bin/cmake -P callback.cmake arg index-.json`` will be executed in +``/usr/bin/python callback.py index-.json`` and +``/usr/bin/cmake -P callback.cmake arg index-.json`` will be executed in that order. The index file will contain the ``staticSystemInformation`` data and each snippet file listed in the index will contain the ``dynamicSystemInformation`` data. Once both callbacks have completed, the index @@ -275,7 +275,7 @@ the command executed. Additionally, snippet files are created for the following: These files remain in the build tree until after `Indexing`_ occurs and any user-specified `Callbacks`_ are executed. -Snippet files have a filename with the syntax ``--.json`` +Snippet files have a filename with the syntax ``--.json`` and contain the following data: ``version`` @@ -285,6 +285,9 @@ and contain the following data: ``command`` The full command executed. Excluded when ``role`` is ``build``. + ``workingDir`` + The working directory in which the ``command`` was executed. + ``result`` The exit-value of the command, an integer. @@ -450,14 +453,14 @@ Example: "buildDir": "", "dataDir": "/.cmake/instrumentation/v1/data", "snippets": [ - "configure--.json", - "generate--.json", - "compile--.json", - "compile--.json", - "link--.json", - "install--.json", - "ctest--.json", - "test--.json", - "test--.json", + "configure--.json", + "generate--.json", + "compile--.json", + "compile--.json", + "link--.json", + "install--.json", + "ctest--.json", + "test--.json", + "test--.json", ] } diff --git a/Source/cmInstrumentation.cxx b/Source/cmInstrumentation.cxx index 35cb234888..4f92bfbde1 100644 --- a/Source/cmInstrumentation.cxx +++ b/Source/cmInstrumentation.cxx @@ -409,6 +409,7 @@ std::string cmInstrumentation::InstrumentTest( root["testName"] = name; root["result"] = static_cast(result); root["config"] = config; + root["workingDir"] = cmSystemTools::GetLogicalWorkingDirectory(); // Post-Command this->InsertTimingData(root, steadyStart, systemStart); @@ -417,9 +418,11 @@ std::string cmInstrumentation::InstrumentTest( this->InsertDynamicSystemInformation(root, "after"); } - std::string file_name = - cmStrCat("test-", this->ComputeSuffixHash(command_str), - this->ComputeSuffixTime(), ".json"); + cmsys::SystemInformation info; + std::string file_name = cmStrCat( + "test-", + this->ComputeSuffixHash(cmStrCat(command_str, info.GetProcessId())), + this->ComputeSuffixTime(), ".json"); this->WriteInstrumentationJson(root, "data", file_name); return file_name; } @@ -534,11 +537,14 @@ int cmInstrumentation::InstrumentCommand( } } root["role"] = command_type; + root["workingDir"] = cmSystemTools::GetLogicalWorkingDirectory(); // Write Json - std::string const& file_name = - cmStrCat(command_type, "-", this->ComputeSuffixHash(command_str), - this->ComputeSuffixTime(), ".json"); + cmsys::SystemInformation info; + std::string const& file_name = cmStrCat( + command_type, "-", + this->ComputeSuffixHash(cmStrCat(command_str, info.GetProcessId())), + this->ComputeSuffixTime(), ".json"); this->WriteInstrumentationJson(root, "data", file_name); return ret; } diff --git a/Tests/RunCMake/Instrumentation/verify-snippet.cmake b/Tests/RunCMake/Instrumentation/verify-snippet.cmake index 33f9414dee..3eaafe8937 100644 --- a/Tests/RunCMake/Instrumentation/verify-snippet.cmake +++ b/Tests/RunCMake/Instrumentation/verify-snippet.cmake @@ -31,6 +31,7 @@ function(snippet_has_fields snippet contents) get_filename_component(filename "${snippet}" NAME) has_key("${snippet}" "${contents}" role) has_key("${snippet}" "${contents}" result) + has_key("${snippet}" "${contents}" workingDir) if (NOT filename MATCHES "^build-*") has_key("${snippet}" "${contents}" command) endif()