Ninja: Pass all build paths through a central method
This gives us a central location to revise paths.
This commit is contained in:
parent
7c26a6a269
commit
038e7716e5
|
@ -488,8 +488,8 @@ void cmGlobalNinjaGenerator::Generate()
|
||||||
this->OpenBuildFileStream();
|
this->OpenBuildFileStream();
|
||||||
this->OpenRulesFileStream();
|
this->OpenRulesFileStream();
|
||||||
|
|
||||||
this->TargetAll = "all";
|
this->TargetAll = this->NinjaOutputPath("all");
|
||||||
this->CMakeCacheFile = "CMakeCache.txt";
|
this->CMakeCacheFile = this->NinjaOutputPath("CMakeCache.txt");
|
||||||
|
|
||||||
this->PolicyCMP0058 =
|
this->PolicyCMP0058 =
|
||||||
this->LocalGenerators[0]->GetMakefile()->GetPolicyStatus(
|
this->LocalGenerators[0]->GetMakefile()->GetPolicyStatus(
|
||||||
|
@ -722,6 +722,7 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path)
|
||||||
cmLocalNinjaGenerator* ng =
|
cmLocalNinjaGenerator* ng =
|
||||||
static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
|
static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
|
||||||
std::string convPath = ng->Convert(path, cmOutputConverter::HOME_OUTPUT);
|
std::string convPath = ng->Convert(path, cmOutputConverter::HOME_OUTPUT);
|
||||||
|
convPath = this->NinjaOutputPath(convPath);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
cmSystemTools::ReplaceString(convPath, "/", "\\");
|
cmSystemTools::ReplaceString(convPath, "/", "\\");
|
||||||
#endif
|
#endif
|
||||||
|
@ -734,6 +735,7 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaFolderRule(
|
||||||
cmLocalNinjaGenerator* ng =
|
cmLocalNinjaGenerator* ng =
|
||||||
static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
|
static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
|
||||||
std::string convPath = ng->Convert(path + "/all", cmOutputConverter::HOME);
|
std::string convPath = ng->Convert(path + "/all", cmOutputConverter::HOME);
|
||||||
|
convPath = this->NinjaOutputPath(convPath);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
cmSystemTools::ReplaceString(convPath, "/", "\\");
|
cmSystemTools::ReplaceString(convPath, "/", "\\");
|
||||||
#endif
|
#endif
|
||||||
|
@ -849,7 +851,7 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs(
|
||||||
case cmState::GLOBAL_TARGET:
|
case cmState::GLOBAL_TARGET:
|
||||||
// Always use the target in HOME instead of an unused duplicate in a
|
// Always use the target in HOME instead of an unused duplicate in a
|
||||||
// subdirectory.
|
// subdirectory.
|
||||||
outputs.push_back(target->GetName());
|
outputs.push_back(this->NinjaOutputPath(target->GetName()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -883,6 +885,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends(
|
||||||
void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
|
void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
|
||||||
cmGeneratorTarget* target)
|
cmGeneratorTarget* target)
|
||||||
{
|
{
|
||||||
|
std::string buildAlias = this->NinjaOutputPath(alias);
|
||||||
cmNinjaDeps outputs;
|
cmNinjaDeps outputs;
|
||||||
this->AppendTargetOutputs(target, outputs);
|
this->AppendTargetOutputs(target, outputs);
|
||||||
// Mark the target's outputs as ambiguous to ensure that no other target uses
|
// Mark the target's outputs as ambiguous to ensure that no other target uses
|
||||||
|
@ -893,7 +896,7 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
|
||||||
// Insert the alias into the map. If the alias was already present in the
|
// Insert the alias into the map. If the alias was already present in the
|
||||||
// map and referred to another target, mark it as ambiguous.
|
// map and referred to another target, mark it as ambiguous.
|
||||||
std::pair<TargetAliasMap::iterator, bool> newAlias =
|
std::pair<TargetAliasMap::iterator, bool> newAlias =
|
||||||
TargetAliases.insert(std::make_pair(alias, target));
|
TargetAliases.insert(std::make_pair(buildAlias, target));
|
||||||
if (newAlias.second && newAlias.first->second != target)
|
if (newAlias.second && newAlias.first->second != target)
|
||||||
newAlias.first->second = 0;
|
newAlias.first->second = 0;
|
||||||
}
|
}
|
||||||
|
@ -1182,9 +1185,10 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
|
||||||
variables["pool"] = "console";
|
variables["pool"] = "console";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string const ninjaBuildFile = this->NinjaOutputPath(NINJA_BUILD_FILE);
|
||||||
this->WriteBuild(os, "Re-run CMake if any of its inputs changed.",
|
this->WriteBuild(os, "Re-run CMake if any of its inputs changed.",
|
||||||
"RERUN_CMAKE",
|
"RERUN_CMAKE",
|
||||||
/*outputs=*/cmNinjaDeps(1, NINJA_BUILD_FILE),
|
/*outputs=*/cmNinjaDeps(1, ninjaBuildFile),
|
||||||
/*explicitDeps=*/cmNinjaDeps(), implicitDeps,
|
/*explicitDeps=*/cmNinjaDeps(), implicitDeps,
|
||||||
/*orderOnlyDeps=*/cmNinjaDeps(), variables);
|
/*orderOnlyDeps=*/cmNinjaDeps(), variables);
|
||||||
|
|
||||||
|
@ -1221,7 +1225,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
|
||||||
/*restat=*/"",
|
/*restat=*/"",
|
||||||
/*generator=*/false);
|
/*generator=*/false);
|
||||||
WriteBuild(os, "Clean all the built files.", "CLEAN",
|
WriteBuild(os, "Clean all the built files.", "CLEAN",
|
||||||
/*outputs=*/cmNinjaDeps(1, "clean"),
|
/*outputs=*/cmNinjaDeps(1, this->NinjaOutputPath("clean")),
|
||||||
/*explicitDeps=*/cmNinjaDeps(),
|
/*explicitDeps=*/cmNinjaDeps(),
|
||||||
/*implicitDeps=*/cmNinjaDeps(),
|
/*implicitDeps=*/cmNinjaDeps(),
|
||||||
/*orderOnlyDeps=*/cmNinjaDeps(),
|
/*orderOnlyDeps=*/cmNinjaDeps(),
|
||||||
|
@ -1240,9 +1244,14 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os)
|
||||||
/*restat=*/"",
|
/*restat=*/"",
|
||||||
/*generator=*/false);
|
/*generator=*/false);
|
||||||
WriteBuild(os, "Print all primary targets available.", "HELP",
|
WriteBuild(os, "Print all primary targets available.", "HELP",
|
||||||
/*outputs=*/cmNinjaDeps(1, "help"),
|
/*outputs=*/cmNinjaDeps(1, this->NinjaOutputPath("help")),
|
||||||
/*explicitDeps=*/cmNinjaDeps(),
|
/*explicitDeps=*/cmNinjaDeps(),
|
||||||
/*implicitDeps=*/cmNinjaDeps(),
|
/*implicitDeps=*/cmNinjaDeps(),
|
||||||
/*orderOnlyDeps=*/cmNinjaDeps(),
|
/*orderOnlyDeps=*/cmNinjaDeps(),
|
||||||
/*variables=*/cmNinjaVars());
|
/*variables=*/cmNinjaVars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string cmGlobalNinjaGenerator::NinjaOutputPath(std::string const& path)
|
||||||
|
{
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
|
@ -314,6 +314,8 @@ public:
|
||||||
static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; }
|
static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; }
|
||||||
bool SupportsConsolePool() const;
|
bool SupportsConsolePool() const;
|
||||||
|
|
||||||
|
std::string NinjaOutputPath(std::string const& path);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Generate();
|
virtual void Generate();
|
||||||
|
|
||||||
|
|
|
@ -225,8 +225,13 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os)
|
||||||
cmGlobalNinjaGenerator::WriteDivider(os);
|
cmGlobalNinjaGenerator::WriteDivider(os);
|
||||||
os << "# Include auxiliary files.\n"
|
os << "# Include auxiliary files.\n"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
cmGlobalNinjaGenerator::WriteInclude(
|
cmGlobalNinjaGenerator* ng = this->GetGlobalNinjaGenerator();
|
||||||
os, cmGlobalNinjaGenerator::NINJA_RULES_FILE, "Include rules file.");
|
std::string const ninjaRulesFile =
|
||||||
|
ng->NinjaOutputPath(cmGlobalNinjaGenerator::NINJA_RULES_FILE);
|
||||||
|
std::string const rulesFilePath =
|
||||||
|
ng->EncodeIdent(ng->EncodePath(ninjaRulesFile), os);
|
||||||
|
cmGlobalNinjaGenerator::WriteInclude(os, rulesFilePath,
|
||||||
|
"Include rules file.");
|
||||||
os << "\n";
|
os << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
|
||||||
{
|
{
|
||||||
std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash();
|
std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash();
|
||||||
utilCommandName += this->GetTargetName() + ".util";
|
utilCommandName += this->GetTargetName() + ".util";
|
||||||
|
utilCommandName =
|
||||||
|
this->GetGlobalGenerator()->NinjaOutputPath(utilCommandName);
|
||||||
|
|
||||||
std::vector<std::string> commands;
|
std::vector<std::string> commands;
|
||||||
cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName);
|
cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName);
|
||||||
|
|
Loading…
Reference in New Issue