From e5e3f3d4ff79d27450618edb01890fc99f212d12 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Sun, 1 Dec 2013 23:16:06 +0100 Subject: [PATCH] CTest: filter /showIncludes output from ninja compile launcher Teach "ctest --launch" a new "--filter-prefix" option. Set it using the CMAKE_CL_SHOWINCLUDES_PREFIX value with the Ninja generator. --- Modules/CTestUseLaunchers.cmake | 28 +++++++++++++++++++++++++--- Source/CTest/cmCTestLaunch.cxx | 19 ++++++++++++++++++- Source/CTest/cmCTestLaunch.h | 1 + Source/cmLocalGenerator.cxx | 1 + Source/cmLocalGenerator.h | 1 + 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/Modules/CTestUseLaunchers.cmake b/Modules/CTestUseLaunchers.cmake index 2fab247eb5..c79119f954 100644 --- a/Modules/CTestUseLaunchers.cmake +++ b/Modules/CTestUseLaunchers.cmake @@ -46,9 +46,31 @@ if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja") endif() if(CTEST_USE_LAUNCHERS) - set(CTEST_LAUNCH_COMPILE "\"${CMAKE_CTEST_COMMAND}\" --launch --target-name --build-dir --output --source --language --") - set(CTEST_LAUNCH_LINK "\"${CMAKE_CTEST_COMMAND}\" --launch --target-name --build-dir --output --target-type --language --") - set(CTEST_LAUNCH_CUSTOM "\"${CMAKE_CTEST_COMMAND}\" --launch --target-name --build-dir --output --") + set(__launch_common_options + "--target-name --build-dir ") + + set(__launch_compile_options + "${__launch_common_options} --output --source --language ") + + set(__launch_link_options + "${__launch_common_options} --output --target-type --language ") + + set(__launch_custom_options + "${__launch_common_options} --output ") + + if("${CMAKE_GENERATOR}" MATCHES "Ninja") + set(__launch_compile_options "${__launch_compile_options} --filter-prefix ") + endif() + + set(CTEST_LAUNCH_COMPILE + "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_compile_options} --") + + set(CTEST_LAUNCH_LINK + "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_link_options} --") + + set(CTEST_LAUNCH_CUSTOM + "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_custom_options} --") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CTEST_LAUNCH_COMPILE}") set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CTEST_LAUNCH_LINK}") set_property(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "${CTEST_LAUNCH_CUSTOM}") diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 9831d02009..8e5fd78c85 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -64,7 +64,8 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv) DoingTargetName, DoingTargetType, DoingBuildDir, - DoingCount }; + DoingCount, + DoingFilterPrefix }; Doing doing = DoingNone; int arg0 = 0; for(int i=1; !arg0 && i < argc; ++i) @@ -98,6 +99,10 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv) { doing = DoingBuildDir; } + else if(strcmp(arg, "--filter-prefix") == 0) + { + doing = DoingFilterPrefix; + } else if(doing == DoingOutput) { this->OptionOutput = arg; @@ -132,6 +137,11 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv) this->OptionBuildDir = arg; doing = DoingNone; } + else if(doing == DoingFilterPrefix) + { + this->OptionFilterPrefix = arg; + doing = DoingNone; + } } // Extract the real command line. @@ -573,8 +583,15 @@ void cmCTestLaunch::DumpFileToXML(std::ostream& fxml, std::string line; const char* sep = ""; + while(cmSystemTools::GetLineFromStream(fin, line)) { + if(OptionFilterPrefix.size() && cmSystemTools::StringStartsWith( + line.c_str(), OptionFilterPrefix.c_str())) + { + continue; + } + fxml << sep << cmXMLSafe(line).Quotes(false); sep = "\n"; } diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index 7457e8357f..a86a9df74d 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -45,6 +45,7 @@ private: std::string OptionTargetName; std::string OptionTargetType; std::string OptionBuildDir; + std::string OptionFilterPrefix; bool ParseArguments(int argc, const char* const* argv); // The real command line appearing after launcher arguments. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index d26d6e9845..c3c529973c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -807,6 +807,7 @@ static const char* ruleReplaceVars[] = "CMAKE_CURRENT_BINARY_DIR", "CMAKE_RANLIB", "CMAKE_LINKER", + "CMAKE_CL_SHOWINCLUDES_PREFIX", 0 }; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 21700e908f..9a89f0f9fc 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -266,6 +266,7 @@ public: const char* Defines; const char* RuleLauncher; const char* DependencyFile; + const char* FilterPrefix; }; /** Set whether to treat conversions to SHELL as a link script shell. */