Commit e5e3f3d4 authored by Nils Gladitz's avatar Nils Gladitz Committed by Brad King

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.
parent 845cdbc6
......@@ -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 <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR> --output <OBJECT> --source <SOURCE> --language <LANGUAGE> --")
set(CTEST_LAUNCH_LINK "\"${CMAKE_CTEST_COMMAND}\" --launch --target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR> --output <TARGET> --target-type <TARGET_TYPE> --language <LANGUAGE> --")
set(CTEST_LAUNCH_CUSTOM "\"${CMAKE_CTEST_COMMAND}\" --launch --target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR> --output <OUTPUT> --")
set(__launch_common_options
"--target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR>")
set(__launch_compile_options
"${__launch_common_options} --output <OBJECT> --source <SOURCE> --language <LANGUAGE>")
set(__launch_link_options
"${__launch_common_options} --output <TARGET> --target-type <TARGET_TYPE> --language <LANGUAGE>")
set(__launch_custom_options
"${__launch_common_options} --output <OUTPUT>")
if("${CMAKE_GENERATOR}" MATCHES "Ninja")
set(__launch_compile_options "${__launch_compile_options} --filter-prefix <CMAKE_CL_SHOWINCLUDES_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}")
......
......@@ -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";
}
......
......@@ -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.
......
......@@ -807,6 +807,7 @@ static const char* ruleReplaceVars[] =
"CMAKE_CURRENT_BINARY_DIR",
"CMAKE_RANLIB",
"CMAKE_LINKER",
"CMAKE_CL_SHOWINCLUDES_PREFIX",
0
};
......
......@@ -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. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment