diff options
author | Brad King <brad.king@kitware.com> | 2014-03-10 19:47:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-12 14:44:01 (GMT) |
commit | bc993f277ebd44fabe8312a85c5682eed011336d (patch) | |
tree | 3f385f5257072c0eb18aa64badfe282eb41e3996 /Source/cmLocalNinjaGenerator.cxx | |
parent | 9a5c55441418ef79415b9a1b99c35192d2b8c1b0 (diff) | |
download | CMake-bc993f277ebd44fabe8312a85c5682eed011336d.zip CMake-bc993f277ebd44fabe8312a85c5682eed011336d.tar.gz CMake-bc993f277ebd44fabe8312a85c5682eed011336d.tar.bz2 |
Generalize cmCustomCommandGenerator to more fields
Until now the cmCustomCommandGenerator was used only to compute the
command lines of a custom command. Generalize it to get the comment,
working directory, dependencies, and outputs of custom commands. Update
use in all generators to support this.
Diffstat (limited to 'Source/cmLocalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index d68a07b..7c4aab8 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -303,10 +303,11 @@ cmLocalNinjaGenerator this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs); } -void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, - cmNinjaDeps &ninjaDeps) +void cmLocalNinjaGenerator::AppendCustomCommandDeps( + cmCustomCommandGenerator const& ccg, + cmNinjaDeps &ninjaDeps) { - const std::vector<std::string> &deps = cc->GetDepends(); + const std::vector<std::string> &deps = ccg.GetDepends(); for (std::vector<std::string>::const_iterator i = deps.begin(); i != deps.end(); ++i) { std::string dep; @@ -359,12 +360,12 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( return cmd.str(); } -void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, - std::vector<std::string> &cmdLines) +void cmLocalNinjaGenerator::AppendCustomCommandLines( + cmCustomCommandGenerator const& ccg, + std::vector<std::string> &cmdLines) { - cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); if (ccg.GetNumberOfCommands() > 0) { - std::string wd = cc->GetWorkingDirectory(); + std::string wd = ccg.GetWorkingDirectory(); if (wd.empty()) wd = this->GetMakefile()->GetStartOutputDirectory(); @@ -378,7 +379,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, cmdLines.push_back(cdCmd.str()); } - std::string launcher = this->MakeCustomLauncher(*cc); + std::string launcher = this->MakeCustomLauncher(ccg); for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { cmdLines.push_back(launcher + @@ -396,19 +397,21 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) return; - const std::vector<std::string> &outputs = cc->GetOutputs(); + cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); + + const std::vector<std::string> &outputs = ccg.GetOutputs(); cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps; std::transform(outputs.begin(), outputs.end(), ninjaOutputs.begin(), MapToNinjaPath()); - this->AppendCustomCommandDeps(cc, ninjaDeps); + this->AppendCustomCommandDeps(ccg, ninjaDeps); for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); ++i) this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i); std::vector<std::string> cmdLines; - this->AppendCustomCommandLines(cc, cmdLines); + this->AppendCustomCommandLines(ccg, cmdLines); if (cmdLines.empty()) { this->GetGlobalNinjaGenerator()->WritePhonyBuild( @@ -423,7 +426,7 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( } else { this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild( this->BuildCommandLine(cmdLines), - this->ConstructComment(*cc), + this->ConstructComment(ccg), "Custom command for " + ninjaOutputs[0], ninjaOutputs, ninjaDeps, @@ -472,7 +475,7 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements() } std::string cmLocalNinjaGenerator::MakeCustomLauncher( - const cmCustomCommand& cc) + cmCustomCommandGenerator const& ccg) { const char* property = "RULE_LAUNCH_CUSTOM"; const char* property_value = this->Makefile->GetProperty(property); @@ -487,11 +490,11 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( RuleVariables vars; vars.RuleLauncher = property; std::string output; - const std::vector<std::string>& outputs = cc.GetOutputs(); + const std::vector<std::string>& outputs = ccg.GetOutputs(); if(!outputs.empty()) { RelativeRoot relative_root = - cc.GetWorkingDirectory().empty() ? START_OUTPUT : NONE; + ccg.GetWorkingDirectory().empty() ? START_OUTPUT : NONE; output = this->Convert(outputs[0], relative_root, SHELL); } |