From d94b23885a6646571904c9f41599ffde487d6314 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 14 Jun 2021 15:06:34 -0400 Subject: cmNinjaTargetGenerator: Simplify scan rule response file selection Since commit 33a8e0bb09 (cmNinjaTargetGenerator: Simplify scan rule depfile selection, 2020-11-06, v3.20.0-rc1~516^2~1), the `$out` of the scan rule always matches our `.rsp` file selection, so use `$out.rsp`. --- Source/cmNinjaTargetGenerator.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 6080270..6543485 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1118,11 +1118,7 @@ cmNinjaBuild GetScanBuildStatement(const std::string& ruleName, { cmNinjaBuild scanBuild(ruleName); - if (!ppFileName.empty()) { - scanBuild.RspFile = cmStrCat(ppFileName, ".rsp"); - } else { - scanBuild.RspFile = "$out.rsp"; - } + scanBuild.RspFile = "$out.rsp"; if (compilePP) { // Move compilation dependencies to the scan/preprocessing build statement. -- cgit v0.12 From 1dd9c4ab6fa9ced2276433dbce081d9cff838d1e Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 14 Jun 2021 15:11:20 -0400 Subject: cmNinjaTargetGenerator: Clarify GetScanBuildStatement condition Use the `compilePP` variable directly rather than relying on callers to make `compilePP == !ppFileName.empty()`. --- Source/cmNinjaTargetGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 6543485..c8dc304 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1162,7 +1162,7 @@ cmNinjaBuild GetScanBuildStatement(const std::string& ruleName, scanBuild.Variables["DYNDEP_INTERMEDIATE_FILE"] = ddiFile; // Outputs of the scan/preprocessor build statement. - if (!ppFileName.empty()) { + if (compilePP) { scanBuild.Outputs.push_back(ppFileName); scanBuild.ImplicitOuts.push_back(ddiFile); } else { -- cgit v0.12 From 312ced6547e789447f518ea996215ddd1741c80a Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 14 Jun 2021 15:15:39 -0400 Subject: cmNinjaTargetGenerator: Fix scan rule PREPROCESSED_SOURCE placeholder When running the module dependencies scan tool for for a language that does not compile the preprocessed output, we do not actually put the preprocessed output in the build graph. However, the value of `CMAKE_EXPERIMENTAL__SCANDEP_SOURCE` may reference the placeholder for the preprocessed source. Populate the placeholder to keep the file out of the way. In particular, do not clobber the `.ddi` file. --- Source/cmNinjaTargetGenerator.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c8dc304..609848b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -536,7 +536,7 @@ std::string GetScanCommand(const std::string& cmakeCmd, const std::string& tdi, // Helper function to create dependency scanning rule that may or may // not perform explicit preprocessing too. cmNinjaRule GetScanRule( - const std::string& ruleName, + std::string const& ruleName, std::string const& ppFileName, cmRulePlaceholderExpander::RuleVariables const& vars, const std::string& responseFlag, const std::string& flags, cmRulePlaceholderExpander* const rulePlaceholderExpander, @@ -553,7 +553,7 @@ cmNinjaRule GetScanRule( scanVars.CMTargetType = vars.CMTargetType; scanVars.Language = vars.Language; scanVars.Object = "$OBJ_FILE"; - scanVars.PreprocessedSource = "$out"; + scanVars.PreprocessedSource = ppFileName.c_str(); scanVars.DynDepFile = "$DYNDEP_INTERMEDIATE_FILE"; scanVars.DependencyFile = rule.DepFile.c_str(); scanVars.DependencyTarget = "$out"; @@ -653,8 +653,10 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, { std::vector scanCommands; std::string scanRuleName; + std::string ppFileName; if (compilationPreprocesses) { scanRuleName = this->LanguageScanRule(lang, config); + ppFileName = "$PREPROCESSED_OUTPUT_FILE"; std::string const& scanCommand = mf->GetRequiredDefinition( cmStrCat("CMAKE_EXPERIMENTAL_", lang, "_SCANDEP_SOURCE")); cmExpandList(scanCommand, scanCommands); @@ -663,6 +665,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, } } else { scanRuleName = this->LanguagePreprocessAndScanRule(lang, config); + ppFileName = "$out"; std::string const& ppCommmand = mf->GetRequiredDefinition( cmStrCat("CMAKE_", lang, "_PREPROCESS_SOURCE")); cmExpandList(ppCommmand, scanCommands); @@ -673,9 +676,10 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, "$DYNDEP_INTERMEDIATE_FILE")); } - auto scanRule = GetScanRule( - scanRuleName, vars, responseFlag, flags, rulePlaceholderExpander.get(), - this->GetLocalGenerator(), std::move(scanCommands), config); + auto scanRule = + GetScanRule(scanRuleName, ppFileName, vars, responseFlag, flags, + rulePlaceholderExpander.get(), this->GetLocalGenerator(), + std::move(scanCommands), config); scanRule.Comment = cmStrCat("Rule for generating ", lang, " dependencies."); @@ -704,7 +708,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, GetScanCommand(cmakeCmd, tdi, lang, "$in", "$out")); auto scanRule = GetScanRule( - scanRuleName, vars, "", flags, rulePlaceholderExpander.get(), + scanRuleName, "", vars, "", flags, rulePlaceholderExpander.get(), this->GetLocalGenerator(), std::move(scanCommands), config); // Write the rule for generating dependencies for the given language. @@ -1167,6 +1171,7 @@ cmNinjaBuild GetScanBuildStatement(const std::string& ruleName, scanBuild.ImplicitOuts.push_back(ddiFile); } else { scanBuild.Outputs.push_back(ddiFile); + scanBuild.Variables["PREPROCESSED_OUTPUT_FILE"] = ppFileName; } // Scanning always uses a depfile for preprocessor dependencies. @@ -1362,6 +1367,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( this->GetPreprocessedFilePath(source, config)); } else { scanRuleName = this->LanguageScanRule(language, config); + ppFileName = cmStrCat(objectFileName, ".ddi.i"); } cmNinjaBuild ppBuild = GetScanBuildStatement( -- cgit v0.12