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/cmLocalUnixMakefileGenerator2.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/cmLocalUnixMakefileGenerator2.cxx')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator2.cxx | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx index 57ff0c9..400c3be 100644 --- a/Source/cmLocalUnixMakefileGenerator2.cxx +++ b/Source/cmLocalUnixMakefileGenerator2.cxx @@ -670,7 +670,7 @@ cmLocalUnixMakefileGenerator2 if(m_CustomRuleFiles.find(ruleFileName) != m_CustomRuleFiles.end()) { cmSystemTools::Error("An output was found with multiple rules on how to build it for output: ", - cc.GetOutput().c_str()); + cc.GetOutput()); return; } m_CustomRuleFiles.insert(ruleFileName); @@ -704,15 +704,15 @@ cmLocalUnixMakefileGenerator2 // Write the rule. const char* comment = 0; - if(cc.GetComment().size()) + if(cc.GetComment() && *cc.GetComment()) { - comment = cc.GetComment().c_str(); + comment = cc.GetComment(); } std::string preEcho = "Generating "; preEcho += customName; preEcho += "..."; this->WriteMakeRule(ruleFileStream, comment, preEcho.c_str(), - cc.GetOutput().c_str(), depends, commands); + cc.GetOutput(), depends, commands); // Write the clean rule for this custom command. std::string cleanTarget = customName; @@ -720,7 +720,7 @@ cmLocalUnixMakefileGenerator2 commands.clear(); depends.clear(); std::vector<std::string> cleanFiles; - cleanFiles.push_back(cc.GetOutput().c_str()); + cleanFiles.push_back(cc.GetOutput()); this->AppendCleanCommand(commands, cleanFiles); this->WriteMakeRule(ruleFileStream, "Clean the output of this custom command.", 0, @@ -2282,18 +2282,18 @@ cmLocalUnixMakefileGenerator2 // the custom file. Otherwise, we will use just the filename // portion. std::string customName; - if(cmSystemTools::FileIsFullPath(cc.GetOutput().c_str()) && - (cc.GetOutput().find(m_Makefile->GetStartOutputDirectory()) == 0)) + if(cmSystemTools::FileIsFullPath(cc.GetOutput()) && + (std::string(cc.GetOutput()).find(m_Makefile->GetStartOutputDirectory()) == 0)) { // Use the relative path but convert it to a valid file name. customName = cmSystemTools::RelativePath(m_Makefile->GetStartOutputDirectory(), - cc.GetOutput().c_str()); + cc.GetOutput()); cmSystemTools::ReplaceString(customName, "/", "_"); } else { - customName = cmSystemTools::GetFilenameName(cc.GetOutput().c_str()); + customName = cmSystemTools::GetFilenameName(cc.GetOutput()); } return customName; } @@ -2734,16 +2734,22 @@ cmLocalUnixMakefileGenerator2 { // TODO: Convert outputs/dependencies (arguments?) to relative paths. - // Build the command line in a single string. - std::string cmd = cc.GetCommand(); - cmSystemTools::ReplaceString(cmd, "/./", "/"); - cmd = this->ConvertToRelativeOutputPath(cmd.c_str()); - if(cc.GetArguments().size() > 0) + // Add each command line to the set of commands. + for(cmCustomCommandLines::const_iterator cl = cc.GetCommandLines().begin(); + cl != cc.GetCommandLines().end(); ++cl) { - cmd += " "; - cmd += cc.GetArguments(); + // 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); } - commands.push_back(cmd); } //---------------------------------------------------------------------------- |