From bb014b0f4d0f01d4a37e23434116febfb2a9450e Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 11 Apr 2006 14:53:57 -0400 Subject: [PATCH] ENH: Restored implementation of AddCustomCommandToCreateObject. Updated it to use newer custom command functionality. --- Source/cmLocalGenerator.cxx | 61 +++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 5b86ff94e..695233880 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -472,6 +472,9 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, flags += this->Makefile->GetSafeDefinition(varString.c_str()); flags += " "; flags += this->GetIncludeFlags(lang); + + // Construct the command lines. + cmCustomCommandLines commandLines; std::vector commands; cmSystemTools::ExpandList(rules, commands); cmLocalGenerator::RuleVariables vars; @@ -482,39 +485,45 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, for(std::vector::iterator i = commands.begin(); i != commands.end(); ++i) { + // Expand the full command line string. this->ExpandRuleVariables(*i, vars); + + // Parse the string to get the custom command line. + cmCustomCommandLine commandLine; + std::vector cmd = cmSystemTools::ParseArguments(i->c_str()); + for(std::vector::iterator a = cmd.begin(); + a != cmd.end(); ++a) + { + commandLine.push_back(*a); + } + + // Store this command line. + commandLines.push_back(commandLine); } - std::vector sourceAndDeps; - sourceAndDeps.push_back(sourceFile); - if(commands.size() > 1) - { - cmSystemTools::Error("Currently custom rules can only have one command sorry "); - } - // Check for extra object-file dependencies. + + // Check for extra object-file dependencies. std::vector depends; const char* additionalDeps = source.GetProperty("OBJECT_DEPENDS"); if(additionalDeps) { cmSystemTools::ExpandListArgument(additionalDeps, depends); - for(std::vector::iterator i = depends.begin(); - i != depends.end(); ++i) - { - sourceAndDeps.push_back(this->Convert(i->c_str(),START_OUTPUT,SHELL)); - } - } -#if 0 - std::string command; - std::string args; - cmSystemTools::SplitProgramFromArgs(commands[0].c_str(), command, args); - std::vector argsv; - argsv.push_back(args); - this->Makefile->AddCustomCommandToOutput(ofname, - command.c_str(), - argsv, - source.GetFullPath().c_str(), - sourceAndDeps, - "build from source"); -#endif + } + + // Generate a meaningful comment for the command. + std::string comment = "Building "; + comment += lang; + comment += " object "; + comment += this->Convert(ofname, START_OUTPUT); + + // Add the custom command to build the object file. + this->Makefile->AddCustomCommandToOutput( + ofname, + depends, + source.GetFullPath().c_str(), + commandLines, + comment.c_str(), + this->Makefile->GetStartOutputDirectory() + ); } void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)