From b0301db23b12351720993a351fedf081ca0fa444 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 9 Oct 2016 10:47:44 +0200 Subject: Makefiles: Make helper class independent of cmLocalGenerator It only needs output conversion. --- Source/cmMakefileTargetGenerator.cxx | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 14102ef..99a7fae 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1228,10 +1228,12 @@ class cmMakefileTargetGeneratorObjectStrings { public: cmMakefileTargetGeneratorObjectStrings(std::vector& strings, - cmLocalUnixMakefileGenerator3* lg, + cmOutputConverter* outputConverter, + cmState::Directory stateDir, std::string::size_type limit) : Strings(strings) - , LocalGenerator(lg) + , OutputConverter(outputConverter) + , StateDir(stateDir) , LengthLimit(limit) { this->Space = ""; @@ -1239,10 +1241,8 @@ public: void Feed(std::string const& obj) { // Construct the name of the next object. - this->NextObject = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->MaybeConvertToRelativePath( - this->LocalGenerator->GetCurrentBinaryDirectory(), obj), - cmOutputConverter::RESPONSE); + this->NextObject = this->OutputConverter->ConvertToOutputFormat( + this->MaybeConvertToRelativePath(obj), cmOutputConverter::RESPONSE); // Roll over to next string if the limit will be exceeded. if (this->LengthLimit != std::string::npos && @@ -1262,8 +1262,19 @@ public: } void Done() { this->Strings.push_back(this->CurrentString); } private: + std::string MaybeConvertToRelativePath(std::string const& obj) + { + if (!cmOutputConverter::ContainedInDirectory( + this->StateDir.GetCurrentBinary(), obj, this->StateDir)) { + return obj; + } + return cmOutputConverter::ForceToRelativePath( + this->StateDir.GetCurrentBinary(), obj); + } + std::vector& Strings; - cmLocalUnixMakefileGenerator3* LocalGenerator; + cmOutputConverter* OutputConverter; + cmState::Directory StateDir; std::string::size_type LengthLimit; std::string CurrentString; std::string NextObject; @@ -1273,8 +1284,9 @@ private: void cmMakefileTargetGenerator::WriteObjectsStrings( std::vector& objStrings, std::string::size_type limit) { - cmMakefileTargetGeneratorObjectStrings helper(objStrings, - this->LocalGenerator, limit); + cmMakefileTargetGeneratorObjectStrings helper( + objStrings, this->LocalGenerator, + this->LocalGenerator->GetStateSnapshot().GetDirectory(), limit); for (std::vector::const_iterator i = this->Objects.begin(); i != this->Objects.end(); ++i) { helper.Feed(*i); -- cgit v0.12