diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-12-10 21:47:37 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-12-10 21:47:37 (GMT) |
commit | 3893ee72d2d5a04889cc1056b56029c9d60393c0 (patch) | |
tree | 3d96e526b726e7c0f2965489f74f2655776d6390 /Source | |
parent | ab64db6ee84604c361a2d6f279398f7c9d3247f5 (diff) | |
download | CMake-3893ee72d2d5a04889cc1056b56029c9d60393c0.zip CMake-3893ee72d2d5a04889cc1056b56029c9d60393c0.tar.gz CMake-3893ee72d2d5a04889cc1056b56029c9d60393c0.tar.bz2 |
Add comment support, so that you can see in build process what the custom command does
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmAddCustomCommandCommand.cxx | 20 | ||||
-rw-r--r-- | Source/cmAddCustomCommandCommand.h | 4 | ||||
-rw-r--r-- | Source/cmCustomCommand.cxx | 1 | ||||
-rw-r--r-- | Source/cmCustomCommand.h | 5 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 7 | ||||
-rw-r--r-- | Source/cmMakefile.h | 7 | ||||
-rw-r--r-- | Source/cmSourceGroup.cxx | 2 | ||||
-rw-r--r-- | Source/cmSourceGroup.h | 3 |
9 files changed, 41 insertions, 16 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 3717dd5..6b1c09c 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -32,7 +32,7 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args std::vector<std::string> args; cmSystemTools::ExpandListArguments(argsIn, args); - std::string source, command, target; + std::string source, command, target, comment; std::vector<std::string> command_args, depends, outputs; enum tdoing { @@ -42,6 +42,7 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args doing_args, doing_depends, doing_outputs, + doing_comment, doing_nothing }; @@ -75,6 +76,10 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args { doing = doing_outputs; } + else if (copy == "COMMENT") + { + doing = doing_comment; + } else { switch (doing) @@ -97,6 +102,9 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args case doing_outputs: outputs.push_back(copy); break; + case doing_comment: + comment = copy; + break; default: this->SetError("Wrong syntax. Unknow type of argument."); return false; @@ -108,12 +116,7 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args For the moment, let's say that COMMAND, TARGET are always required. */ - - if(command.empty()) - { - this->SetError("Wrong syntax. Empty COMMAND."); - return false; - } + if(target.empty()) { this->SetError("Wrong syntax. Empty TARGET."); @@ -133,7 +136,8 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args command_args, depends, outputs, - target.c_str()); + target.c_str(), + comment.c_str()); return true; } diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index 1f332c8..e2afc23 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -86,8 +86,8 @@ public: virtual const char* GetFullDocumentation() { return - "ADD_CUSTOM_COMMAND([SOURCE source] COMMAND command TARGET target " - "[ARGS [args...]] [DEPENDS [depends...]] [OUTPUTS [outputs...]])\n" + "ADD_CUSTOM_COMMAND([SOURCE source] [COMMAND command] TARGET target " + "[ARGS [args...]] [DEPENDS [depends...]] [OUTPUTS [outputs...]] [COMMENT comment])\n" "Add a custom command."; } diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index fee5866..d8fafe4 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -40,6 +40,7 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r): m_Source(r.m_Source), m_Command(r.m_Command), m_Arguments(r.m_Arguments), + m_Comment(r.m_Comment), m_Depends(r.m_Depends), m_Outputs(r.m_Outputs) { diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 3cf2681..9085177 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -54,6 +54,10 @@ public: std::string GetCommand() const {return m_Command;} void SetCommand(const char *cmd) {m_Command = cmd;} + ///! Return the command to execute + std::string GetComment() const {return m_Comment;} + void SetComment(const char *cm) {m_Comment = cm;} + ///! Return the commands arguments std::string GetArguments() const {return m_Arguments;} void SetArguments(const char *arg) {m_Arguments = arg;} @@ -74,6 +78,7 @@ private: std::string m_Source; std::string m_Command; std::string m_Arguments; + std::string m_Comment; std::vector<std::string> m_Depends; std::vector<std::string> m_Outputs; }; diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx index 84305f7..5e72e0f 100644 --- a/Source/cmLocalUnixMakefileGenerator.cxx +++ b/Source/cmLocalUnixMakefileGenerator.cxx @@ -1785,6 +1785,7 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) { // escape spaces and convert to native slashes path for // the command + const char* comment = c->second.m_Comment.c_str(); std::string command = c->second.m_Command; cmSystemTools::ReplaceString(command, "/./", "/"); command = cmSystemTools::ConvertToOutputPath(command.c_str()); @@ -1811,7 +1812,7 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) } // output rule this->OutputMakeRule(fout, - "Custom command", + (*comment?comment:"Custom command"), source.c_str(), depends.c_str(), command.c_str()); @@ -1838,7 +1839,7 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) } // output rule this->OutputMakeRule(fout, - "Custom command", + (*comment?comment:"Custom command"), output->c_str(), depends.c_str(), command.c_str()); @@ -2511,7 +2512,8 @@ void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout, { replace = *i; m_Makefile->ExpandVariablesInString(replace); - if(count == 0 && replace[0] != '-' && replace.find("echo") != 0 + if(count == 0 && replace.find_first_not_of(" \t\n\r") != std::string::npos && + replace[0] != '-' && replace.find("echo") != 0 && replace.find("$(MAKE)") != 0) { std::string echostring = "Building "; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 0fec989..9c5dc9f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -415,7 +415,8 @@ void cmMakefile::AddCustomCommand(const char* source, const std::vector<std::string>& commandArgs, const std::vector<std::string>& depends, const std::vector<std::string>& outputs, - const char *target) + const char *target, + const char *comment) { // find the target, if (m_Targets.find(target) != m_Targets.end()) @@ -434,6 +435,10 @@ void cmMakefile::AddCustomCommand(const char* source, } cmCustomCommand cc(source,c.c_str(),combinedArgs.c_str(),depends,outputs); + if ( comment && comment[0] ) + { + cc.SetComment(comment); + } m_Targets[target].GetCustomCommands().push_back(cc); std::string cacheCommand = command; this->ExpandVariablesInString(cacheCommand); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 8d1b546..dbb62af 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -123,7 +123,8 @@ public: const std::vector<std::string>& commandArgs, const std::vector<std::string>& depends, const std::vector<std::string>& outputs, - const char *target); + const char *target, + const char *comment = 0); void AddCustomCommand(const char* source, const char* command, @@ -260,6 +261,8 @@ public: { m_cmCurrentDirectory = m_cmStartDirectory; m_CurrentOutputDirectory = m_StartOutputDirectory; + this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", m_cmCurrentDirectory.c_str()); + this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", m_CurrentOutputDirectory.c_str()); } //@{ @@ -323,6 +326,7 @@ public: { m_cmCurrentDirectory = dir; cmSystemTools::ConvertToUnixSlashes(m_cmCurrentDirectory); + this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", m_cmCurrentDirectory.c_str()); } const char* GetCurrentDirectory() const { @@ -332,6 +336,7 @@ public: { m_CurrentOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(m_CurrentOutputDirectory); + this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", m_CurrentOutputDirectory.c_str()); } const char* GetCurrentOutputDirectory() const { diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index b94ad61..081f299 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -80,6 +80,7 @@ void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd) CommandFiles& cmdFiles = m_BuildRules[cmd.GetSourceName()].m_Commands[commandAndArgs]; cmdFiles.m_Command = cmd.GetCommand(); + cmdFiles.m_Comment = cmd.GetComment(); cmdFiles.m_Arguments = cmd.GetArguments(); cmdFiles.m_Depends.insert(cmd.GetDepends().begin(),cmd.GetDepends().end()); cmdFiles.m_Outputs.insert(cmd.GetOutputs().begin(),cmd.GetOutputs().end()); @@ -93,6 +94,7 @@ void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd) { // The command did not exist. Add it. commands[commandAndArgs].m_Command = cmd.GetCommand(); + commands[commandAndArgs].m_Comment = cmd.GetComment(); commands[commandAndArgs].m_Arguments = cmd.GetArguments(); commands[commandAndArgs].m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end()); diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index ebd23b1..6c3fe4d 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -39,12 +39,13 @@ public: { CommandFiles() {} CommandFiles(const CommandFiles& r): - m_Outputs(r.m_Outputs), m_Depends(r.m_Depends) {} + m_Comment(r.m_Comment), m_Outputs(r.m_Outputs), m_Depends(r.m_Depends) {} void Merge(const CommandFiles &r); std::string m_Command; std::string m_Arguments; + std::string m_Comment; std::set<std::string> m_Outputs; std::set<std::string> m_Depends; }; |