cmLocalGenerator: Add ComputeObjectFilenames interface.
Implement it in the local generators and use it in the global generators.
This commit is contained in:
parent
9ad804ac7b
commit
f6da044080
@ -19,6 +19,7 @@
|
|||||||
#include "cmVersion.h"
|
#include "cmVersion.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja";
|
const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja";
|
||||||
const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja";
|
const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja";
|
||||||
@ -636,15 +637,21 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
|
|||||||
{
|
{
|
||||||
std::vector<cmSourceFile const*> objectSources;
|
std::vector<cmSourceFile const*> objectSources;
|
||||||
gt->GetObjectSources(objectSources);
|
gt->GetObjectSources(objectSources);
|
||||||
// Compute the name of each object file.
|
|
||||||
for(std::vector<cmSourceFile const*>::iterator
|
std::map<cmSourceFile const*, std::string> mapping;
|
||||||
si = objectSources.begin();
|
for(std::vector<cmSourceFile const*>::const_iterator it
|
||||||
si != objectSources.end(); ++si)
|
= objectSources.begin(); it != objectSources.end(); ++it)
|
||||||
{
|
{
|
||||||
cmSourceFile const* sf = *si;
|
mapping[*it];
|
||||||
std::string objectName = gt->LocalGenerator
|
}
|
||||||
->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory);
|
|
||||||
gt->AddObject(sf, objectName);
|
gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
|
||||||
|
|
||||||
|
for(std::map<cmSourceFile const*, std::string>::const_iterator it
|
||||||
|
= mapping.begin(); it != mapping.end(); ++it)
|
||||||
|
{
|
||||||
|
assert(!it->second.empty());
|
||||||
|
gt->AddObject(it->first, it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,15 +110,20 @@ cmGlobalUnixMakefileGenerator3
|
|||||||
{
|
{
|
||||||
std::vector<cmSourceFile const*> objectSources;
|
std::vector<cmSourceFile const*> objectSources;
|
||||||
gt->GetObjectSources(objectSources);
|
gt->GetObjectSources(objectSources);
|
||||||
// Compute the name of each object file.
|
|
||||||
for(std::vector<cmSourceFile const*>::iterator
|
std::map<cmSourceFile const*, std::string> mapping;
|
||||||
si = objectSources.begin();
|
for(std::vector<cmSourceFile const*>::const_iterator it
|
||||||
si != objectSources.end(); ++si)
|
= objectSources.begin(); it != objectSources.end(); ++it)
|
||||||
{
|
{
|
||||||
cmSourceFile const* sf = *si;
|
mapping[*it];
|
||||||
std::string objectName = gt->LocalGenerator
|
}
|
||||||
->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory);
|
|
||||||
gt->AddObject(sf, objectName);
|
gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
|
||||||
|
|
||||||
|
for(std::map<cmSourceFile const*, std::string>::const_iterator it
|
||||||
|
= mapping.begin(); it != mapping.end(); ++it)
|
||||||
|
{
|
||||||
|
gt->AddObject(it->first, it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,42 +122,22 @@ void
|
|||||||
cmGlobalVisualStudioGenerator
|
cmGlobalVisualStudioGenerator
|
||||||
::ComputeTargetObjects(cmGeneratorTarget* gt) const
|
::ComputeTargetObjects(cmGeneratorTarget* gt) const
|
||||||
{
|
{
|
||||||
cmLocalVisualStudioGenerator* lg =
|
|
||||||
static_cast<cmLocalVisualStudioGenerator*>(gt->LocalGenerator);
|
|
||||||
std::string dir_max = lg->ComputeLongestObjectDirectory(*gt->Target);
|
|
||||||
|
|
||||||
// Count the number of object files with each name. Note that
|
|
||||||
// windows file names are not case sensitive.
|
|
||||||
std::map<std::string, int> counts;
|
|
||||||
std::vector<cmSourceFile const*> objectSources;
|
std::vector<cmSourceFile const*> objectSources;
|
||||||
gt->GetObjectSources(objectSources);
|
gt->GetObjectSources(objectSources);
|
||||||
for(std::vector<cmSourceFile const*>::const_iterator
|
|
||||||
si = objectSources.begin();
|
std::map<cmSourceFile const*, std::string> mapping;
|
||||||
si != objectSources.end(); ++si)
|
for(std::vector<cmSourceFile const*>::const_iterator it
|
||||||
|
= objectSources.begin(); it != objectSources.end(); ++it)
|
||||||
{
|
{
|
||||||
cmSourceFile const* sf = *si;
|
mapping[*it];
|
||||||
std::string objectNameLower = cmSystemTools::LowerCase(
|
|
||||||
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
|
|
||||||
objectNameLower += ".obj";
|
|
||||||
counts[objectNameLower] += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For all source files producing duplicate names we need unique
|
gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
|
||||||
// object name computation.
|
|
||||||
for(std::vector<cmSourceFile const*>::const_iterator
|
for(std::map<cmSourceFile const*, std::string>::const_iterator it
|
||||||
si = objectSources.begin();
|
= mapping.begin(); it != mapping.end(); ++it)
|
||||||
si != objectSources.end(); ++si)
|
|
||||||
{
|
{
|
||||||
cmSourceFile const* sf = *si;
|
gt->AddObject(it->first, it->second);
|
||||||
std::string objectName =
|
|
||||||
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
|
|
||||||
objectName += ".obj";
|
|
||||||
if(counts[cmSystemTools::LowerCase(objectName)] > 1)
|
|
||||||
{
|
|
||||||
gt->AddExplicitObjectName(sf);
|
|
||||||
objectName = lg->GetObjectFileNameWithoutTarget(*sf, dir_max);
|
|
||||||
}
|
|
||||||
gt->AddObject(sf, objectName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3939,30 +3939,22 @@ void
|
|||||||
cmGlobalXCodeGenerator
|
cmGlobalXCodeGenerator
|
||||||
::ComputeTargetObjects(cmGeneratorTarget* gt) const
|
::ComputeTargetObjects(cmGeneratorTarget* gt) const
|
||||||
{
|
{
|
||||||
// Count the number of object files with each name. Warn about duplicate
|
|
||||||
// names since Xcode names them uniquely automatically with a numeric suffix
|
|
||||||
// to avoid exact duplicate file names. Note that Mac file names are not
|
|
||||||
// typically case sensitive, hence the LowerCase.
|
|
||||||
std::map<std::string, int> counts;
|
|
||||||
std::vector<cmSourceFile const*> objectSources;
|
std::vector<cmSourceFile const*> objectSources;
|
||||||
gt->GetObjectSources(objectSources);
|
gt->GetObjectSources(objectSources);
|
||||||
for(std::vector<cmSourceFile const*>::const_iterator
|
|
||||||
si = objectSources.begin();
|
std::map<cmSourceFile const*, std::string> mapping;
|
||||||
si != objectSources.end(); ++si)
|
for(std::vector<cmSourceFile const*>::const_iterator it
|
||||||
|
= objectSources.begin(); it != objectSources.end(); ++it)
|
||||||
{
|
{
|
||||||
cmSourceFile const* sf = *si;
|
mapping[*it];
|
||||||
std::string objectName =
|
}
|
||||||
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
|
|
||||||
objectName += ".o";
|
|
||||||
|
|
||||||
std::string objectNameLower = cmSystemTools::LowerCase(objectName);
|
gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
|
||||||
counts[objectNameLower] += 1;
|
|
||||||
if (2 == counts[objectNameLower])
|
|
||||||
{
|
|
||||||
// TODO: emit warning about duplicate name?
|
|
||||||
}
|
|
||||||
|
|
||||||
gt->AddObject(sf, objectName);
|
for(std::map<cmSourceFile const*, std::string>::const_iterator it
|
||||||
|
= mapping.begin(); it != mapping.end(); ++it)
|
||||||
|
{
|
||||||
|
gt->AddObject(it->first, it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3080,6 +3080,14 @@ cmLocalGenerator
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmLocalGenerator::ComputeObjectFilenames(
|
||||||
|
std::map<cmSourceFile const*, std::string>&,
|
||||||
|
cmGeneratorTarget const*)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string
|
std::string
|
||||||
cmLocalGenerator
|
cmLocalGenerator
|
||||||
|
@ -372,6 +372,10 @@ public:
|
|||||||
std::string& linkPath,
|
std::string& linkPath,
|
||||||
cmGeneratorTarget* target);
|
cmGeneratorTarget* target);
|
||||||
|
|
||||||
|
virtual void ComputeObjectFilenames(
|
||||||
|
std::map<cmSourceFile const*, std::string>& mapping,
|
||||||
|
cmGeneratorTarget const* gt = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///! put all the libraries for a target on into the given stream
|
///! put all the libraries for a target on into the given stream
|
||||||
virtual void OutputLinkLibraries(std::string& linkLibraries,
|
virtual void OutputLinkLibraries(std::string& linkLibraries,
|
||||||
|
@ -267,6 +267,20 @@ void cmLocalNinjaGenerator::SetConfigName()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmLocalNinjaGenerator::ComputeObjectFilenames(
|
||||||
|
std::map<cmSourceFile const*, std::string>& mapping,
|
||||||
|
cmGeneratorTarget const* gt)
|
||||||
|
{
|
||||||
|
for(std::map<cmSourceFile const*, std::string>::iterator
|
||||||
|
si = mapping.begin(); si != mapping.end(); ++si)
|
||||||
|
{
|
||||||
|
cmSourceFile const* sf = si->first;
|
||||||
|
si->second = this->GetObjectFileNameWithoutTarget(*sf,
|
||||||
|
gt->ObjectDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
|
void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
|
||||||
{
|
{
|
||||||
cmGlobalNinjaGenerator::WriteDivider(os);
|
cmGlobalNinjaGenerator::WriteDivider(os);
|
||||||
|
@ -101,6 +101,10 @@ public:
|
|||||||
virtual std::string ConvertToLinkReference(std::string const& lib,
|
virtual std::string ConvertToLinkReference(std::string const& lib,
|
||||||
OutputFormat format = SHELL);
|
OutputFormat format = SHELL);
|
||||||
|
|
||||||
|
virtual void ComputeObjectFilenames(
|
||||||
|
std::map<cmSourceFile const*, std::string>& mapping,
|
||||||
|
cmGeneratorTarget const* gt = 0);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual std::string ConvertToIncludeReference(std::string const& path,
|
virtual std::string ConvertToIncludeReference(std::string const& path,
|
||||||
|
@ -171,6 +171,20 @@ void cmLocalUnixMakefileGenerator3::Generate()
|
|||||||
this->WriteDirectoryInformationFile();
|
this->WriteDirectoryInformationFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames(
|
||||||
|
std::map<cmSourceFile const*, std::string>& mapping,
|
||||||
|
cmGeneratorTarget const* gt)
|
||||||
|
{
|
||||||
|
for(std::map<cmSourceFile const*, std::string>::iterator
|
||||||
|
si = mapping.begin(); si != mapping.end(); ++si)
|
||||||
|
{
|
||||||
|
cmSourceFile const* sf = si->first;
|
||||||
|
si->second = this->GetObjectFileNameWithoutTarget(*sf,
|
||||||
|
gt->ObjectDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmLocalUnixMakefileGenerator3::
|
void cmLocalUnixMakefileGenerator3::
|
||||||
GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
|
GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
|
||||||
|
@ -313,6 +313,10 @@ private:
|
|||||||
std::string MakeLauncher(cmCustomCommandGenerator const& ccg,
|
std::string MakeLauncher(cmCustomCommandGenerator const& ccg,
|
||||||
cmTarget* target, RelativeRoot relative);
|
cmTarget* target, RelativeRoot relative);
|
||||||
|
|
||||||
|
virtual void ComputeObjectFilenames(
|
||||||
|
std::map<cmSourceFile const*, std::string>& mapping,
|
||||||
|
cmGeneratorTarget const* gt = 0);
|
||||||
|
|
||||||
friend class cmMakefileTargetGenerator;
|
friend class cmMakefileTargetGenerator;
|
||||||
friend class cmMakefileExecutableTargetGenerator;
|
friend class cmMakefileExecutableTargetGenerator;
|
||||||
friend class cmMakefileLibraryTargetGenerator;
|
friend class cmMakefileLibraryTargetGenerator;
|
||||||
|
@ -30,6 +30,46 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
|
||||||
|
std::map<cmSourceFile const*, std::string>& mapping,
|
||||||
|
cmGeneratorTarget const* gt)
|
||||||
|
{
|
||||||
|
std::string dir_max = this->ComputeLongestObjectDirectory(*gt->Target);
|
||||||
|
|
||||||
|
// Count the number of object files with each name. Note that
|
||||||
|
// windows file names are not case sensitive.
|
||||||
|
std::map<std::string, int> counts;
|
||||||
|
|
||||||
|
for(std::map<cmSourceFile const*, std::string>::iterator
|
||||||
|
si = mapping.begin(); si != mapping.end(); ++si)
|
||||||
|
{
|
||||||
|
cmSourceFile const* sf = si->first;
|
||||||
|
std::string objectNameLower = cmSystemTools::LowerCase(
|
||||||
|
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
|
||||||
|
objectNameLower += ".obj";
|
||||||
|
counts[objectNameLower] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For all source files producing duplicate names we need unique
|
||||||
|
// object name computation.
|
||||||
|
|
||||||
|
for(std::map<cmSourceFile const*, std::string>::iterator
|
||||||
|
si = mapping.begin(); si != mapping.end(); ++si)
|
||||||
|
{
|
||||||
|
cmSourceFile const* sf = si->first;
|
||||||
|
std::string objectName =
|
||||||
|
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
|
||||||
|
objectName += ".obj";
|
||||||
|
if(counts[cmSystemTools::LowerCase(objectName)] > 1)
|
||||||
|
{
|
||||||
|
const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf);
|
||||||
|
objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max);
|
||||||
|
}
|
||||||
|
si->second = objectName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmsys::auto_ptr<cmCustomCommand>
|
cmsys::auto_ptr<cmCustomCommand>
|
||||||
cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target,
|
cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target,
|
||||||
|
@ -61,6 +61,10 @@ public:
|
|||||||
|
|
||||||
virtual void AddCMakeListsRules() = 0;
|
virtual void AddCMakeListsRules() = 0;
|
||||||
|
|
||||||
|
virtual void ComputeObjectFilenames(
|
||||||
|
std::map<cmSourceFile const*, std::string>& mapping,
|
||||||
|
cmGeneratorTarget const* = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual const char* ReportErrorLabel() const;
|
virtual const char* ReportErrorLabel() const;
|
||||||
virtual bool CustomCommandUseLocal() const { return false; }
|
virtual bool CustomCommandUseLocal() const { return false; }
|
||||||
|
@ -71,3 +71,31 @@ void cmLocalXCodeGenerator::GenerateInstallRules()
|
|||||||
t->HasMacOSXRpathInstallNameDir("");
|
t->HasMacOSXRpathInstallNameDir("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmLocalXCodeGenerator::ComputeObjectFilenames(
|
||||||
|
std::map<cmSourceFile const*, std::string>& mapping,
|
||||||
|
cmGeneratorTarget const*)
|
||||||
|
{
|
||||||
|
// Count the number of object files with each name. Warn about duplicate
|
||||||
|
// names since Xcode names them uniquely automatically with a numeric suffix
|
||||||
|
// to avoid exact duplicate file names. Note that Mac file names are not
|
||||||
|
// typically case sensitive, hence the LowerCase.
|
||||||
|
std::map<std::string, int> counts;
|
||||||
|
for(std::map<cmSourceFile const*, std::string>::iterator
|
||||||
|
si = mapping.begin(); si != mapping.end(); ++si)
|
||||||
|
{
|
||||||
|
cmSourceFile const* sf = si->first;
|
||||||
|
std::string objectName =
|
||||||
|
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
|
||||||
|
objectName += ".o";
|
||||||
|
|
||||||
|
std::string objectNameLower = cmSystemTools::LowerCase(objectName);
|
||||||
|
counts[objectNameLower] += 1;
|
||||||
|
if (2 == counts[objectNameLower])
|
||||||
|
{
|
||||||
|
// TODO: emit warning about duplicate name?
|
||||||
|
}
|
||||||
|
si->second = objectName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -32,6 +32,9 @@ public:
|
|||||||
const std::string& rawFlag);
|
const std::string& rawFlag);
|
||||||
virtual void Generate();
|
virtual void Generate();
|
||||||
virtual void GenerateInstallRules();
|
virtual void GenerateInstallRules();
|
||||||
|
virtual void ComputeObjectFilenames(
|
||||||
|
std::map<cmSourceFile const*, std::string>& mapping,
|
||||||
|
cmGeneratorTarget const* gt = 0);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user