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.
This commit is contained in:
parent
9362440a0b
commit
cea03e632b
@ -84,6 +84,15 @@ std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string &lit)
|
|||||||
return result;
|
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,
|
void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
|
||||||
const std::string& comment,
|
const std::string& comment,
|
||||||
const std::string& rule,
|
const std::string& rule,
|
||||||
@ -122,7 +131,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
|
|||||||
for(cmNinjaDeps::const_iterator i = outputs.begin();
|
for(cmNinjaDeps::const_iterator i = outputs.begin();
|
||||||
i != outputs.end();
|
i != outputs.end();
|
||||||
++i)
|
++i)
|
||||||
builds << " " << EncodeIdent(*i, os);
|
builds << " " << EncodeIdent(EncodePath(*i), os);
|
||||||
builds << ":";
|
builds << ":";
|
||||||
|
|
||||||
// Write the rule.
|
// Write the rule.
|
||||||
@ -132,7 +141,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
|
|||||||
for(cmNinjaDeps::const_iterator i = explicitDeps.begin();
|
for(cmNinjaDeps::const_iterator i = explicitDeps.begin();
|
||||||
i != explicitDeps.end();
|
i != explicitDeps.end();
|
||||||
++i)
|
++i)
|
||||||
builds << " " << EncodeIdent(*i, os);
|
builds << " " << EncodeIdent(EncodePath(*i), os);
|
||||||
|
|
||||||
// Write implicit dependencies.
|
// Write implicit dependencies.
|
||||||
if(!implicitDeps.empty())
|
if(!implicitDeps.empty())
|
||||||
@ -141,7 +150,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
|
|||||||
for(cmNinjaDeps::const_iterator i = implicitDeps.begin();
|
for(cmNinjaDeps::const_iterator i = implicitDeps.begin();
|
||||||
i != implicitDeps.end();
|
i != implicitDeps.end();
|
||||||
++i)
|
++i)
|
||||||
builds << " " << EncodeIdent(*i, os);
|
builds << " " << EncodeIdent(EncodePath(*i), os);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write order-only dependencies.
|
// Write order-only dependencies.
|
||||||
@ -151,7 +160,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
|
|||||||
for(cmNinjaDeps::const_iterator i = orderOnlyDeps.begin();
|
for(cmNinjaDeps::const_iterator i = orderOnlyDeps.begin();
|
||||||
i != orderOnlyDeps.end();
|
i != orderOnlyDeps.end();
|
||||||
++i)
|
++i)
|
||||||
builds << " " << EncodeIdent(*i, os);
|
builds << " " << EncodeIdent(EncodePath(*i), os);
|
||||||
}
|
}
|
||||||
|
|
||||||
builds << "\n";
|
builds << "\n";
|
||||||
|
@ -59,6 +59,7 @@ public:
|
|||||||
|
|
||||||
static std::string EncodeIdent(const std::string &ident, std::ostream &vars);
|
static std::string EncodeIdent(const std::string &ident, std::ostream &vars);
|
||||||
static std::string EncodeLiteral(const std::string &lit);
|
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
|
* Write the given @a comment to the output stream @a os. It
|
||||||
|
@ -28,6 +28,9 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator()
|
|||||||
, HomeRelativeOutputPath("")
|
, HomeRelativeOutputPath("")
|
||||||
{
|
{
|
||||||
this->IsMakefileGenerator = true;
|
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)
|
std::string cmLocalNinjaGenerator::ConvertToNinjaPath(const char *path)
|
||||||
{
|
{
|
||||||
return this->Convert(path,
|
std::string convPath = this->Convert(path, cmLocalGenerator::HOME_OUTPUT);
|
||||||
cmLocalGenerator::HOME_OUTPUT,
|
#ifdef _WIN32
|
||||||
cmLocalGenerator::MAKEFILE);
|
cmSystemTools::ReplaceString(convPath, "/", "\\");
|
||||||
|
#endif
|
||||||
|
return convPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -212,13 +212,6 @@ ComputeDefines(cmSourceFile *source, const std::string& language)
|
|||||||
return defines;
|
return defines;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmNinjaTargetGenerator::ConvertToNinjaPath(const char *path) const
|
|
||||||
{
|
|
||||||
return this->LocalGenerator->Convert(path,
|
|
||||||
cmLocalGenerator::HOME_OUTPUT,
|
|
||||||
cmLocalGenerator::MAKEFILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
|
cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
|
||||||
{
|
{
|
||||||
// Static libraries never depend on other targets for linking.
|
// Static libraries never depend on other targets for linking.
|
||||||
|
@ -75,7 +75,9 @@ protected:
|
|||||||
std::string ComputeDefines(cmSourceFile *source,
|
std::string ComputeDefines(cmSourceFile *source,
|
||||||
const std::string& language);
|
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 {
|
cmLocalNinjaGenerator::map_to_ninja_path MapToNinjaPath() const {
|
||||||
return this->GetLocalGenerator()->MapToNinjaPath();
|
return this->GetLocalGenerator()->MapToNinjaPath();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user