diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index be9b0df43..b0a6e837b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2004,8 +2004,7 @@ cmGlobalGenerator::GetDirectoryContent(std::string const& dir, bool needDisk) //---------------------------------------------------------------------------- void cmGlobalGenerator::AddRuleHash(const std::vector& outputs, - std::vector::const_iterator first, - std::vector::const_iterator last) + std::string const& content) { #if defined(CMAKE_BUILD_WITH_CMAKE) // Ignore if there are no outputs. @@ -2017,16 +2016,12 @@ cmGlobalGenerator::AddRuleHash(const std::vector& outputs, // Compute a hash of the rule. RuleHash hash; { - unsigned char const* data; - int length; + unsigned char const* data = + reinterpret_cast(content.c_str()); + int length = static_cast(content.length()); cmsysMD5* sum = cmsysMD5_New(); cmsysMD5_Initialize(sum); - for(std::vector::const_iterator i = first; i != last; ++i) - { - data = reinterpret_cast(i->c_str()); - length = static_cast(i->length()); - cmsysMD5_Append(sum, data, length); - } + cmsysMD5_Append(sum, data, length); cmsysMD5_FinalizeHex(sum, hash.Data); cmsysMD5_Delete(sum); } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 51e462d91..60847c200 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -251,8 +251,7 @@ public: void GetFilesReplacedDuringGenerate(std::vector& filenames); void AddRuleHash(const std::vector& outputs, - std::vector::const_iterator first, - std::vector::const_iterator last); + std::string const& content); protected: // for a project collect all its targets by following depend diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 9517cd8e1..fad722db2 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -968,7 +968,8 @@ void cmLocalUnixMakefileGenerator3 ::AppendCustomCommand(std::vector& commands, const cmCustomCommand& cc, bool echo_comment, - cmLocalGenerator::RelativeRoot relative) + cmLocalGenerator::RelativeRoot relative, + std::ostream* content) { // Optionally create a command to display the custom command's // comment text. This is used for pre-build, pre-link, and @@ -991,6 +992,10 @@ cmLocalUnixMakefileGenerator3 { dir = workingDir; } + if(content) + { + *content << dir; + } bool escapeOldStyle = cc.GetEscapeOldStyle(); bool escapeAllowMakeVars = cc.GetEscapeAllowMakeVars(); @@ -1048,6 +1053,10 @@ cmLocalUnixMakefileGenerator3 escapeAllowMakeVars); } } + if(content) + { + *content << cmd; + } if(this->BorlandMakeCurlyHack) { // Borland Make has a very strange bug. If the first curly diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index ebb7c7975..b35bdbcfd 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -332,7 +332,8 @@ protected: const cmCustomCommand& cc, bool echo_comment=false, cmLocalGenerator::RelativeRoot relative = - cmLocalGenerator::HOME_OUTPUT); + cmLocalGenerator::HOME_OUTPUT, + std::ostream* content = 0); void AppendCleanCommand(std::vector& commands, const std::vector& files, cmTarget& target, const char* filename =0); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index e19cd1dd0..c2cad6673 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1119,11 +1119,12 @@ void cmMakefileTargetGenerator ->AppendEcho(commands, comment.c_str(), cmLocalUnixMakefileGenerator3::EchoGenerate); } - // Below we need to skip over the echo and progress commands. - unsigned int skip = static_cast(commands.size()); // Now append the actual user-specified commands. - this->LocalGenerator->AppendCustomCommand(commands, cc); + cmOStringStream content; + this->LocalGenerator->AppendCustomCommand(commands, cc, false, + cmLocalGenerator::HOME_OUTPUT, + &content); // Collect the dependencies. std::vector depends; @@ -1151,9 +1152,7 @@ void cmMakefileTargetGenerator // If the rule has changed make sure the output is rebuilt. if(!symbolic) { - this->GlobalGenerator->AddRuleHash(cc.GetOutputs(), - commands.begin()+skip, - commands.end()); + this->GlobalGenerator->AddRuleHash(cc.GetOutputs(), content.str()); } }