diff options
author | Stephen Kelly <steveire@gmail.com> | 2014-03-11 15:35:58 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2014-03-13 14:27:23 (GMT) |
commit | d5b2e33be2119ad12744ed62920a8f8d9b6d705d (patch) | |
tree | 89ed0e46f942715ece3d00e649850af4c7b2d3bd /Source | |
parent | 82a7d54cfe75c399b66c888acfcb5ddb15af547b (diff) | |
download | CMake-d5b2e33be2119ad12744ed62920a8f8d9b6d705d.zip CMake-d5b2e33be2119ad12744ed62920a8f8d9b6d705d.tar.gz CMake-d5b2e33be2119ad12744ed62920a8f8d9b6d705d.tar.bz2 |
Makefiles: Compute local object files on demand.
Don't compute them up front.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalUnixMakefileGenerator3.cxx | 8 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 58 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.h | 8 |
3 files changed, 50 insertions, 24 deletions
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index f5c56a9..0e03e89 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -109,9 +109,6 @@ cmGlobalUnixMakefileGenerator3 ::ComputeTargetObjects(cmGeneratorTarget* gt) const { cmTarget* target = gt->Target; - cmLocalUnixMakefileGenerator3* lg = - static_cast<cmLocalUnixMakefileGenerator3*>(gt->LocalGenerator); - // Compute full path to object file directory for this target. std::string dir_max; dir_max += gt->Makefile->GetCurrentOutputDirectory(); @@ -128,12 +125,9 @@ cmGlobalUnixMakefileGenerator3 si != objectSources.end(); ++si) { cmSourceFile* sf = *si; - bool hasSourceExtension = true; std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max, - &hasSourceExtension); + ->GetObjectFileNameWithoutTarget(*sf, dir_max); gt->AddObject(sf, objectName); - lg->AddLocalObjectFile(target, sf, objectName, hasSourceExtension); } } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 9f12ffe..a838ce3 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -172,26 +172,57 @@ void cmLocalUnixMakefileGenerator3::Generate() } //---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::AddLocalObjectFile( - cmTarget* target, cmSourceFile* sf, std::string objNoTargetDir, - bool hasSourceExtension) +void cmLocalUnixMakefileGenerator3:: +GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles) { - if(cmSystemTools::FileIsFullPath(objNoTargetDir.c_str())) + std::set<std::string> emitted; + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator ti = targets.begin(); + ti != targets.end(); ++ti) { - objNoTargetDir = cmSystemTools::GetFilenameName(objNoTargetDir); + cmGeneratorTarget* gt = ti->second; + if (gt->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + std::vector<cmSourceFile*> objectSources; + gt->GetObjectSources(objectSources); + // Compute full path to object file directory for this target. + std::string dir_max; + dir_max += gt->Makefile->GetCurrentOutputDirectory(); + dir_max += "/"; + dir_max += this->GetTargetDirectory(*gt->Target); + dir_max += "/"; + // Compute the name of each object file. + for(std::vector<cmSourceFile*>::iterator + si = objectSources.begin(); + si != objectSources.end(); ++si) + { + cmSourceFile* sf = *si; + bool hasSourceExtension = true; + std::string objectName = this->GetObjectFileNameWithoutTarget(*sf, + dir_max, + &hasSourceExtension); + if(cmSystemTools::FileIsFullPath(objectName.c_str())) + { + objectName = cmSystemTools::GetFilenameName(objectName); + } + LocalObjectInfo& info = localObjectFiles[objectName]; + info.HasSourceExtension = hasSourceExtension; + info.push_back(LocalObjectEntry(gt->Target, sf->GetLanguage())); + } } - LocalObjectInfo& info = this->LocalObjectFiles[objNoTargetDir]; - info.HasSourceExtension = hasSourceExtension; - info.push_back(LocalObjectEntry(target, sf->GetLanguage())); } //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets (std::vector<std::string>& targets) { + std::map<std::string, LocalObjectInfo> localObjectFiles; + this->GetLocalObjectFiles(localObjectFiles); for (std::map<std::string, LocalObjectInfo>::iterator lo = - this->LocalObjectFiles.begin(); - lo != this->LocalObjectFiles.end(); ++lo) + localObjectFiles.begin(); + lo != localObjectFiles.end(); ++lo) { targets.push_back(lo->first); @@ -253,11 +284,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() bool do_assembly_rules = this->GetCreateAssemblySourceRules(); + std::map<std::string, LocalObjectInfo> localObjectFiles; + this->GetLocalObjectFiles(localObjectFiles); + // now write out the object rules // for each object file name for (std::map<std::string, LocalObjectInfo>::iterator lo = - this->LocalObjectFiles.begin(); - lo != this->LocalObjectFiles.end(); ++lo) + localObjectFiles.begin(); + lo != localObjectFiles.end(); ++lo) { // Add a convenience rule for building the object file. this->WriteObjectConvenienceRule(ruleFileStream, diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index d504247..27070e2 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -224,10 +224,6 @@ public: // write the target rules for the local Makefile into the stream void WriteLocalAllRules(std::ostream& ruleFileStream); - void AddLocalObjectFile(cmTarget* target, cmSourceFile* sf, - std::string objNoTargetDir, - bool hasSourceExtension); - std::vector<std::string> const& GetLocalHelp() { return this->LocalHelp; } /** Get whether to create rules to generate preprocessed and @@ -366,7 +362,9 @@ private: LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), HasAssembleRule(false) {} }; - std::map<std::string, LocalObjectInfo> LocalObjectFiles; + void GetLocalObjectFiles( + std::map<std::string, LocalObjectInfo> &localObjectFiles); + void WriteObjectConvenienceRule(std::ostream& ruleFileStream, const char* comment, const char* output, LocalObjectInfo const& info); |