Merge topic 'ninja-swift-cldeps-order'

9d7da095fd Ninja: Restore cmcldeps command-line ordering

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12270
This commit is contained in:
Brad King
2026-07-15 10:57:32 -04:00
committed by Kitware Robot
4 changed files with 40 additions and 7 deletions
+7 -7
View File
@@ -725,6 +725,7 @@ cmList ExpandRuleCommands(std::string const& command,
cmRulePlaceholderExpander::RuleVariables const& vars,
cmMakefile const* mf, std::string const& lang,
std::string const& launcher,
std::string const& cldeps,
cmLocalGenerator* localGenerator,
cmRulePlaceholderExpander* rulePlaceholderExpander)
{
@@ -735,6 +736,9 @@ cmList ExpandRuleCommands(std::string const& command,
commands.front().insert(0, "${CODE_CHECK}");
commands.front().insert(0, "${LAUNCHER}");
}
if (!commands.empty()) {
commands.front().insert(0, cldeps);
}
if (!extraCommands.empty()) {
commands.append(extraCommands);
}
@@ -1038,13 +1042,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(std::string const& lang,
std::string const cmdVar = this->GetCompileTemplateVar(lang);
std::string const& compileCmd = mf->GetRequiredDefinition(cmdVar);
cmList compileCmds = ExpandRuleCommands(compileCmd, vars, mf, lang, launcher,
this->GetLocalGenerator(),
cldeps, this->GetLocalGenerator(),
rulePlaceholderExpander.get());
if (!compileCmds.empty()) {
compileCmds.front().insert(0, cldeps);
}
rule.Command =
this->GetLocalGenerator()->BuildCommandLine(compileCmds, config, config);
@@ -1076,8 +1076,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(std::string const& lang,
emitModRule.Restat = "1";
cmList emitModCmds = ExpandRuleCommands(
*emitModCmdVal, emVars, mf, lang, launcher, this->GetLocalGenerator(),
rulePlaceholderExpander.get());
*emitModCmdVal, emVars, mf, lang, launcher, cldeps,
this->GetLocalGenerator(), rulePlaceholderExpander.get());
emitModRule.Command = this->GetLocalGenerator()->BuildCommandLine(
emitModCmds, config, config);
emitModRule.Comment = "Rule for emitting Swift .swiftmodule files.";
@@ -0,0 +1,21 @@
if(RunCMake_GENERATOR STREQUAL "Ninja")
set(rules_ninja "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/rules.ninja")
set(build_ninja "${RunCMake_TEST_BINARY_DIR}/build.ninja")
file(READ "${rules_ninja}" ninja_content)
file(READ "${build_ninja}" build_ninja_content)
if(NOT ninja_content MATCHES "command = \"[^\"]*ctest(\.exe)?\" --launch")
set(RunCMake_TEST_FAILED
"Expected compile command to use ctest --launch: ${ninja_content}"
)
return()
endif()
if(NOT build_ninja_content MATCHES "LAUNCHER = [^\n]*USED_LAUNCHER=1")
set(RunCMake_TEST_FAILED
"Expected compile command to include the compiler launcher"
)
return()
endif()
endif()
@@ -391,6 +391,9 @@ instrument(no-query
BUILD INSTALL TEST
CHECK_SCRIPT check-data-dir.cmake
)
if(RunCMake_GENERATOR STREQUAL "Ninja")
set(CHECK_NINJA_INSTRUMENT_ORDER 1)
endif()
instrument(disabled-test
BUILD TEST DISABLE_TEST
CHECK_SCRIPT check-data-dir.cmake
@@ -403,6 +406,7 @@ instrument(both-query
BUILD INSTALL TEST STATIC_QUERY DYNAMIC_QUERY CAPTURE_OUTPUT_QUERY
CHECK_SCRIPT check-data-dir.cmake
)
unset(CHECK_NINJA_INSTRUMENT_ORDER)
# Test cmake_instrumentation command
instrument(cmake-command
@@ -240,6 +240,14 @@ if (ARGS_BUILD AND NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/shell_redirect.out)
add_error("custom command with shell redirection did not run")
endif()
if (CHECK_NINJA_INSTRUMENT_ORDER)
set(rules_ninja "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/rules.ninja")
file(READ "${rules_ninja}" ninja_content)
if (NOT ninja_content MATCHES "command = \"[^\"]*ctest(\.exe)?\" --instrument")
add_error("Expected compile command to start with ctest --instrument")
endif()
endif()
# Look for build snippet, which may not appear immediately
if (ARGS_BUILD_MAKE_PROGRAM)
set(NUM_TRIES 30)