diff options
author | Brad King <brad.king@kitware.com> | 2005-02-22 15:32:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2005-02-22 15:32:44 (GMT) |
commit | 39af9ee1e496db77849015541f687897ed819a56 (patch) | |
tree | 79bd7c1765408c80822dc9b87853bdac24704332 /Source/cmLocalUnixMakefileGenerator.cxx | |
parent | 4d30cb309cc0cd191e89a7969599b79dea111a08 (diff) | |
download | CMake-39af9ee1e496db77849015541f687897ed819a56.zip CMake-39af9ee1e496db77849015541f687897ed819a56.tar.gz CMake-39af9ee1e496db77849015541f687897ed819a56.tar.bz2 |
ENH: Updated implementation of custom commands. Multiple command lines are now supported effectively allowing entire scripts to be written. Also removed extra variable expansions and cleaned up passing of commands through to the generators. The command and individual arguments are now kept separate all the way until the generator writes them out. This cleans up alot of escaping issues.
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator.cxx')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator.cxx | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx index 0236d74..9a881cc 100644 --- a/Source/cmLocalUnixMakefileGenerator.cxx +++ b/Source/cmLocalUnixMakefileGenerator.cxx @@ -663,8 +663,6 @@ std::string cmLocalUnixMakefileGenerator::CreatePreBuildRules( target.GetPreBuildCommands().begin(); cr != target.GetPreBuildCommands().end(); ++cr) { - cmCustomCommand cc(*cr); - cc.ExpandVariables(*m_Makefile); if(initNext) { customRuleCode += "\n\t"; @@ -673,8 +671,7 @@ std::string cmLocalUnixMakefileGenerator::CreatePreBuildRules( { initNext = true; } - std::string command = this->ConvertToRelativeOutputPath(cc.GetCommand().c_str()); - customRuleCode += command + " " + cc.GetArguments(); + customRuleCode += this->ConstructScript(cr->GetCommandLines(), "\n\t"); } return customRuleCode; } @@ -688,8 +685,6 @@ std::string cmLocalUnixMakefileGenerator::CreatePreLinkRules( target.GetPreLinkCommands().begin(); cr != target.GetPreLinkCommands().end(); ++cr) { - cmCustomCommand cc(*cr); - cc.ExpandVariables(*m_Makefile); if(initNext) { customRuleCode += "\n\t"; @@ -698,8 +693,7 @@ std::string cmLocalUnixMakefileGenerator::CreatePreLinkRules( { initNext = true; } - std::string command = this->ConvertToRelativeOutputPath(cc.GetCommand().c_str()); - customRuleCode += command + " " + cc.GetArguments(); + customRuleCode += this->ConstructScript(cr->GetCommandLines(), "\n\t"); } return customRuleCode; } @@ -713,8 +707,6 @@ std::string cmLocalUnixMakefileGenerator::CreatePostBuildRules( target.GetPostBuildCommands().begin(); cr != target.GetPostBuildCommands().end(); ++cr) { - cmCustomCommand cc(*cr); - cc.ExpandVariables(*m_Makefile); if(initNext) { customRuleCode += "\n\t"; @@ -723,8 +715,7 @@ std::string cmLocalUnixMakefileGenerator::CreatePostBuildRules( { initNext = true; } - std::string command = this->ConvertToRelativeOutputPath(cc.GetCommand().c_str()); - customRuleCode += command + " " + cc.GetArguments(); + customRuleCode += this->ConstructScript(cr->GetCommandLines(), "\n\t"); } return customRuleCode; } @@ -2025,12 +2016,24 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) // escape spaces and convert to native slashes path for // the command std::string comment = c->GetComment(); - std::string command = c->GetCommand(); - cmSystemTools::ReplaceString(command, "/./", "/"); - command = this->ConvertToRelativeOutputPath(command.c_str()); - command += " "; - // now add the arguments - command += c->GetArguments(); + std::vector<std::string> commands; + + // Add each command line to the set of commands. + for(cmCustomCommandLines::const_iterator cl = c->GetCommandLines().begin(); + cl != c->GetCommandLines().end(); ++cl) + { + // Build the command line in a single string. + const cmCustomCommandLine& commandLine = *cl; + std::string cmd = commandLine[0]; + cmSystemTools::ReplaceString(cmd, "/./", "/"); + cmd = this->ConvertToRelativeOutputPath(cmd.c_str()); + for(unsigned int j=1; j < commandLine.size(); ++j) + { + cmd += " "; + cmd += cmSystemTools::EscapeSpaces(commandLine[j].c_str()); + } + commands.push_back(cmd); + } std::vector<std::string> depends; // Collect out all the dependencies for this rule. for(std::vector<std::string>::const_iterator d = @@ -2066,15 +2069,15 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) { this->OutputMakeRule(fout, (comment.size()?comment.c_str():"Custom command"), - c->GetOutput().c_str(), + c->GetOutput(), depends, - command.c_str()); + commands); processedOutputs.insert(c->GetOutput()); } else { cmSystemTools::Error("An output was found with multiple rules on how to build it for output: ", - c->GetOutput().c_str()); + c->GetOutput()); } } } |