Ninja: GlobalNinjaGenerator WriteBuild and WritePhonyBuild non static
To properly track the usage of dependencies that are generated at compile time as the side effect of other build steps we need to make the WriteBuild and WritePhonyBuild commands non static
This commit is contained in:
parent
88d27ad014
commit
874e17120d
|
@ -208,7 +208,7 @@ void cmGlobalNinjaGenerator::WritePhonyBuild(std::ostream& os,
|
||||||
const cmNinjaDeps& orderOnlyDeps,
|
const cmNinjaDeps& orderOnlyDeps,
|
||||||
const cmNinjaVars& variables)
|
const cmNinjaVars& variables)
|
||||||
{
|
{
|
||||||
cmGlobalNinjaGenerator::WriteBuild(os,
|
this->WriteBuild(os,
|
||||||
comment,
|
comment,
|
||||||
"phony",
|
"phony",
|
||||||
outputs,
|
outputs,
|
||||||
|
@ -251,7 +251,7 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
|
||||||
vars["COMMAND"] = cmd;
|
vars["COMMAND"] = cmd;
|
||||||
vars["DESC"] = EncodeLiteral(description);
|
vars["DESC"] = EncodeLiteral(description);
|
||||||
|
|
||||||
cmGlobalNinjaGenerator::WriteBuild(*this->BuildFileStream,
|
this->WriteBuild(*this->BuildFileStream,
|
||||||
comment,
|
comment,
|
||||||
"CUSTOM_COMMAND",
|
"CUSTOM_COMMAND",
|
||||||
outputs,
|
outputs,
|
||||||
|
@ -293,7 +293,7 @@ cmGlobalNinjaGenerator::WriteMacOSXContentBuild(const std::string& input,
|
||||||
deps.push_back(input);
|
deps.push_back(input);
|
||||||
cmNinjaVars vars;
|
cmNinjaVars vars;
|
||||||
|
|
||||||
cmGlobalNinjaGenerator::WriteBuild(*this->BuildFileStream,
|
this->WriteBuild(*this->BuildFileStream,
|
||||||
"",
|
"",
|
||||||
"COPY_OSX_CONTENT",
|
"COPY_OSX_CONTENT",
|
||||||
outputs,
|
outputs,
|
||||||
|
@ -896,7 +896,7 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
|
||||||
cmNinjaDeps deps;
|
cmNinjaDeps deps;
|
||||||
this->AppendTargetOutputs(i->second, deps);
|
this->AppendTargetOutputs(i->second, deps);
|
||||||
|
|
||||||
cmGlobalNinjaGenerator::WritePhonyBuild(os,
|
this->WritePhonyBuild(os,
|
||||||
"",
|
"",
|
||||||
cmNinjaDeps(1, i->first),
|
cmNinjaDeps(1, i->first),
|
||||||
deps);
|
deps);
|
||||||
|
@ -920,7 +920,7 @@ void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os)
|
||||||
cmNinjaDeps outputs;
|
cmNinjaDeps outputs;
|
||||||
outputs.push_back("all");
|
outputs.push_back("all");
|
||||||
|
|
||||||
cmGlobalNinjaGenerator::WritePhonyBuild(os,
|
this->WritePhonyBuild(os,
|
||||||
"The main all target.",
|
"The main all target.",
|
||||||
outputs,
|
outputs,
|
||||||
this->AllDependencies);
|
this->AllDependencies);
|
||||||
|
@ -970,7 +970,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
|
||||||
implicitDeps.end());
|
implicitDeps.end());
|
||||||
implicitDeps.push_back("CMakeCache.txt");
|
implicitDeps.push_back("CMakeCache.txt");
|
||||||
|
|
||||||
WriteBuild(os,
|
this->WriteBuild(os,
|
||||||
"Re-run CMake if any of its inputs changed.",
|
"Re-run CMake if any of its inputs changed.",
|
||||||
"RERUN_CMAKE",
|
"RERUN_CMAKE",
|
||||||
/*outputs=*/ cmNinjaDeps(1, NINJA_BUILD_FILE),
|
/*outputs=*/ cmNinjaDeps(1, NINJA_BUILD_FILE),
|
||||||
|
@ -979,7 +979,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
|
||||||
/*orderOnlyDeps=*/ cmNinjaDeps(),
|
/*orderOnlyDeps=*/ cmNinjaDeps(),
|
||||||
/*variables=*/ cmNinjaVars());
|
/*variables=*/ cmNinjaVars());
|
||||||
|
|
||||||
WritePhonyBuild(os,
|
this->WritePhonyBuild(os,
|
||||||
"A missing CMake input file is not an error.",
|
"A missing CMake input file is not an error.",
|
||||||
implicitDeps,
|
implicitDeps,
|
||||||
cmNinjaDeps());
|
cmNinjaDeps());
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
* It also writes the variables bound to this build statement.
|
* It also writes the variables bound to this build statement.
|
||||||
* @warning no escaping of any kind is done here.
|
* @warning no escaping of any kind is done here.
|
||||||
*/
|
*/
|
||||||
static void WriteBuild(std::ostream& os,
|
void WriteBuild(std::ostream& os,
|
||||||
const std::string& comment,
|
const std::string& comment,
|
||||||
const std::string& rule,
|
const std::string& rule,
|
||||||
const cmNinjaDeps& outputs,
|
const cmNinjaDeps& outputs,
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Helper to write a build statement with the special 'phony' rule.
|
* Helper to write a build statement with the special 'phony' rule.
|
||||||
*/
|
*/
|
||||||
static void WritePhonyBuild(std::ostream& os,
|
void WritePhonyBuild(std::ostream& os,
|
||||||
const std::string& comment,
|
const std::string& comment,
|
||||||
const cmNinjaDeps& outputs,
|
const cmNinjaDeps& outputs,
|
||||||
const cmNinjaDeps& explicitDeps,
|
const cmNinjaDeps& explicitDeps,
|
||||||
|
|
|
@ -340,7 +340,8 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
|
||||||
this->AppendCustomCommandLines(cc, cmdLines);
|
this->AppendCustomCommandLines(cc, cmdLines);
|
||||||
|
|
||||||
if (cmdLines.empty()) {
|
if (cmdLines.empty()) {
|
||||||
cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(),
|
this->GetGlobalNinjaGenerator()->WritePhonyBuild(
|
||||||
|
this->GetBuildFileStream(),
|
||||||
"Phony custom command for " +
|
"Phony custom command for " +
|
||||||
ninjaOutputs[0],
|
ninjaOutputs[0],
|
||||||
ninjaOutputs,
|
ninjaOutputs,
|
||||||
|
|
|
@ -598,12 +598,17 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get the global generator as we are going to be call WriteBuild numerous
|
||||||
|
//times in the following section
|
||||||
|
cmGlobalNinjaGenerator* globalGenerator = this->GetGlobalGenerator();
|
||||||
|
|
||||||
|
|
||||||
const std::string rspfile = std::string
|
const std::string rspfile = std::string
|
||||||
(cmake::GetCMakeFilesDirectoryPostSlash()) +
|
(cmake::GetCMakeFilesDirectoryPostSlash()) +
|
||||||
this->GetTarget()->GetName() + ".rsp";
|
this->GetTarget()->GetName() + ".rsp";
|
||||||
|
|
||||||
// Write the build statement for this target.
|
// Write the build statement for this target.
|
||||||
cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(),
|
globalGenerator->WriteBuild(this->GetBuildFileStream(),
|
||||||
comment.str(),
|
comment.str(),
|
||||||
this->LanguageLinkerRule(),
|
this->LanguageLinkerRule(),
|
||||||
outputs,
|
outputs,
|
||||||
|
@ -616,7 +621,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
||||||
|
|
||||||
if (targetOutput != targetOutputReal) {
|
if (targetOutput != targetOutputReal) {
|
||||||
if (targetType == cmTarget::EXECUTABLE) {
|
if (targetType == cmTarget::EXECUTABLE) {
|
||||||
cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(),
|
globalGenerator->WriteBuild(this->GetBuildFileStream(),
|
||||||
"Create executable symlink " + targetOutput,
|
"Create executable symlink " + targetOutput,
|
||||||
"CMAKE_SYMLINK_EXECUTABLE",
|
"CMAKE_SYMLINK_EXECUTABLE",
|
||||||
cmNinjaDeps(1, targetOutput),
|
cmNinjaDeps(1, targetOutput),
|
||||||
|
@ -635,7 +640,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
||||||
symlinks.push_back(soName);
|
symlinks.push_back(soName);
|
||||||
}
|
}
|
||||||
symlinks.push_back(targetOutput);
|
symlinks.push_back(targetOutput);
|
||||||
cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(),
|
globalGenerator->WriteBuild(this->GetBuildFileStream(),
|
||||||
"Create library symlink " + targetOutput,
|
"Create library symlink " + targetOutput,
|
||||||
"CMAKE_SYMLINK_LIBRARY",
|
"CMAKE_SYMLINK_LIBRARY",
|
||||||
symlinks,
|
symlinks,
|
||||||
|
@ -649,16 +654,16 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
||||||
if (!this->TargetNameImport.empty()) {
|
if (!this->TargetNameImport.empty()) {
|
||||||
// Since using multiple outputs would mess up the $out variable, use an
|
// Since using multiple outputs would mess up the $out variable, use an
|
||||||
// alias for the import library.
|
// alias for the import library.
|
||||||
cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(),
|
globalGenerator->WritePhonyBuild(this->GetBuildFileStream(),
|
||||||
"Alias for import library.",
|
"Alias for import library.",
|
||||||
cmNinjaDeps(1, targetOutputImplib),
|
cmNinjaDeps(1, targetOutputImplib),
|
||||||
cmNinjaDeps(1, targetOutputReal));
|
cmNinjaDeps(1, targetOutputReal));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add aliases for the file name and the target name.
|
// Add aliases for the file name and the target name.
|
||||||
this->GetGlobalGenerator()->AddTargetAlias(this->TargetNameOut,
|
globalGenerator->AddTargetAlias(this->TargetNameOut,
|
||||||
this->GetTarget());
|
this->GetTarget());
|
||||||
this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
|
globalGenerator->AddTargetAlias(this->GetTargetName(),
|
||||||
this->GetTarget());
|
this->GetTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,7 +674,7 @@ void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
|
||||||
cmNinjaDeps outputs;
|
cmNinjaDeps outputs;
|
||||||
this->GetLocalGenerator()->AppendTargetOutputs(this->GetTarget(), outputs);
|
this->GetLocalGenerator()->AppendTargetOutputs(this->GetTarget(), outputs);
|
||||||
cmNinjaDeps depends = this->GetObjects();
|
cmNinjaDeps depends = this->GetObjects();
|
||||||
cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(),
|
this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
|
||||||
"Object library "
|
"Object library "
|
||||||
+ this->GetTargetName(),
|
+ this->GetTargetName(),
|
||||||
outputs,
|
outputs,
|
||||||
|
|
|
@ -642,7 +642,7 @@ cmNinjaTargetGenerator
|
||||||
sourceFileName);
|
sourceFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(),
|
this->GetGlobalGenerator()->WriteBuild(this->GetBuildFileStream(),
|
||||||
comment,
|
comment,
|
||||||
rule,
|
rule,
|
||||||
outputs,
|
outputs,
|
||||||
|
@ -656,7 +656,7 @@ cmNinjaTargetGenerator
|
||||||
cmSystemTools::ExpandListArgument(objectOutputs, outputList);
|
cmSystemTools::ExpandListArgument(objectOutputs, outputList);
|
||||||
std::transform(outputList.begin(), outputList.end(), outputList.begin(),
|
std::transform(outputList.begin(), outputList.end(), outputList.begin(),
|
||||||
MapToNinjaPath());
|
MapToNinjaPath());
|
||||||
cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(),
|
this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
|
||||||
"Additional output files.",
|
"Additional output files.",
|
||||||
outputList,
|
outputList,
|
||||||
outputs);
|
outputs);
|
||||||
|
|
|
@ -61,7 +61,7 @@ void cmNinjaUtilityTargetGenerator::Generate()
|
||||||
this->GetLocalGenerator()->AppendTargetDepends(this->GetTarget(), deps);
|
this->GetLocalGenerator()->AppendTargetDepends(this->GetTarget(), deps);
|
||||||
|
|
||||||
if (commands.empty()) {
|
if (commands.empty()) {
|
||||||
cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(),
|
this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
|
||||||
"Utility command for "
|
"Utility command for "
|
||||||
+ this->GetTargetName(),
|
+ this->GetTargetName(),
|
||||||
outputs,
|
outputs,
|
||||||
|
@ -105,10 +105,11 @@ void cmNinjaUtilityTargetGenerator::Generate()
|
||||||
cmNinjaDeps(1, utilCommandName),
|
cmNinjaDeps(1, utilCommandName),
|
||||||
deps);
|
deps);
|
||||||
|
|
||||||
cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(),
|
this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
|
||||||
"",
|
"",
|
||||||
outputs,
|
outputs,
|
||||||
cmNinjaDeps(1, utilCommandName));
|
cmNinjaDeps(1, utilCommandName)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
|
this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
|
||||||
|
|
Loading…
Reference in New Issue