summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaUtilityTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmNinjaUtilityTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.cxx96
1 files changed, 46 insertions, 50 deletions
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index 735730e..b0b1147 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -20,10 +20,14 @@
#include "cmSourceFile.h"
cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(
- cmGeneratorTarget *target)
- : cmNinjaTargetGenerator(target) {}
+ cmGeneratorTarget* target)
+ : cmNinjaTargetGenerator(target)
+{
+}
-cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {}
+cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator()
+{
+}
void cmNinjaUtilityTargetGenerator::Generate()
{
@@ -33,7 +37,7 @@ void cmNinjaUtilityTargetGenerator::Generate()
std::vector<std::string> commands;
cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName);
- const std::vector<cmCustomCommand> *cmdLists[2] = {
+ const std::vector<cmCustomCommand>* cmdLists[2] = {
&this->GetGeneratorTarget()->GetPreBuildCommands(),
&this->GetGeneratorTarget()->GetPostBuildCommands()
};
@@ -41,8 +45,9 @@ void cmNinjaUtilityTargetGenerator::Generate()
bool uses_terminal = false;
for (unsigned i = 0; i != 2; ++i) {
- for (std::vector<cmCustomCommand>::const_iterator
- ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) {
+ for (std::vector<cmCustomCommand>::const_iterator ci =
+ cmdLists[i]->begin();
+ ci != cmdLists[i]->end(); ++ci) {
cmCustomCommandGenerator ccg(*ci, this->GetConfigName(),
this->GetLocalGenerator());
this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps);
@@ -56,18 +61,16 @@ void cmNinjaUtilityTargetGenerator::Generate()
}
std::vector<cmSourceFile*> sources;
- std::string config = this->GetMakefile()
- ->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ std::string config =
+ this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->GetGeneratorTarget()->GetSourceFiles(sources, config);
- for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
- source != sources.end(); ++source)
- {
- if(cmCustomCommand* cc = (*source)->GetCustomCommand())
- {
+ for (std::vector<cmSourceFile*>::const_iterator source = sources.begin();
+ source != sources.end(); ++source) {
+ if (cmCustomCommand* cc = (*source)->GetCustomCommand()) {
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
this->GetLocalGenerator());
- this->GetLocalGenerator()->AddCustomCommandTarget(cc,
- this->GetGeneratorTarget());
+ this->GetLocalGenerator()->AddCustomCommandTarget(
+ cc, this->GetGeneratorTarget());
// Depend on all custom command outputs.
const std::vector<std::string>& ccOutputs = ccg.GetOutputs();
@@ -76,8 +79,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
std::back_inserter(deps), MapToNinjaPath());
std::transform(ccByproducts.begin(), ccByproducts.end(),
std::back_inserter(deps), MapToNinjaPath());
- }
}
+ }
this->GetLocalGenerator()->AppendTargetOutputs(this->GetGeneratorTarget(),
outputs);
@@ -85,16 +88,14 @@ void cmNinjaUtilityTargetGenerator::Generate()
deps);
if (commands.empty()) {
- this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
- "Utility command for "
- + this->GetTargetName(),
- outputs,
- deps);
+ this->GetGlobalGenerator()->WritePhonyBuild(
+ this->GetBuildFileStream(),
+ "Utility command for " + this->GetTargetName(), outputs, deps);
} else {
std::string command =
this->GetLocalGenerator()->BuildCommandLine(commands);
- const char *echoStr =
- this->GetGeneratorTarget()->GetProperty("EchoString");
+ const char* echoStr =
+ this->GetGeneratorTarget()->GetProperty("EchoString");
std::string desc;
if (echoStr)
desc = echoStr;
@@ -104,43 +105,38 @@ void cmNinjaUtilityTargetGenerator::Generate()
// TODO: fix problematic global targets. For now, search and replace the
// makefile vars.
cmSystemTools::ReplaceString(
- command,
- "$(CMAKE_SOURCE_DIR)",
- this->GetLocalGenerator()->ConvertToOutputFormat(
- this->GetLocalGenerator()->GetSourceDirectory(),
- cmLocalGenerator::SHELL).c_str());
+ command, "$(CMAKE_SOURCE_DIR)",
+ this->GetLocalGenerator()
+ ->ConvertToOutputFormat(
+ this->GetLocalGenerator()->GetSourceDirectory(),
+ cmLocalGenerator::SHELL)
+ .c_str());
cmSystemTools::ReplaceString(
- command,
- "$(CMAKE_BINARY_DIR)",
- this->GetLocalGenerator()->ConvertToOutputFormat(
- this->GetLocalGenerator()->GetBinaryDirectory(),
- cmLocalGenerator::SHELL).c_str());
+ command, "$(CMAKE_BINARY_DIR)",
+ this->GetLocalGenerator()
+ ->ConvertToOutputFormat(
+ this->GetLocalGenerator()->GetBinaryDirectory(),
+ cmLocalGenerator::SHELL)
+ .c_str());
cmSystemTools::ReplaceString(command, "$(ARGS)", "");
if (command.find('$') != std::string::npos)
return;
- for (cmNinjaDeps::const_iterator
- oi = util_outputs.begin(), oe = util_outputs.end();
- oi != oe; ++oi)
- {
+ for (cmNinjaDeps::const_iterator oi = util_outputs.begin(),
+ oe = util_outputs.end();
+ oi != oe; ++oi) {
this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi);
- }
+ }
this->GetGlobalGenerator()->WriteCustomCommandBuild(
- command,
- desc,
- "Utility command for " + this->GetTargetName(),
+ command, desc, "Utility command for " + this->GetTargetName(),
uses_terminal,
- /*restat*/true,
- util_outputs,
- deps);
-
- this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
- "",
- outputs,
- cmNinjaDeps(1, utilCommandName)
- );
+ /*restat*/ true, util_outputs, deps);
+
+ this->GetGlobalGenerator()->WritePhonyBuild(
+ this->GetBuildFileStream(), "", outputs,
+ cmNinjaDeps(1, utilCommandName));
}
this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),