Merge topic 'ninja-multi-default-build-alias'

8337ed0d73 Ninja Multi-Config: Add variable to control aliases in build.ninja
110037369d Refactor: Split Ninja files into impl-<Config>.ninja and build-<Config>.ninja
e62a3414f7 Refactor: Move common.ninja into CMakeFiles

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4238
This commit is contained in:
Brad King 2020-01-23 15:01:04 +00:00 committed by Kitware Robot
commit 9771d231aa
19 changed files with 494 additions and 73 deletions

View File

@ -78,4 +78,13 @@ targets built with the generated code.
As a convenience, ``Ninja Multi-Config`` offers a
:variable:`CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE` setting. If this variable is
specified, a ``build.ninja`` file will be generated which points to the
specified ``build-<Config>.ninja`` file.
specified ``build-<Config>.ninja`` file. In addition, if
:variable:`CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE` is used in conjunction with
:variable:`CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE`, you can also specify
:variable:`CMAKE_NINJA_MULTI_DEFAULT_BUILD_ALIAS`, which changes the config
of the ``<target>`` targets in ``build.ninja``. For example, if you set
:variable:`CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE` to ``Release``, but set
:variable:`CMAKE_NINJA_MULTI_DEFAULT_BUILD_ALIAS` to ``Debug`` or ``all``,
all ``<target>`` aliases in ``build.ninja`` will resolve to ``<target>:Debug``
or ``<target>:all``, but custom commands will still use the ``Release``
configuration.

View File

@ -425,6 +425,7 @@ Variables that Control the Build
/variable/CMAKE_MSVCIDE_RUN_PATH
/variable/CMAKE_MSVC_RUNTIME_LIBRARY
/variable/CMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE
/variable/CMAKE_NINJA_MULTI_DEFAULT_BUILD_ALIAS
/variable/CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE
/variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX
/variable/CMAKE_NO_BUILTIN_CHRPATH

View File

@ -0,0 +1,6 @@
CMAKE_NINJA_MULTI_DEFAULT_BUILD_ALIAS
-------------------------------------
Controls the config of ``<target>`` aliases in ``build.ninja`` for the
:generator:`Ninja Multi-Config` generator. See the generator's documentation
for more details.

View File

