summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-01-17 20:25:08 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-01-22 15:26:21 (GMT)
commit110037369d9be6c346f3de5074bb2e4d47c7e36c (patch)
tree147b87074c2a59c604ef191a07f93357af1b5b6a
parente62a3414f76d443c271f4927f6f88fad12593646 (diff)
downloadCMake-110037369d9be6c346f3de5074bb2e4d47c7e36c.zip
CMake-110037369d9be6c346f3de5074bb2e4d47c7e36c.tar.gz
CMake-110037369d9be6c346f3de5074bb2e4d47c7e36c.tar.bz2
Refactor: Split Ninja files into impl-<Config>.ninja and build-<Config>.ninja
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx143
-rw-r--r--Source/cmGlobalNinjaGenerator.h33
-rw-r--r--Source/cmLocalNinjaGenerator.cxx10
-rw-r--r--Source/cmLocalNinjaGenerator.h2
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx10
-rw-r--r--Source/cmNinjaTargetGenerator.cxx30
-rw-r--r--Source/cmNinjaTargetGenerator.h2
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.cxx2
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-all-ninja-check.cmake49
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-minsizerel-ninja-check.cmake41
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-ninja-check.cmake49
12 files changed, 308 insertions, 66 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index da53d9a..28b1cb4 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -293,7 +293,7 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild(
if (config.empty()) {
this->WriteBuild(*this->GetCommonFileStream(), build);
} else {
- this->WriteBuild(*this->GetConfigFileStream(config), build);
+ this->WriteBuild(*this->GetImplFileStream(config), build);
}
}
@@ -324,7 +324,7 @@ void cmGlobalNinjaGenerator::WriteMacOSXContentBuild(std::string input,
cmNinjaBuild build("COPY_OSX_CONTENT");
build.Outputs.push_back(std::move(output));
build.ExplicitDeps.push_back(std::move(input));
- this->WriteBuild(*this->GetConfigFileStream(config), build);
+ this->WriteBuild(*this->GetImplFileStream(config), build);
}
}
@@ -518,6 +518,7 @@ void cmGlobalNinjaGenerator::Generate()
if (cmSystemTools::GetErrorOccuredFlag()) {
this->RulesFileStream->setstate(std::ios::failbit);
for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs()) {
+ this->GetImplFileStream(config)->setstate(std::ios::failbit);
this->GetConfigFileStream(config)->setstate(std::ios::failbit);
}
this->GetCommonFileStream()->setstate(std::ios::failbit);
@@ -527,10 +528,6 @@ void cmGlobalNinjaGenerator::Generate()
this->CloseRulesFileStream();
this->CloseBuildFileStreams();
- if (!this->WriteDefaultBuildFile()) {
- return;
- }
-
auto run_ninja_tool = [this](std::vector<char const*> const& args) {
std::vector<std::string> command;
command.push_back(this->NinjaCommand);
@@ -1208,7 +1205,7 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
}
this->WriteBuild(this->EnableCrossConfigBuild()
? os
- : *this->GetConfigFileStream(ta.second.Config),
+ : *this->GetImplFileStream(ta.second.Config),
build);
}
@@ -1233,6 +1230,29 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
this->WriteBuild(*this->GetConfigFileStream(config), build);
}
}
+
+ auto const* defaultConfig = this->GetDefaultBuildType();
+ if (defaultConfig) {
+ std::string config = defaultConfig;
+ for (auto const& ta : this->Configs[config].TargetAliases) {
+ // Don't write ambiguous aliases.
+ if (!ta.second.GeneratorTarget) {
+ continue;
+ }
+
+ // Don't write alias if there is a already a custom command with
+ // matching output
+ if (this->HasCustomCommandOutput(ta.first)) {
+ continue;
+ }
+
+ build.Outputs.front() = ta.first;
+ build.ExplicitDeps.clear();
+ this->AppendTargetOutputs(ta.second.GeneratorTarget,
+ build.ExplicitDeps, config);
+ this->WriteBuild(*this->GetDefaultFileStream(), build);
+ }
+ }
}
}
@@ -1276,10 +1296,9 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
}
}
// Write target
- this->WriteBuild(this->EnableCrossConfigBuild()
- ? os
- : *this->GetConfigFileStream(config),
- build);
+ this->WriteBuild(
+ this->EnableCrossConfigBuild() ? os : *this->GetImplFileStream(config),
+ build);
}
// Add shortcut target
@@ -1291,6 +1310,16 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
this->ConvertToNinjaPath(currentBinaryDir + "/all");
this->WriteBuild(*this->GetConfigFileStream(config), build);
}
+
+ auto const* defaultConfig = this->GetDefaultBuildType();
+ if (defaultConfig) {
+ std::string config = defaultConfig;
+ build.ExplicitDeps = { this->BuildAlias(
+ this->ConvertToNinjaPath(currentBinaryDir + "/all"), config) };
+ build.Outputs.front() =
+ this->ConvertToNinjaPath(currentBinaryDir + "/all");
+ this->WriteBuild(*this->GetDefaultFileStream(), build);
+ }
}
// Add target for all configs
@@ -1442,6 +1471,10 @@ void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os)
for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs()) {
this->WriteTargetDefault(*this->GetConfigFileStream(config));
}
+
+ if (this->GetDefaultBuildType()) {
+ this->WriteTargetDefault(*this->GetDefaultFileStream());
+ }
}
void cmGlobalNinjaGenerator::WriteTargetDefault(std::ostream& os)
@@ -1734,9 +1767,10 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
}
if (this->IsMultiConfig()) {
build.Variables["FILE_ARG"] = cmStrCat(
- "-f ", cmGlobalNinjaMultiGenerator::GetNinjaFilename(fileConfig));
+ "-f ",
+ cmGlobalNinjaMultiGenerator::GetNinjaImplFilename(fileConfig));
}
- this->WriteBuild(*this->GetConfigFileStream(fileConfig), build);
+ this->WriteBuild(*this->GetImplFileStream(fileConfig), build);
}
}
@@ -1754,8 +1788,9 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
for (auto const& fileConfig : configs) {
build.Variables["FILE_ARG"] = cmStrCat(
- "-f ", cmGlobalNinjaMultiGenerator::GetNinjaFilename(fileConfig));
- this->WriteBuild(*this->GetConfigFileStream(fileConfig), build);
+ "-f ",
+ cmGlobalNinjaMultiGenerator::GetNinjaImplFilename(fileConfig));
+ this->WriteBuild(*this->GetImplFileStream(fileConfig), build);
}
}
}
@@ -1771,6 +1806,14 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
this->NinjaOutputPath(this->GetCleanTargetName()), config);
this->WriteBuild(*this->GetConfigFileStream(config), build);
}
+
+ auto const* defaultConfig = this->GetDefaultBuildType();
+ if (defaultConfig) {
+ std::string config = defaultConfig;
+ build.ExplicitDeps.front() = this->BuildAlias(
+ this->NinjaOutputPath(this->GetCleanTargetName()), config);
+ this->WriteBuild(*this->GetDefaultFileStream(), build);
+ }
}
// Write byproducts
@@ -2343,21 +2386,45 @@ bool cmGlobalNinjaMultiGenerator::OpenBuildFileStreams()
return false;
}
+ auto const* defaultConfig = this->GetDefaultBuildType();
+ if (defaultConfig) {
+ if (!this->OpenFileStream(this->DefaultFileStream, NINJA_BUILD_FILE)) {
+ return false;
+ }
+ *this->DefaultFileStream
+ << "# This file is a convenience file generated by\n"
+ << "# CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE.\n\n"
+ << "include " << GetNinjaImplFilename(defaultConfig) << "\n\n";
+ }
+
// Write a comment about this file.
*this->CommonFileStream
<< "# This file contains build statements common to all "
"configurations.\n\n";
for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs()) {
- if (!this->OpenFileStream(this->ConfigFileStreams[config],
- GetNinjaFilename(config))) {
+ // Open impl file.
+ if (!this->OpenFileStream(this->ImplFileStreams[config],
+ GetNinjaImplFilename(config))) {
return false;
}
// Write a comment about this file.
- *this->ConfigFileStreams[config]
+ *this->ImplFileStreams[config]
<< "# This file contains build statements specific to the \"" << config
<< "\"\n# configuration.\n\n";
+
+ // Open config file.
+ if (!this->OpenFileStream(this->ConfigFileStreams[config],
+ GetNinjaConfigFilename(config))) {
+ return false;
+ }
+
+ // Write a comment about this file.
+ *this->ConfigFileStreams[config]
+ << "# This file contains aliases specific to the \"" << config
+ << "\"\n# configuration.\n\n"
+ << "include " << GetNinjaImplFilename(config) << "\n\n";
}
return true;
@@ -2371,7 +2438,17 @@ void cmGlobalNinjaMultiGenerator::CloseBuildFileStreams()
cmSystemTools::Error("Common file stream was not open.");
}
+ if (this->DefaultFileStream) {
+ this->DefaultFileStream.reset();
+ } // No error if it wasn't open
+
for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs()) {
+ if (this->ImplFileStreams[config]) {
+ this->ImplFileStreams[config].reset();
+ } else {
+ cmSystemTools::Error(
+ cmStrCat("Impl file stream for \"", config, "\" was not open."));
+ }
if (this->ConfigFileStreams[config]) {
this->ConfigFileStreams[config].reset();
} else {
@@ -2385,10 +2462,17 @@ void cmGlobalNinjaMultiGenerator::AppendNinjaFileArgument(
GeneratedMakeCommand& command, const std::string& config) const
{
command.Add("-f");
- command.Add(GetNinjaFilename(config));
+ command.Add(GetNinjaConfigFilename(config));
+}
+
+std::string cmGlobalNinjaMultiGenerator::GetNinjaImplFilename(
+ const std::string& config)
+{
+ return cmStrCat("CMakeFiles/impl-", config,
+ cmGlobalNinjaMultiGenerator::NINJA_FILE_EXTENSION);
}
-std::string cmGlobalNinjaMultiGenerator::GetNinjaFilename(
+std::string cmGlobalNinjaMultiGenerator::GetNinjaConfigFilename(
const std::string& config)
{
return cmStrCat("build-", config,
@@ -2399,7 +2483,8 @@ void cmGlobalNinjaMultiGenerator::AddRebuildManifestOutputs(
cmNinjaDeps& outputs) const
{
for (auto const& config : this->Makefiles.front()->GetGeneratorConfigs()) {
- outputs.push_back(this->NinjaOutputPath(GetNinjaFilename(config)));
+ outputs.push_back(this->NinjaOutputPath(GetNinjaImplFilename(config)));
+ outputs.push_back(this->NinjaOutputPath(GetNinjaConfigFilename(config)));
}
if (this->Makefiles.front()->GetDefinition(
"CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE")) {
@@ -2417,20 +2502,8 @@ void cmGlobalNinjaMultiGenerator::GetQtAutoGenConfigs(
}
}
-bool cmGlobalNinjaMultiGenerator::WriteDefaultBuildFile()
+const char* cmGlobalNinjaMultiGenerator::GetDefaultBuildType() const
{
- auto const* defaultConfig = this->Makefiles.front()->GetDefinition(
+ return this->Makefiles.front()->GetDefinition(
"CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE");
- if (defaultConfig) {
- std::unique_ptr<cmGeneratedFileStream> defaultStream;
- if (!this->OpenFileStream(defaultStream, NINJA_BUILD_FILE)) {
- return false;
- }
- *defaultStream << "# This file is a convenience file generated by\n"
- << "# CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE.\n\n"
- << "include " << this->GetNinjaFilename(defaultConfig)
- << "\n";
- }
-
- return true;
}
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 3545f1e..0410b91 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -208,12 +208,23 @@ public:
}
const char* GetCleanTargetName() const override { return "clean"; }
+ virtual cmGeneratedFileStream* GetImplFileStream(
+ const std::string& /*config*/) const
+ {
+ return this->BuildFileStream.get();
+ }
+
virtual cmGeneratedFileStream* GetConfigFileStream(
const std::string& /*config*/) const
{
return this->BuildFileStream.get();
}
+ virtual cmGeneratedFileStream* GetDefaultFileStream() const
+ {
+ return this->BuildFileStream.get();
+ }
+
virtual cmGeneratedFileStream* GetCommonFileStream() const
{
return this->BuildFileStream.get();
@@ -397,6 +408,8 @@ public:
bool EnableCrossConfigBuild() const;
+ virtual const char* GetDefaultBuildType() const { return nullptr; }
+
protected:
void Generate() override;
@@ -404,7 +417,6 @@ protected:
virtual bool OpenBuildFileStreams();
virtual void CloseBuildFileStreams();
- virtual bool WriteDefaultBuildFile() { return true; }
bool OpenFileStream(std::unique_ptr<cmGeneratedFileStream>& stream,
const std::string& name);
@@ -573,12 +585,23 @@ public:
std::string ExpandCFGIntDir(const std::string& str,
const std::string& config) const override;
+ cmGeneratedFileStream* GetImplFileStream(
+ const std::string& config) const override
+ {
+ return this->ImplFileStreams.at(config).get();
+ }
+
cmGeneratedFileStream* GetConfigFileStream(
const std::string& config) const override
{
return this->ConfigFileStreams.at(config).get();
}
+ cmGeneratedFileStream* GetDefaultFileStream() const override
+ {
+ return this->DefaultFileStream.get();
+ }
+
cmGeneratedFileStream* GetCommonFileStream() const override
{
return this->CommonFileStream.get();
@@ -587,13 +610,14 @@ public:
void AppendNinjaFileArgument(GeneratedMakeCommand& command,
const std::string& config) const override;
- static std::string GetNinjaFilename(const std::string& config);
+ static std::string GetNinjaImplFilename(const std::string& config);
+ static std::string GetNinjaConfigFilename(const std::string& config);
void AddRebuildManifestOutputs(cmNinjaDeps& outputs) const override;
void GetQtAutoGenConfigs(std::vector<std::string>& configs) const override;
- bool WriteDefaultBuildFile() override;
+ const char* GetDefaultBuildType() const override;
protected:
bool OpenBuildFileStreams() override;
@@ -601,8 +625,11 @@ protected:
private:
std::map<std::string, std::unique_ptr<cmGeneratedFileStream>>
+ ImplFileStreams;
+ std::map<std::string, std::unique_ptr<cmGeneratedFileStream>>
ConfigFileStreams;
std::unique_ptr<cmGeneratedFileStream> CommonFileStream;
+ std::unique_ptr<cmGeneratedFileStream> DefaultFileStream;
};
#endif // ! cmGlobalNinjaGenerator_h
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 6967097..be1dd0d 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -64,7 +64,7 @@ void cmLocalNinjaGenerator::Generate()
if (this->GetGlobalGenerator()->IsMultiConfig()) {
for (auto const& config : this->GetConfigNames()) {
- this->WriteProcessedMakefile(this->GetConfigFileStream(config));
+ this->WriteProcessedMakefile(this->GetImplFileStream(config));
}
}
this->WriteProcessedMakefile(this->GetCommonFileStream());
@@ -154,10 +154,10 @@ std::string cmLocalNinjaGenerator::ConvertToIncludeReference(
// Private methods.
-cmGeneratedFileStream& cmLocalNinjaGenerator::GetConfigFileStream(
+cmGeneratedFileStream& cmLocalNinjaGenerator::GetImplFileStream(
const std::string& config) const
{
- return *this->GetGlobalNinjaGenerator()->GetConfigFileStream(config);
+ return *this->GetGlobalNinjaGenerator()->GetImplFileStream(config);
}
cmGeneratedFileStream& cmLocalNinjaGenerator::GetCommonFileStream() const
@@ -186,7 +186,7 @@ void cmLocalNinjaGenerator::WriteBuildFileTop()
if (this->GetGlobalGenerator()->IsMultiConfig()) {
for (auto const& config : this->GetConfigNames()) {
- auto& stream = this->GetConfigFileStream(config);
+ auto& stream = this->GetImplFileStream(config);
this->WriteProjectHeader(stream);
this->WriteNinjaRequiredVersion(stream);
this->WriteNinjaConfigurationVariable(stream, config);
@@ -560,7 +560,7 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
build.Outputs = std::move(ninjaOutputs);
build.ExplicitDeps = std::move(ninjaDeps);
build.OrderOnlyDeps = orderOnlyDeps;
- gg->WriteBuild(this->GetConfigFileStream(config), build);
+ gg->WriteBuild(this->GetImplFileStream(config), build);
} else {
std::string customStep = cmSystemTools::GetFilenameName(ninjaOutputs[0]);
// Hash full path to make unique.
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index 0445879..ef160e7 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -86,7 +86,7 @@ protected:
bool forceFullPaths = false) override;
private:
- cmGeneratedFileStream& GetConfigFileStream(const std::string& config) const;
+ cmGeneratedFileStream& GetImplFileStream(const std::string& config) const;
cmGeneratedFileStream& GetCommonFileStream() const;
cmGeneratedFileStream& GetRulesFileStream() const;
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index f853ac5..a871a92 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -811,9 +811,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
}
// Write comments.
- cmGlobalNinjaGenerator::WriteDivider(this->GetConfigFileStream(fileConfig));
+ cmGlobalNinjaGenerator::WriteDivider(this->GetImplFileStream(fileConfig));
const cmStateEnums::TargetType targetType = gt->GetType();
- this->GetConfigFileStream(fileConfig)
+ this->GetImplFileStream(fileConfig)
<< "# Link build statements for " << cmState::GetTargetTypeName(targetType)
<< " target " << this->GetTargetName() << "\n\n";
@@ -1183,7 +1183,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
// Write the build statement for this target.
bool usedResponseFile = false;
- globalGen->WriteBuild(this->GetConfigFileStream(fileConfig), linkBuild,
+ globalGen->WriteBuild(this->GetImplFileStream(fileConfig), linkBuild,
commandLineLengthLimit, &usedResponseFile);
this->WriteLinkRule(usedResponseFile, config);
@@ -1197,7 +1197,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
}
build.ExplicitDeps.push_back(targetOutputReal);
build.Variables = std::move(symlinkVars);
- globalGen->WriteBuild(this->GetConfigFileStream(fileConfig), build);
+ globalGen->WriteBuild(this->GetImplFileStream(fileConfig), build);
} else {
cmNinjaBuild build("CMAKE_SYMLINK_LIBRARY");
build.Comment = "Create library symlink " + targetOutput;
@@ -1223,7 +1223,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
build.ExplicitDeps.push_back(targetOutputReal);
build.Variables = std::move(symlinkVars);
- globalGen->WriteBuild(this->GetConfigFileStream(fileConfig), build);
+ globalGen->WriteBuild(this->GetImplFileStream(fileConfig), build);
}
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 5a8c144..455d809 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -68,10 +68,10 @@ cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target)
cmNinjaTargetGenerator::~cmNinjaTargetGenerator() = default;
-cmGeneratedFileStream& cmNinjaTargetGenerator::GetConfigFileStream(
+cmGeneratedFileStream& cmNinjaTargetGenerator::GetImplFileStream(
const std::string& config) const
{
- return *this->GetGlobalGenerator()->GetConfigFileStream(config);
+ return *this->GetGlobalGenerator()->GetImplFileStream(config);
}
cmGeneratedFileStream& cmNinjaTargetGenerator::GetCommonFileStream() const
@@ -815,8 +815,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
bool firstForConfig)
{
// Write comments.
- cmGlobalNinjaGenerator::WriteDivider(this->GetConfigFileStream(fileConfig));
- this->GetConfigFileStream(fileConfig)
+ cmGlobalNinjaGenerator::WriteDivider(this->GetImplFileStream(fileConfig));
+ this->GetImplFileStream(fileConfig)
<< "# Object build statements for "
<< cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType())
<< " target " << this->GetTargetName() << "\n\n";
@@ -901,8 +901,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
orderOnlyDeps.push_back(this->ConvertToNinjaPath(tgtDir));
}
- this->GetGlobalGenerator()->WriteBuild(
- this->GetConfigFileStream(fileConfig), build);
+ this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
+ build);
}
{
@@ -935,11 +935,11 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
this->GeneratorTarget, build.OrderOnlyDeps, config, fileConfig,
DependOnTargetArtifact);
- this->GetGlobalGenerator()->WriteBuild(
- this->GetConfigFileStream(fileConfig), build);
+ this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
+ build);
}
- this->GetConfigFileStream(fileConfig) << "\n";
+ this->GetImplFileStream(fileConfig) << "\n";
if (!this->Configs[config].SwiftOutputMap.empty()) {
std::string const mapFilePath =
@@ -1177,8 +1177,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetGeneratorTarget(),
ppBuild.Variables);
- this->GetGlobalGenerator()->WriteBuild(
- this->GetConfigFileStream(fileConfig), ppBuild, commandLineLengthLimit);
+ this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
+ ppBuild, commandLineLengthLimit);
}
if (needDyndep) {
std::string const dyndep = this->GetDyndepFilePath(language, config);
@@ -1210,8 +1210,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
if (language == "Swift") {
this->EmitSwiftDependencyInfo(source, config);
} else {
- this->GetGlobalGenerator()->WriteBuild(
- this->GetConfigFileStream(fileConfig), objBuild, commandLineLengthLimit);
+ this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
+ objBuild, commandLineLengthLimit);
}
if (const char* objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) {
@@ -1221,8 +1221,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
std::transform(build.Outputs.begin(), build.Outputs.end(),
build.Outputs.begin(), MapToNinjaPath());
build.ExplicitDeps = objBuild.Outputs;
- this->GetGlobalGenerator()->WriteBuild(
- this->GetConfigFileStream(fileConfig), build);
+ this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
+ build);
}
}
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 22dd7b8..bca12b1 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -47,7 +47,7 @@ public:
protected:
bool SetMsvcTargetPdbVariable(cmNinjaVars&, const std::string& config) const;
- cmGeneratedFileStream& GetConfigFileStream(const std::string& config) const;
+ cmGeneratedFileStream& GetImplFileStream(const std::string& config) const;
cmGeneratedFileStream& GetCommonFileStream() const;
cmGeneratedFileStream& GetRulesFileStream() const;
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index 0cddb12..a42d65d 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -164,6 +164,6 @@ void cmNinjaUtilityTargetGenerator::Generate(const std::string& config)
cmNinjaBuild phonyAlias("phony");
gg->AppendTargetOutputs(genTarget, phonyAlias.Outputs, "");
phonyAlias.ExplicitDeps = phonyBuild.Outputs;
- gg->WriteBuild(this->GetConfigFileStream(config), phonyAlias);
+ gg->WriteBuild(this->GetImplFileStream(config), phonyAlias);
}
}
diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
index f3208ed..fc80859 100644
--- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
@@ -103,6 +103,9 @@ run_ninja(Simple reconfigure-config build-Release.ninja simpleexe)
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
file(TOUCH "${RunCMake_TEST_BINARY_DIR}/empty.cmake")
run_ninja(Simple reconfigure-noconfig build.ninja simpleexe)
+run_ninja(Simple default-build-file-clean build.ninja clean)
+run_ninja(Simple default-build-file-clean-minsizerel build.ninja clean:MinSizeRel)
+run_ninja(Simple default-build-file-all build.ninja all)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleNoCross-build)
run_cmake_configure(SimpleNoCross)
diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-all-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-all-ninja-check.cmake
new file mode 100644
index 0000000..4e6e654
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-all-ninja-check.cmake
@@ -0,0 +1,49 @@
+check_files("${RunCMake_TEST_BINARY_DIR}"
+ INCLUDE
+ ${GENERATED_FILES}
+
+ ${TARGET_FILE_simpleexe_Debug}
+ ${TARGET_OBJECT_FILES_simpleexe_Debug}
+
+ ${TARGET_FILE_simpleshared_Debug}
+ ${TARGET_LINKER_FILE_simpleshared_Debug}
+ ${TARGET_OBJECT_FILES_simpleshared_Debug}
+
+ ${TARGET_FILE_simplestatic_Debug}
+ ${TARGET_LINKER_FILE_simplestatic_Debug}
+ ${TARGET_OBJECT_FILES_simplestatic_Debug}
+
+ ${TARGET_OBJECT_FILES_simpleobj_Debug}
+
+ ${TARGET_FILE_simpleexe_Release}
+ ${TARGET_OBJECT_FILES_simpleexe_Release}
+
+ ${TARGET_FILE_simpleshared_Release}
+ ${TARGET_LINKER_FILE_simpleshared_Release}
+ ${TARGET_OBJECT_FILES_simpleshared_Release}
+
+ ${TARGET_FILE_simplestatic_Release}
+ ${TARGET_LINKER_FILE_simplestatic_Release}
+ ${TARGET_OBJECT_FILES_simplestatic_Release}
+
+ ${TARGET_OBJECT_FILES_simpleobj_Release}
+
+ ${TARGET_FILE_simpleexe_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo}
+
+ ${TARGET_FILE_simpleshared_RelWithDebInfo}
+ ${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo}
+
+ ${TARGET_FILE_simplestatic_RelWithDebInfo}
+ ${TARGET_LINKER_FILE_simplestatic_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo}
+
+ ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo}
+
+ EXCLUDE
+ ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel}
+ )
diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-minsizerel-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-minsizerel-ninja-check.cmake
new file mode 100644
index 0000000..c09ae65
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-minsizerel-ninja-check.cmake
@@ -0,0 +1,41 @@
+check_files("${RunCMake_TEST_BINARY_DIR}"
+ INCLUDE
+ ${GENERATED_FILES}
+
+ ${TARGET_FILE_simpleexe_Debug}
+ ${TARGET_OBJECT_FILES_simpleexe_Debug}
+
+ ${TARGET_FILE_simpleshared_Debug}
+ ${TARGET_LINKER_FILE_simpleshared_Debug}
+ ${TARGET_OBJECT_FILES_simpleshared_Debug}
+
+ ${TARGET_FILE_simplestatic_Debug}
+ ${TARGET_LINKER_FILE_simplestatic_Debug}
+ ${TARGET_OBJECT_FILES_simplestatic_Debug}
+
+ ${TARGET_OBJECT_FILES_simpleobj_Debug}
+
+ ${TARGET_FILE_simpleexe_Release}
+ ${TARGET_OBJECT_FILES_simpleexe_Release}
+
+ ${TARGET_FILE_simpleshared_Release}
+ ${TARGET_LINKER_FILE_simpleshared_Release}
+ ${TARGET_OBJECT_FILES_simpleshared_Release}
+
+ ${TARGET_FILE_simplestatic_Release}
+ ${TARGET_LINKER_FILE_simplestatic_Release}
+ ${TARGET_OBJECT_FILES_simplestatic_Release}
+
+ ${TARGET_OBJECT_FILES_simpleobj_Release}
+
+ EXCLUDE
+ ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel}
+
+ ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo}
+ )
diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-ninja-check.cmake
new file mode 100644
index 0000000..43213dd
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/Simple-default-build-file-clean-ninja-check.cmake
@@ -0,0 +1,49 @@
+check_files("${RunCMake_TEST_BINARY_DIR}"
+ INCLUDE
+ ${GENERATED_FILES}
+
+ ${TARGET_FILE_simpleexe_Debug}
+ ${TARGET_OBJECT_FILES_simpleexe_Debug}
+
+ ${TARGET_FILE_simpleshared_Debug}
+ ${TARGET_LINKER_FILE_simpleshared_Debug}
+ ${TARGET_OBJECT_FILES_simpleshared_Debug}
+
+ ${TARGET_FILE_simplestatic_Debug}
+ ${TARGET_LINKER_FILE_simplestatic_Debug}
+ ${TARGET_OBJECT_FILES_simplestatic_Debug}
+
+ ${TARGET_OBJECT_FILES_simpleobj_Debug}
+
+ ${TARGET_FILE_simpleexe_Release}
+ ${TARGET_OBJECT_FILES_simpleexe_Release}
+
+ ${TARGET_FILE_simpleshared_Release}
+ ${TARGET_LINKER_FILE_simpleshared_Release}
+ ${TARGET_OBJECT_FILES_simpleshared_Release}
+
+ ${TARGET_FILE_simplestatic_Release}
+ ${TARGET_LINKER_FILE_simplestatic_Release}
+ ${TARGET_OBJECT_FILES_simplestatic_Release}
+
+ ${TARGET_OBJECT_FILES_simpleobj_Release}
+
+ ${TARGET_FILE_simpleexe_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel}
+
+ ${TARGET_FILE_simpleshared_MinSizeRel}
+ ${TARGET_LINKER_FILE_simpleshared_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel}
+
+ ${TARGET_FILE_simplestatic_MinSizeRel}
+ ${TARGET_LINKER_FILE_simplestatic_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel}
+
+ ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel}
+
+ EXCLUDE
+ ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo}
+ )