diff options
author | Nicolas Despres <nicolas.despres@gmail.com> | 2016-05-13 23:18:20 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-17 13:34:11 (GMT) |
commit | 038e7716e58e4cf79bda6ba72b92814a14978a8f (patch) | |
tree | 05a417720ba732cc8beb2210f010835ffc6dd4e8 /Source | |
parent | 7c26a6a269b0c12ecdf7605183d9fa26ad2b91eb (diff) | |
download | CMake-038e7716e58e4cf79bda6ba72b92814a14978a8f.zip CMake-038e7716e58e4cf79bda6ba72b92814a14978a8f.tar.gz CMake-038e7716e58e4cf79bda6ba72b92814a14978a8f.tar.bz2 |
Ninja: Pass all build paths through a central method
This gives us a central location to revise paths.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 23 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmNinjaUtilityTargetGenerator.cxx | 2 |
4 files changed, 27 insertions, 9 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index df5a001..3c5a8e3 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -488,8 +488,8 @@ void cmGlobalNinjaGenerator::Generate() this->OpenBuildFileStream(); this->OpenRulesFileStream(); - this->TargetAll = "all"; - this->CMakeCacheFile = "CMakeCache.txt"; + this->TargetAll = this->NinjaOutputPath("all"); + this->CMakeCacheFile = this->NinjaOutputPath("CMakeCache.txt"); this->PolicyCMP0058 = this->LocalGenerators[0]->GetMakefile()->GetPolicyStatus( @@ -722,6 +722,7 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path) cmLocalNinjaGenerator* ng = static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]); std::string convPath = ng->Convert(path, cmOutputConverter::HOME_OUTPUT); + convPath = this->NinjaOutputPath(convPath); #ifdef _WIN32 cmSystemTools::ReplaceString(convPath, "/", "\\"); #endif @@ -734,6 +735,7 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaFolderRule( cmLocalNinjaGenerator* ng = static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]); std::string convPath = ng->Convert(path + "/all", cmOutputConverter::HOME); + convPath = this->NinjaOutputPath(convPath); #ifdef _WIN32 cmSystemTools::ReplaceString(convPath, "/", "\\"); #endif @@ -849,7 +851,7 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( case cmState::GLOBAL_TARGET: // Always use the target in HOME instead of an unused duplicate in a // subdirectory. - outputs.push_back(target->GetName()); + outputs.push_back(this->NinjaOutputPath(target->GetName())); break; default: @@ -883,6 +885,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends( void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias, cmGeneratorTarget* target) { + std::string buildAlias = this->NinjaOutputPath(alias); cmNinjaDeps outputs; this->AppendTargetOutputs(target, outputs); // 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 // map and referred to another target, mark it as ambiguous. 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) newAlias.first->second = 0; } @@ -1182,9 +1185,10 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) variables["pool"] = "console"; } + std::string const ninjaBuildFile = this->NinjaOutputPath(NINJA_BUILD_FILE); this->WriteBuild(os, "Re-run CMake if any of its inputs changed.", "RERUN_CMAKE", - /*outputs=*/cmNinjaDeps(1, NINJA_BUILD_FILE), + /*outputs=*/cmNinjaDeps(1, ninjaBuildFile), /*explicitDeps=*/cmNinjaDeps(), implicitDeps, /*orderOnlyDeps=*/cmNinjaDeps(), variables); @@ -1221,7 +1225,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) /*restat=*/"", /*generator=*/false); WriteBuild(os, "Clean all the built files.", "CLEAN", - /*outputs=*/cmNinjaDeps(1, "clean"), + /*outputs=*/cmNinjaDeps(1, this->NinjaOutputPath("clean")), /*explicitDeps=*/cmNinjaDeps(), /*implicitDeps=*/cmNinjaDeps(), /*orderOnlyDeps=*/cmNinjaDeps(), @@ -1240,9 +1244,14 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os) /*restat=*/"", /*generator=*/false); WriteBuild(os, "Print all primary targets available.", "HELP", - /*outputs=*/cmNinjaDeps(1, "help"), + /*outputs=*/cmNinjaDeps(1, this->NinjaOutputPath("help")), /*explicitDeps=*/cmNinjaDeps(), /*implicitDeps=*/cmNinjaDeps(), /*orderOnlyDeps=*/cmNinjaDeps(), /*variables=*/cmNinjaVars()); } + +std::string cmGlobalNinjaGenerator::NinjaOutputPath(std::string const& path) +{ + return path; +} diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 28034f6..15c0f34 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -314,6 +314,8 @@ public: static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; } bool SupportsConsolePool() const; + std::string NinjaOutputPath(std::string const& path); + protected: virtual void Generate(); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 69f8fe5..c7e1a90f8 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -225,8 +225,13 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os) cmGlobalNinjaGenerator::WriteDivider(os); os << "# Include auxiliary files.\n" << "\n"; - cmGlobalNinjaGenerator::WriteInclude( - os, cmGlobalNinjaGenerator::NINJA_RULES_FILE, "Include rules file."); + cmGlobalNinjaGenerator* ng = this->GetGlobalNinjaGenerator(); + 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"; } diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index b0b1147..d07341c 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -33,6 +33,8 @@ void cmNinjaUtilityTargetGenerator::Generate() { std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash(); utilCommandName += this->GetTargetName() + ".util"; + utilCommandName = + this->GetGlobalGenerator()->NinjaOutputPath(utilCommandName); std::vector<std::string> commands; cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName); |