@ -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);
@ -1164,14 +1161,11 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
newAliasGlobal.first->second.GeneratorTarget != target) {
newAliasGlobal.first->second.GeneratorTarget = nullptr;
}
if (config != "all") {
std::pair<TargetAliasMap::iterator, bool> newAliasConfig =
this->Configs[config].TargetAliases.insert(
std::make_pair(outputPath, ta));
if (newAliasConfig.second &&
newAliasConfig.first->second.GeneratorTarget != target) {
newAliasConfig.first->second.GeneratorTarget = nullptr;
}
std::pair<TargetAliasMap::iterator, bool> newAliasConfig =
this->Configs[config].TargetAliases.insert(std::make_pair(outputPath, ta));
if (newAliasConfig.second &&
newAliasConfig.first->second.GeneratorTarget != target) {
newAliasConfig.first->second.GeneratorTarget = nullptr;
}
}
@ -1208,7 +1202,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 +1227,37 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
this->WriteBuild(*this->GetConfigFileStream(config), build);
}
}
auto const* defaultConfig = this->GetDefaultBuildAlias();
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();
if (config == "all") {
for (auto const& config2 :
this->Makefiles.front()->GetGeneratorConfigs()) {
this->AppendTargetOutputs(ta.second.GeneratorTarget,
build.ExplicitDeps, config2);
}
} else {
this->AppendTargetOutputs(ta.second.GeneratorTarget,
build.ExplicitDeps, config);
}
this->WriteBuild(*this->GetDefaultFileStream(), build);
}
}
}
}
@ -1276,10 +1301,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 +1315,16 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
this->ConvertToNinjaPath(currentBinaryDir + "/all");
this->WriteBuild(*this->GetConfigFileStream(config), build);
}
auto const* defaultConfig = this->GetDefaultBuildAlias();
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 +1476,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 +1772,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 +1793,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 +1811,14 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
this->NinjaOutputPath(this->GetCleanTargetName()), config);
this->WriteBuild(*this->GetConfigFileStream(config), build);
}
auto const* defaultConfig = this->GetDefaultBuildAlias();
if (defaultConfig) {
std::string config = defaultConfig;
build.ExplicitDeps.front() = this->BuildAlias(
this->NinjaOutputPath(this->GetCleanTargetName()), config);
this->WriteBuild(*this->GetDefaultFileStream(), build);
}
}
// Write byproducts
@ -2311,7 +2359,8 @@ void cmGlobalNinjaGenerator::AppendDirectoryForConfig(
}
}
const char* cmGlobalNinjaMultiGenerator::NINJA_COMMON_FILE = "common.ninja";
const char* cmGlobalNinjaMultiGenerator::NINJA_COMMON_FILE =
"CMakeFiles/common.ninja";
const char* cmGlobalNinjaMultiGenerator::NINJA_FILE_EXTENSION = ".ninja";
cmGlobalNinjaMultiGenerator::cmGlobalNinjaMultiGenerator(cmake* cm)
@ -2342,21 +2391,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()) {
// Open impl file.
if (!this->OpenFileStream(this->ImplFileStreams[config],
GetNinjaImplFilename(config))) {
return false;
}
// Write a comment about this file.
*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],
GetNinjaFilename(config))) {
GetNinjaConfigFilename(config))) {
return false;
}
// Write a comment about this file.
*this->ConfigFileStreams[config]
<< "# This file contains build statements specific to the \"" << config
<< "\"\n# configuration.\n\n";
<< "# This file contains aliases specific to the \"" << config
<< "\"\n# configuration.\n\n"
<< "include " << GetNinjaImplFilename(config) << "\n\n";
}
return true;
@ -2370,7 +2443,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 {
@ -2384,10 +2467,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::GetNinjaFilename(
std::string cmGlobalNinjaMultiGenerator::GetNinjaImplFilename(
const std::string& config)
{
return cmStrCat("CMakeFiles/impl-", config,
cmGlobalNinjaMultiGenerator::NINJA_FILE_EXTENSION);
}
std::string cmGlobalNinjaMultiGenerator::GetNinjaConfigFilename(
const std::string& config)
{
return cmStrCat("build-", config,
@ -2398,7 +2488,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")) {
@ -2416,20 +2507,21 @@ 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;
}
const char* cmGlobalNinjaMultiGenerator::GetDefaultBuildAlias() const
{
if (this->EnableCrossConfigBuild()) {
auto const* alias = this->Makefiles.front()->GetDefinition(
"CMAKE_NINJA_MULTI_DEFAULT_BUILD_ALIAS");
if (alias) {
return alias;
}
*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;
return this->GetDefaultBuildType();
}

View File

@ -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,10 @@ public:
bool EnableCrossConfigBuild() const;
virtual const char* GetDefaultBuildType() const { return nullptr; }
virtual const char* GetDefaultBuildAlias() const { return nullptr; }
protected:
void Generate() override;
@ -404,7 +419,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 +587,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,22 +612,28 @@ 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;
const char* GetDefaultBuildAlias() const override;
protected:
bool OpenBuildFileStreams() override;
void CloseBuildFileStreams() override;
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

View File

@ -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.

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -103,6 +103,18 @@ 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}/SimpleDefaultBuildAlias-build)
set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE=Release;-DCMAKE_NINJA_MULTI_DEFAULT_BUILD_ALIAS=all;-DCMAKE_NINJA_MULTI_CROSS_CONFIG_ENABLE=ON")
run_cmake_configure(SimpleDefaultBuildAlias)
unset(RunCMake_TEST_OPTIONS)
include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake)
run_ninja(SimpleDefaultBuildAlias target build.ninja simpleexe)
run_ninja(SimpleDefaultBuildAlias all build.ninja all)
run_ninja(SimpleDefaultBuildAlias clean build.ninja clean)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleNoCross-build)
run_cmake_configure(SimpleNoCross)

View File

@ -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}
)

View File

@ -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}
)

View File

@ -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}
)

View File

@ -0,0 +1,56 @@
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}
${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}
)

View File

@ -0,0 +1,25 @@
check_files("${RunCMake_TEST_BINARY_DIR}"
INCLUDE
${GENERATED_FILES}
EXCLUDE
${TARGET_OBJECT_FILES_simpleexe_Debug}
${TARGET_OBJECT_FILES_simpleshared_Debug}
${TARGET_OBJECT_FILES_simplestatic_Debug}
${TARGET_OBJECT_FILES_simpleobj_Debug}
${TARGET_OBJECT_FILES_simpleexe_Release}
${TARGET_OBJECT_FILES_simpleshared_Release}
${TARGET_OBJECT_FILES_simplestatic_Release}
${TARGET_OBJECT_FILES_simpleobj_Release}
${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}
)

View File

@ -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_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_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_OBJECT_FILES_simpleobj_MinSizeRel}
${TARGET_FILE_simpleexe_RelWithDebInfo}
${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo}
${TARGET_FILE_simpleshared_RelWithDebInfo}
${TARGET_LINKER_FILE_simpleshared_RelWithDebInfo}
${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo}
${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo}
EXCLUDE
${TARGET_OBJECT_FILES_simplestatic_Debug}
${TARGET_OBJECT_FILES_simplestatic_Release}
${TARGET_OBJECT_FILES_simplestatic_MinSizeRel}
${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo}
)

View File

@ -0,0 +1 @@
include("${CMAKE_CURRENT_SOURCE_DIR}/Simple.cmake")