cmGlobalXCodeGenerator: Simplify handling of multiple outputs

Make the multiple output pair map more local.  Generate it where we
have the current configuration available.
This commit is contained in:
Brad King 2014-03-10 15:04:38 -04:00
parent d45e7f3461
commit 9a5c554414
2 changed files with 19 additions and 34 deletions

View File

@ -1470,32 +1470,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
const & commands, const & commands,
const char* name) const char* name)
{ {
bool haveMultipleOutputPairs = false;
// collect multiple outputs of custom commands into a set
// which will be used for every configuration
std::map<std::string, std::string> multipleOutputPairs;
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i)
{
cmCustomCommand const& cc = *i;
if(!cc.GetCommandLines().empty())
{
const std::vector<std::string>& outputs = cc.GetOutputs();
if(!outputs.empty())
{
// If there are more than one outputs treat the
// first as the primary output and make the rest depend on it.
std::vector<std::string>::const_iterator o = outputs.begin();
std::string primaryOutput = this->ConvertToRelativeForMake(o->c_str());
for(++o; o != outputs.end(); ++o)
{
std::string currentOutput=this->ConvertToRelativeForMake(o->c_str());
multipleOutputPairs[currentOutput] = primaryOutput;
}
}
}
}
std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory(); std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory();
dir += "/CMakeScripts"; dir += "/CMakeScripts";
cmSystemTools::MakeDirectory(dir.c_str()); cmSystemTools::MakeDirectory(dir.c_str());
@ -1515,7 +1490,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
target, target,
commands, commands,
currentConfig->c_str(), currentConfig->c_str(),
multipleOutputPairs); haveMultipleOutputPairs);
} }
std::string cdir = this->CurrentMakefile->GetCurrentOutputDirectory(); std::string cdir = this->CurrentMakefile->GetCurrentOutputDirectory();
@ -1525,7 +1500,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
makecmd += " -f "; makecmd += " -f ";
makecmd += this->ConvertToRelativeForMake( makecmd += this->ConvertToRelativeForMake(
(makefile+"$CONFIGURATION").c_str()); (makefile+"$CONFIGURATION").c_str());
if(!multipleOutputPairs.empty()) if(haveMultipleOutputPairs)
{ {
makecmd += " cmake_check_multiple_outputs"; makecmd += " cmake_check_multiple_outputs";
} }
@ -1544,9 +1519,7 @@ void cmGlobalXCodeGenerator
std::vector<cmCustomCommand> std::vector<cmCustomCommand>
const & commands, const & commands,
const std::string& configName, const std::string& configName,
const std::map<std::string, bool& haveMultipleOutputPairs)
std::string>& multipleOutputPairs
)
{ {
std::string makefileName=makefileBasename; std::string makefileName=makefileBasename;
if(this->XcodeVersion > 20) if(this->XcodeVersion > 20)
@ -1569,6 +1542,7 @@ void cmGlobalXCodeGenerator
makefileStream << "all: "; makefileStream << "all: ";
std::map<const cmCustomCommand*, std::string> tname; std::map<const cmCustomCommand*, std::string> tname;
int count = 0; int count = 0;
std::map<std::string, std::string> multipleOutputPairs;
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i) i != commands.end(); ++i)
{ {
@ -1584,6 +1558,16 @@ void cmGlobalXCodeGenerator
makefileStream makefileStream
<< "\\\n\t" << this->ConvertToRelativeForMake(o->c_str()); << "\\\n\t" << this->ConvertToRelativeForMake(o->c_str());
} }
// If there is more than one output treat the first as the
// primary output and make the rest depend on it.
std::vector<std::string>::const_iterator o = outputs.begin();
std::string primaryOutput = this->ConvertToRelativeForMake(o->c_str());
for(++o; o != outputs.end(); ++o)
{
std::string currentOutput=this->ConvertToRelativeForMake(o->c_str());
multipleOutputPairs[currentOutput] = primaryOutput;
}
} }
else else
{ {
@ -1683,6 +1667,9 @@ void cmGlobalXCodeGenerator
<< o->second << "; fi\n"; << o->second << "; fi\n";
} }
} }
haveMultipleOutputPairs =
haveMultipleOutputPairs || !multipleOutputPairs.empty();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -124,9 +124,7 @@ private:
cmTarget& target, cmTarget& target,
std::vector<cmCustomCommand> const & commands, std::vector<cmCustomCommand> const & commands,
const std::string& configName, const std::string& configName,
const std::map<std::string, std::string>& bool& haveMultipleOutputPairs);
multipleOutputPairs
);
cmXCodeObject* FindXCodeTarget(cmTarget const*); cmXCodeObject* FindXCodeTarget(cmTarget const*);
std::string GetOrCreateId(const std::string& name, const std::string& id); std::string GetOrCreateId(const std::string& name, const std::string& id);