diff options
author | Nils Gladitz <nilsgladitz@gmail.com> | 2013-10-29 21:56:23 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-10-31 13:28:55 (GMT) |
commit | 05c70424f6fb3aac890f50aec067b60e997113b1 (patch) | |
tree | 2cf9cbf6e9708ffb9362f27ab424124af87f40f9 /Source | |
parent | 1665721c28daf8b20c054e3a3cc357fa778bb76e (diff) | |
download | CMake-05c70424f6fb3aac890f50aec067b60e997113b1.zip CMake-05c70424f6fb3aac890f50aec067b60e997113b1.tar.gz CMake-05c70424f6fb3aac890f50aec067b60e997113b1.tar.bz2 |
Ninja: run custom commands through launcher if available
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 44 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.h | 1 |
2 files changed, 43 insertions, 2 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index d95a213..f1d5e2c 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -318,9 +318,13 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, cdCmd << cdStr << this->ConvertToOutputFormat(wd, SHELL); cmdLines.push_back(cdCmd.str()); } + + std::string launcher = this->MakeCustomLauncher(*cc); + for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { - cmdLines.push_back(this->ConvertToOutputFormat(ccg.GetCommand(i).c_str(), - SHELL)); + cmdLines.push_back(launcher + + this->ConvertToOutputFormat(ccg.GetCommand(i).c_str(), SHELL)); + std::string& cmd = cmdLines.back(); ccg.AppendArguments(i, cmd); } @@ -407,3 +411,39 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements() this->WriteCustomCommandBuildStatement(i->first, ccTargetDeps); } } + +std::string cmLocalNinjaGenerator::MakeCustomLauncher( + const cmCustomCommand& cc) +{ + const char* property = "RULE_LAUNCH_CUSTOM"; + const char* property_value = this->Makefile->GetProperty(property); + + if(!property_value || !*property_value) + { + return std::string(); + } + + // Expand rules in the empty string. It may insert the launcher and + // perform replacements. + RuleVariables vars; + vars.RuleLauncher = property; + std::string output; + const std::vector<std::string>& outputs = cc.GetOutputs(); + if(!outputs.empty()) + { + RelativeRoot relative_root = + cc.GetWorkingDirectory() ? NONE : START_OUTPUT; + + output = this->Convert(outputs[0].c_str(), relative_root, SHELL); + } + vars.Output = output.c_str(); + + std::string launcher; + this->ExpandRuleVariables(launcher, vars); + if(!launcher.empty()) + { + launcher += " "; + } + + return launcher; +} diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index c450841..8eb63c5 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -121,6 +121,7 @@ private: void WriteCustomCommandBuildStatements(); + std::string MakeCustomLauncher(const cmCustomCommand& cc); std::string ConfigName; std::string HomeRelativeOutputPath; |