diff options
author | Brad King <brad.king@kitware.com> | 2014-03-10 17:53:57 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-12 14:44:00 (GMT) |
commit | d45e7f34611cd678bdda29d7d2b2ff4ce1abbce7 (patch) | |
tree | 8ebbe10ac12a7d52520ee22b01c6a4391e2dd319 /Source | |
parent | cb8f87f6229359790956a6640639bbe6b8c346f7 (diff) | |
download | CMake-d45e7f34611cd678bdda29d7d2b2ff4ce1abbce7.zip CMake-d45e7f34611cd678bdda29d7d2b2ff4ce1abbce7.tar.gz CMake-d45e7f34611cd678bdda29d7d2b2ff4ce1abbce7.tar.bz2 |
cmCustomCommand: Return std::string from GetWorkingDirectory
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCustomCommand.cxx | 10 | ||||
-rw-r--r-- | Source/cmCustomCommand.h | 7 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 13 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalVisualStudioGenerator.cxx | 8 |
7 files changed, 22 insertions, 29 deletions
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index b672148..ac2eef8 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -101,16 +101,6 @@ const std::vector<std::string>& cmCustomCommand::GetOutputs() const } //---------------------------------------------------------------------------- -const char* cmCustomCommand::GetWorkingDirectory() const -{ - if(this->WorkingDirectory.size() == 0) - { - return 0; - } - return this->WorkingDirectory.c_str(); -} - -//---------------------------------------------------------------------------- const std::vector<std::string>& cmCustomCommand::GetDepends() const { return this->Depends; diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 67c305e..b5d7e62 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -42,12 +42,13 @@ public: /** Get the output file produced by the command. */ const std::vector<std::string>& GetOutputs() const; - /** Get the working directory. */ - const char* GetWorkingDirectory() const; - /** Get the vector that holds the list of dependencies. */ const std::vector<std::string>& GetDepends() const; + /** Get the working directory. */ + std::string const& GetWorkingDirectory() const + { return this->WorkingDirectory; } + /** Get the list of command lines. */ const cmCustomCommandLines& GetCommandLines() const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 30a2a1e..16c74b9 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1646,10 +1646,11 @@ void cmGlobalXCodeGenerator cmSystemTools::ReplaceString(cmd2, "/./", "/"); cmd2 = this->ConvertToRelativeForMake(cmd2.c_str()); std::string cmd; - if(cc.GetWorkingDirectory()) + std::string wd = cc.GetWorkingDirectory(); + if(!wd.empty()) { cmd += "cd "; - cmd += this->ConvertToRelativeForMake(cc.GetWorkingDirectory()); + cmd += this->ConvertToRelativeForMake(wd.c_str()); cmd += " && "; } cmd += cmd2; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index acaacdd..d68a07b 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -364,8 +364,8 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, { cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); if (ccg.GetNumberOfCommands() > 0) { - const char* wd = cc->GetWorkingDirectory(); - if (!wd) + std::string wd = cc->GetWorkingDirectory(); + if (wd.empty()) wd = this->GetMakefile()->GetStartOutputDirectory(); cmOStringStream cdCmd; @@ -491,7 +491,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( if(!outputs.empty()) { RelativeRoot relative_root = - cc.GetWorkingDirectory() ? NONE : START_OUTPUT; + cc.GetWorkingDirectory().empty() ? START_OUTPUT : NONE; output = this->Convert(outputs[0], relative_root, SHELL); } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 3681e0e..d3f63f5 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1023,9 +1023,9 @@ cmLocalUnixMakefileGenerator3 } // if the command specified a working directory use it. - const char* dir = this->Makefile->GetStartOutputDirectory(); - const char* workingDir = cc.GetWorkingDirectory(); - if(workingDir) + std::string dir = this->Makefile->GetStartOutputDirectory(); + std::string workingDir = cc.GetWorkingDirectory(); + if(!workingDir.empty()) { dir = workingDir; } @@ -1066,7 +1066,7 @@ cmLocalUnixMakefileGenerator3 // Convert the command to a relative path only if the current // working directory will be the start-output directory. bool had_slash = cmd.find("/") != cmd.npos; - if(!workingDir) + if(workingDir.empty()) { cmd = this->Convert(cmd,START_OUTPUT); } @@ -1079,7 +1079,8 @@ cmLocalUnixMakefileGenerator3 cmd = "./" + cmd; } std::string launcher = - this->MakeLauncher(cc, target, workingDir? NONE : START_OUTPUT); + this->MakeLauncher(cc, target, + workingDir.empty()? START_OUTPUT : NONE); cmd = launcher + this->ConvertShellCommand(cmd, NONE); ccg.AppendArguments(c, cmd); @@ -1125,7 +1126,7 @@ cmLocalUnixMakefileGenerator3 } // Setup the proper working directory for the commands. - this->CreateCDCommand(commands1, dir, relative); + this->CreateCDCommand(commands1, dir.c_str(), relative); // push back the custom commands commands.insert(commands.end(), commands1.begin(), commands1.end()); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index f1fd994..d713024 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -583,7 +583,7 @@ cmLocalVisualStudio6Generator this->Makefile->AddCustomCommandToOutput( output, depends, no_main_dependency, origCommand.GetCommandLines(), comment.c_str(), - origCommand.GetWorkingDirectory())) + origCommand.GetWorkingDirectory().c_str())) { target.AddSourceFile(outsf); } diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 6e93d22..3075c15 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -84,9 +84,9 @@ cmLocalVisualStudioGenerator const std::string& newline_text) { bool useLocal = this->CustomCommandUseLocal(); - const char* workingDirectory = cc.GetWorkingDirectory(); + std::string workingDirectory = cc.GetWorkingDirectory(); cmCustomCommandGenerator ccg(cc, configName, this->Makefile); - RelativeRoot relativeRoot = workingDirectory? NONE : START_OUTPUT; + RelativeRoot relativeRoot = workingDirectory.empty()? START_OUTPUT : NONE; // Avoid leading or trailing newlines. std::string newline = ""; @@ -114,7 +114,7 @@ cmLocalVisualStudioGenerator script += "setlocal"; } - if(workingDirectory) + if(!workingDirectory.empty()) { // Change the working directory. script += newline; @@ -124,7 +124,7 @@ cmLocalVisualStudioGenerator script += check_error; // Change the working drive. - if(workingDirectory[0] && workingDirectory[1] == ':') + if(workingDirectory.size() > 1 && workingDirectory[1] == ':') { script += newline; newline = newline_text; |