diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2012-02-19 01:50:53 (GMT) |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2012-02-19 04:00:02 (GMT) |
commit | cea03e632b71589592660614a63ff102ba923de8 (patch) | |
tree | 2413c402f5880a595c05ae54e36be230c57497da | |
parent | 9362440a0b9193c417b42c50495d0a3ea6e098c4 (diff) | |
download | CMake-cea03e632b71589592660614a63ff102ba923de8.zip CMake-cea03e632b71589592660614a63ff102ba923de8.tar.gz CMake-cea03e632b71589592660614a63ff102ba923de8.tar.bz2 |
Ninja: Backslash rules for Windows
Generally these are only required in build statements, as Ninja wants
to be able to chop paths up. But it doesn't hurt to also try to use
them in command line arguments.
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 17 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 11 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.h | 4 |
5 files changed, 25 insertions, 15 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index e9264ec..b1d8e5b 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 6f3c6b2..3f8644e 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 cf0e36a..28e8d47 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 1e31044..8a563b6 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 cf47abf..2986844 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(); } |