diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index e9264ecba..b1d8e5b97 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -84,6 +84,15 @@ std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string &lit) return result; } +std::string cmGlobalNinjaGenerator::EncodePath(const std::string &path) +{ + std::string result = path; +#ifdef _WIN32 + cmSystemTools::ReplaceString(result, "/", "\\"); +#endif + return EncodeLiteral(result); +} + void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, const std::string& comment, const std::string& rule, @@ -122,7 +131,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, for(cmNinjaDeps::const_iterator i = outputs.begin(); i != outputs.end(); ++i) - builds << " " << EncodeIdent(*i, os); + builds << " " << EncodeIdent(EncodePath(*i), os); builds << ":"; // Write the rule. @@ -132,7 +141,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, for(cmNinjaDeps::const_iterator i = explicitDeps.begin(); i != explicitDeps.end(); ++i) - builds << " " << EncodeIdent(*i, os); + builds << " " << EncodeIdent(EncodePath(*i), os); // Write implicit dependencies. if(!implicitDeps.empty()) @@ -141,7 +150,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, for(cmNinjaDeps::const_iterator i = implicitDeps.begin(); i != implicitDeps.end(); ++i) - builds << " " << EncodeIdent(*i, os); + builds << " " << EncodeIdent(EncodePath(*i), os); } // Write order-only dependencies. @@ -151,7 +160,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, for(cmNinjaDeps::const_iterator i = orderOnlyDeps.begin(); i != orderOnlyDeps.end(); ++i) - builds << " " << EncodeIdent(*i, os); + builds << " " << EncodeIdent(EncodePath(*i), os); } builds << "\n"; diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 6f3c6b2c9..3f8644ea1 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -59,6 +59,7 @@ public: static std::string EncodeIdent(const std::string &ident, std::ostream &vars); static std::string EncodeLiteral(const std::string &lit); + static std::string EncodePath(const std::string &path); /** * Write the given @a comment to the output stream @a os. It diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index cf0e36a4d..28e8d47e5 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -28,6 +28,9 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator() , HomeRelativeOutputPath("") { this->IsMakefileGenerator = true; +#ifdef _WIN32 + this->WindowsShell = true; +#endif } //---------------------------------------------------------------------------- @@ -256,9 +259,11 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) std::string cmLocalNinjaGenerator::ConvertToNinjaPath(const char *path) { - return this->Convert(path, - cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); + std::string convPath = this->Convert(path, cmLocalGenerator::HOME_OUTPUT); +#ifdef _WIN32 + cmSystemTools::ReplaceString(convPath, "/", "\\"); +#endif + return convPath; } void diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 1e31044b9..8a563b640 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -212,13 +212,6 @@ ComputeDefines(cmSourceFile *source, const std::string& language) return defines; } -std::string cmNinjaTargetGenerator::ConvertToNinjaPath(const char *path) const -{ - return this->LocalGenerator->Convert(path, - cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); -} - cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const { // Static libraries never depend on other targets for linking. diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index cf47abf1d..2986844b6 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -75,7 +75,9 @@ protected: std::string ComputeDefines(cmSourceFile *source, const std::string& language); - std::string ConvertToNinjaPath(const char *path) const; + std::string ConvertToNinjaPath(const char *path) const { + return this->GetLocalGenerator()->ConvertToNinjaPath(path); + } cmLocalNinjaGenerator::map_to_ninja_path MapToNinjaPath() const { return this->GetLocalGenerator()->MapToNinjaPath(); }