diff options
-rw-r--r-- | Source/cmLocalGenerator.cxx | 122 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 52 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 20 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 20 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 16 |
5 files changed, 101 insertions, 129 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e7d56a5..4b4b807 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -387,17 +387,15 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, flags += this->GetIncludeFlags(lang); std::vector<std::string> commands; cmSystemTools::ExpandList(rules, commands); + cmLocalGenerator::RuleVariables vars; + vars.Language = lang; + vars.Source = sourceFile.c_str(); + vars.Object = objectFile.c_str(); + vars.Flags = flags.c_str(); for(std::vector<std::string>::iterator i = commands.begin(); i != commands.end(); ++i) { - this->ExpandRuleVariables(*i, - lang, - 0, // no objects - 0, // no target - 0, // no link libs - sourceFile.c_str(), - objectFile.c_str(), - flags.c_str()); + this->ExpandRuleVariables(*i, vars); } std::vector<std::string> sourceAndDeps; sourceAndDeps.push_back(sourceFile); @@ -472,28 +470,14 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) std::string linkFlags; // should be set this->GetTargetFlags(linkLibs, flags, linkFlags, target); std::string rule = m_Makefile->GetRequiredDefinition(createRule.c_str()); - this->ExpandRuleVariables(rule, - llang, // language - objs.c_str(), // objects - targetName.c_str(), // target - linkLibs.c_str(), // link libs - 0, // source - 0, // object - flags.c_str(), // flags - 0, // objects quoted - 0, // target so name, - linkFlags.c_str() // link flags - ); -#if 0 - std::string command; - std::string args; - cmSystemTools::SplitProgramFromArgs(rule.c_str(), command, args); - // Just like ADD_CUSTOM_TARGET(foo ALL DEPENDS a.o b.o) - // Add a custom command for generating each .o file - cmCustomCommand cc(command.c_str(), args.c_str(), objVector, - targetName.c_str(), 0); - target.GetPostBuildCommands().push_back(cc); -#endif + cmLocalGenerator::RuleVariables vars; + vars.Language = llang; + vars.Objects = objs.c_str(); + vars.Target = targetName.c_str(); + vars.LinkLibraries = linkLibs.c_str(); + vars.Flags = flags.c_str(); + vars.LinkFlags = linkFlags.c_str(); + this->ExpandRuleVariables(rule, vars); } @@ -560,76 +544,67 @@ static const char* ruleReplaceVars[] = std::string cmLocalGenerator::ExpandRuleVariable(std::string const& variable, - const char* lang, - const char* objects, - const char* target, - const char* linkLibs, - const char* source, - const char* object, - const char* flags, - const char* objectsquoted, - const char* targetSOName, - const char* linkFlags) + const RuleVariables& replaceValues) { - if(linkFlags) + if(replaceValues.LinkFlags) { if(variable == "LINK_FLAGS") { - return linkFlags; + return replaceValues.LinkFlags; } } - if(flags) + if(replaceValues.Flags) { if(variable == "FLAGS") { - return flags; + return replaceValues.Flags; } } - if(source) + if(replaceValues.Source) { if(variable == "SOURCE") { - return source; + return replaceValues.Source; } } - if(object) + if(replaceValues.Object) { if(variable == "OBJECT") { - return object; + return replaceValues.Object; } } - if(objects) + if(replaceValues.Objects) { if(variable == "OBJECTS") { - return objects; + return replaceValues.Objects; } } - if(objectsquoted) + if(replaceValues.ObjectsQuoted) { if(variable == "OBJECTS_QUOTED") { - return objectsquoted; + return replaceValues.ObjectsQuoted; } } - if(target) + if(replaceValues.Target) { if(variable == "TARGET_QUOTED") { - std::string targetQuoted = target; + std::string targetQuoted = replaceValues.Target; if(targetQuoted.size() && targetQuoted[0] != '\"') { targetQuoted = '\"'; - targetQuoted += target; + targetQuoted += replaceValues.Target; targetQuoted += '\"'; return targetQuoted; } } if(variable == "TARGET") { - return target; + return replaceValues.Target; } if(variable == "TARGET_IMPLIB") { @@ -638,7 +613,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, if(variable == "TARGET_BASE") { // Strip the last extension off the target name. - std::string targetBase = target; + std::string targetBase = replaceValues.Target; std::string::size_type pos = targetBase.rfind("."); if(pos != targetBase.npos) { @@ -650,28 +625,28 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } } } - if(targetSOName) + if(replaceValues.TargetSOName) { if(variable == "TARGET_SONAME") { - if(lang) + if(replaceValues.Language) { std::string name = "CMAKE_SHARED_LIBRARY_SONAME_"; - name += lang; + name += replaceValues.Language; name += "_FLAG"; if(m_Makefile->GetDefinition(name.c_str())) { - return targetSOName; + return replaceValues.TargetSOName; } } return ""; } } - if(linkLibs) + if(replaceValues.LinkLibraries) { if(variable == "LINK_LIBRARIES") { - return linkLibs; + return replaceValues.LinkLibraries; } } std::vector<std::string> enabledLanguages; @@ -683,7 +658,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, for(std::vector<std::string>::iterator i = enabledLanguages.begin(); i != enabledLanguages.end(); ++i) { - lang = i->c_str(); + const char* lang = i->c_str(); std::string actualReplace = ruleReplaceVars[pos]; // If this is the compiler then look for the extra variable // _COMPILER_ARG1 which must be the first argument to the compiler @@ -724,16 +699,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, void cmLocalGenerator::ExpandRuleVariables(std::string& s, - const char* lang, - const char* objects, - const char* target, - const char* linkLibs, - const char* source, - const char* object, - const char* flags, - const char* objectsquoted, - const char* targetSOName, - const char* linkFlags) + const RuleVariables& replaceValues) { std::vector<std::string> enabledLanguages; m_GlobalGenerator->GetEnabledLanguages(enabledLanguages); @@ -764,12 +730,8 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s, { // extract the var std::string var = s.substr(start+1, end - start-1); - std::string replace = this->ExpandRuleVariable(var, lang, objects, - target, linkLibs, - source, object, flags, - objectsquoted, - targetSOName, - linkFlags); + std::string replace = this->ExpandRuleVariable(var, + replaceValues); expandedInput += s.substr(pos, start-pos); expandedInput += replace; // move to next one diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 80afb36..b94cbcc 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -180,30 +180,42 @@ protected: ///! put all the libraries for a target on into the given stream virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink); + // Create a struct to hold the varibles passed into + // ExpandRuleVariables + struct RuleVariables + { + RuleVariables() + { + this->Language= 0; + this->Objects= 0; + this->Target= 0; + this->LinkLibraries= 0; + this->Source= 0; + this->Object= 0; + this->Flags= 0; + this->ObjectsQuoted= 0; + this->TargetSOName= 0; + this->LinkFlags= 0; + } + const char* Language; + const char* Objects; + const char* Target; + const char* LinkLibraries; + const char* Source; + const char* Object; + const char* Flags; + const char* ObjectsQuoted; + const char* TargetSOName; + const char* LinkFlags; + }; + + // Expand rule variables in CMake of the type found in language rules void ExpandRuleVariables(std::string& string, - const char* language, - const char* objects=0, - const char* target=0, - const char* linkLibs=0, - const char* source=0, - const char* object =0, - const char* flags = 0, - const char* objectsquoted = 0, - const char* targetSOName = 0, - const char* linkFlags = 0); + const RuleVariables& replaceValues); // Expand rule variables in a single string std::string ExpandRuleVariable(std::string const& variable, - const char* lang, - const char* objects, - const char* target, - const char* linkLibs, - const char* source, - const char* object, - const char* flags, - const char* objectsquoted, - const char* targetSOName, - const char* linkFlags); + const RuleVariables& replaceValues); ///! Convert a target to a utility target for unsupported languages of a generator void AddBuildTargetRule(const char* llang, cmTarget& target); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index c953b72..5399151 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -294,21 +294,19 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cleanObjs += variableName; cleanObjs += ")"; + cmLocalGenerator::RuleVariables vars; + vars.Language = linkLanguage; + vars.Objects = buildObjs.c_str(); + vars.Target = targetOutPathReal.c_str(); + std::string linkString = linklibs.str(); + vars.LinkLibraries = linkString.c_str(); + vars.Flags = flags.c_str(); + vars.LinkFlags = linkFlags.c_str(); // Expand placeholders in the commands. for(std::vector<std::string>::iterator i = commands.begin(); i != commands.end(); ++i) { - this->LocalGenerator->ExpandRuleVariables(*i, - linkLanguage, - buildObjs.c_str(), - targetOutPathReal.c_str(), - linklibs.str().c_str(), - 0, - 0, - flags.c_str(), - 0, - 0, - linkFlags.c_str()); + this->LocalGenerator->ExpandRuleVariables(*i, vars); } // Write the build rule. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 9f5ce12..b18895f 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -381,20 +381,22 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string cleanObjs = "$("; cleanObjs += variableName; cleanObjs += ")"; - + cmLocalGenerator::RuleVariables vars; + vars.Language = linkLanguage; + vars.Objects = buildObjs.c_str(); + vars.Target = targetOutPathReal.c_str(); + std::string linkString = linklibs.str(); + vars.LinkLibraries = linkString.c_str(); + vars.ObjectsQuoted = buildObjs.c_str(); + vars.TargetSOName= targetNameSO.c_str(); + vars.LinkFlags = linkFlags.c_str(); + // Expand placeholders in the commands. this->LocalGenerator->m_TargetImplib = targetOutPathImport; for(std::vector<std::string>::iterator i = commands.begin(); i != commands.end(); ++i) { - this->LocalGenerator->ExpandRuleVariables(*i, - linkLanguage, - buildObjs.c_str(), - targetOutPathReal.c_str(), - linklibs.str().c_str(), - 0, 0, 0, buildObjs.c_str(), - targetNameSO.c_str(), - linkFlags.c_str()); + this->LocalGenerator->ExpandRuleVariables(*i, vars); } this->LocalGenerator->m_TargetImplib = ""; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ffda9f2..a21fe4e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -379,19 +379,17 @@ cmMakefileTargetGenerator std::string compileRule = this->Makefile->GetRequiredDefinition(compileRuleVar.c_str()); cmSystemTools::ExpandListArgument(compileRule, commands); - + cmLocalGenerator::RuleVariables vars; + vars.Language = lang; + vars.Source = sourceFile.c_str(); + vars.Object = relativeObj.c_str(); + vars.Flags = flags.c_str(); + // Expand placeholders in the commands. for(std::vector<std::string>::iterator i = commands.begin(); i != commands.end(); ++i) { - this->LocalGenerator->ExpandRuleVariables(*i, - lang, - 0, // no objects - 0, // no target - 0, // no link libs - sourceFile.c_str(), - relativeObj.c_str(), - flags.c_str()); + this->LocalGenerator->ExpandRuleVariables(*i, vars); } // Make the target dependency scanning rule include cmake-time-known |