commit ac1ac0fcf87dbff595400cef9e1f8ae213c33a8a Author: Jérôme Gardou Date: Tue Jun 28 19:02:12 2011 +0200 Implements raw replacement for IMPLICIT_DEPENDS_INCLUDE_TRANSFORM target property diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index a76b3af..881dc97 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -511,7 +511,7 @@ void cmDependsC::SetupTransforms() xform += tri->first; sep = "|"; } - xform += ")[ \t]*\\(([^),]*)\\)"; + xform += ")[ \t]*\\(?([^),]*)\\)?"; this->IncludeRegexTransform.compile(xform.c_str()); // Build a string that encodes all transformation rules and will @@ -522,8 +522,8 @@ void cmDependsC::SetupTransforms() { this->IncludeRegexTransformString += " "; this->IncludeRegexTransformString += tri->first; - this->IncludeRegexTransformString += "(%)="; - this->IncludeRegexTransformString += tri->second; + this->IncludeRegexTransformString += tri->second.equals; + this->IncludeRegexTransformString += tri->second.value; } } } @@ -534,13 +534,19 @@ void cmDependsC::ParseTransform(std::string const& xform) // A transform rule is of the form SOME_MACRO(%)=value-with-% // We can simply separate with "(%)=". std::string::size_type pos = xform.find("(%)="); + int substringPos = 4; + if(pos == xform.npos || pos == 0) + { + pos = xform.find("="); + substringPos = 1; + } if(pos == xform.npos || pos == 0) { return; } std::string name = xform.substr(0, pos); - std::string value = xform.substr(pos+4, xform.npos); - this->TransformRules[name] = value; + this->TransformRules[name].equals = xform.substr(pos, substringPos); + this->TransformRules[name].value = xform.substr(pos+substringPos, xform.npos); } //---------------------------------------------------------------------------- @@ -557,11 +563,16 @@ void cmDependsC::TransformLine(std::string& line) { return; } + if(tri->second.equals == "=") + { + line.replace(line.find(tri->first),tri->first.length(), tri->second.value); + return; + } // Construct the transformed line. std::string newline = this->IncludeRegexTransform.match(1); std::string arg = this->IncludeRegexTransform.match(4); - for(const char* c = tri->second.c_str(); *c; ++c) + for(const char* c = tri->second.value.c_str(); *c; ++c) { if(*c == '%') { diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index bd9a4b7..13b4ac3 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -58,7 +58,13 @@ protected: // Regex to transform #include lines. std::string IncludeRegexTransformString; cmsys::RegularExpression IncludeRegexTransform; - typedef std::map TransformRulesType; + class TransformRule + { + public: + cmStdString equals; + cmStdString value; + }; + typedef std::map TransformRulesType; TransformRulesType TransformRules; void SetupTransforms(); void ParseTransform(std::string const& xform);