From f03d446e967af91460ff31eb52d840983b3d8cec Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 8 Oct 2016 12:21:39 +0200 Subject: cmLinkLineComputer: Move FrameworkPath computation from cmLocalGenerator Add UseWatcomQuote state, and remove corresponding method parameters. --- Source/cmGhsMultiTargetGenerator.cxx | 3 ++- Source/cmLinkLineComputer.cxx | 16 ++++++++++++++++ Source/cmLinkLineComputer.h | 3 +++ Source/cmLocalGenerator.cxx | 23 +++++------------------ Source/cmLocalGenerator.h | 4 ++-- Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmMakefileTargetGenerator.cxx | 5 ++--- Source/cmMakefileTargetGenerator.h | 3 +-- Source/cmNinjaNormalTargetGenerator.cxx | 8 ++++---- Source/cmServerProtocol.cxx | 2 +- Source/cmake.cxx | 2 +- 12 files changed, 39 insertions(+), 34 deletions(-) diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 04c45e5..5fbaea4 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -367,10 +367,11 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries( this->GetGlobalGenerator()->CreateLinkLineComputer( this->LocalGenerator, this->LocalGenerator->GetStateSnapshot().GetDirectory())); + linkLineComputer->SetUseWatcomQuote(useWatcomQuote); this->LocalGenerator->GetTargetFlags( linkLineComputer.get(), config, linkLibraries, flags, linkFlags, - frameworkPath, linkPath, this->GeneratorTarget, useWatcomQuote); + frameworkPath, linkPath, this->GeneratorTarget); linkFlags = cmSystemTools::TrimWhitespace(linkFlags); if (!linkPath.empty()) { diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index 3675887..41096ef 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -136,3 +136,19 @@ std::string cmLinkLineComputer::ComputeRPath(cmComputeLinkInformation& cli) } return rpath; } + +std::string cmLinkLineComputer::ComputeFrameworkPath( + cmComputeLinkInformation& cli, std::string const& fwSearchFlag) +{ + std::string frameworkPath; + if (!fwSearchFlag.empty()) { + std::vector const& fwDirs = cli.GetFrameworkPaths(); + for (std::vector::const_iterator fdi = fwDirs.begin(); + fdi != fwDirs.end(); ++fdi) { + frameworkPath += fwSearchFlag; + frameworkPath += this->ConvertToOutputFormat(*fdi); + frameworkPath += " "; + } + } + return frameworkPath; +} diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h index d33e832..f72368a 100644 --- a/Source/cmLinkLineComputer.h +++ b/Source/cmLinkLineComputer.h @@ -30,6 +30,9 @@ public: std::string ComputeRPath(cmComputeLinkInformation& cli); + std::string ComputeFrameworkPath(cmComputeLinkInformation& cli, + std::string const& fwSearchFlag); + private: std::string ConvertToOutputFormat(std::string const& input); std::string ConvertToOutputForExisting(std::string const& input); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index d41399a..ef9e355 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1151,8 +1151,7 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, void cmLocalGenerator::GetTargetFlags( cmLinkLineComputer* linkLineComputer, const std::string& config, std::string& linkLibs, std::string& flags, std::string& linkFlags, - std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target, - bool useWatcomQuote) + std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target) { const std::string buildType = cmSystemTools::UpperCase(config); cmComputeLinkInformation* pcli = target->GetLinkInformation(config); @@ -1208,8 +1207,7 @@ void cmLocalGenerator::GetTargetFlags( } if (pcli) { this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs, - frameworkPath, linkPath, false, - useWatcomQuote); + frameworkPath, linkPath, false); } } break; case cmState::EXECUTABLE: { @@ -1231,8 +1229,7 @@ void cmLocalGenerator::GetTargetFlags( this->AddLanguageFlags(flags, linkLanguage, buildType); if (pcli) { this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs, - frameworkPath, linkPath, false, - useWatcomQuote); + frameworkPath, linkPath, false); } if (cmSystemTools::IsOn( this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { @@ -1400,10 +1397,8 @@ std::string cmLocalGenerator::GetTargetFortranFlags( void cmLocalGenerator::OutputLinkLibraries( cmComputeLinkInformation* pcli, cmLinkLineComputer* linkLineComputer, std::string& linkLibraries, std::string& frameworkPath, - std::string& linkPath, bool forResponseFile, bool useWatcomQuote) + std::string& linkPath, bool forResponseFile) { - OutputFormat shellFormat = - (forResponseFile) ? RESPONSE : ((useWatcomQuote) ? WATCOMQUOTE : SHELL); cmComputeLinkInformation& cli = *pcli; std::string linkLanguage = cli.GetLinkLanguage(); @@ -1428,16 +1423,8 @@ void cmLocalGenerator::OutputLinkLibraries( fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG"; std::string fwSearchFlag = this->Makefile->GetSafeDefinition(fwSearchFlagVar); - if (!fwSearchFlag.empty()) { - std::vector const& fwDirs = cli.GetFrameworkPaths(); - for (std::vector::const_iterator fdi = fwDirs.begin(); - fdi != fwDirs.end(); ++fdi) { - frameworkPath += fwSearchFlag; - frameworkPath += this->ConvertToOutputFormat(*fdi, shellFormat); - frameworkPath += " "; - } - } + frameworkPath = linkLineComputer->ComputeFrameworkPath(cli, fwSearchFlag); linkPath = linkLineComputer->ComputeLinkPath(cli, libPathFlag, libPathTerminator); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 75e01cb..4729acb 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -318,7 +318,7 @@ public: const std::string& config, std::string& linkLibs, std::string& flags, std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, - cmGeneratorTarget* target, bool useWatcomQuote); + cmGeneratorTarget* target); void GetTargetDefines(cmGeneratorTarget const* target, std::string const& config, std::string const& lang, std::set& defines) const; @@ -352,7 +352,7 @@ protected: cmLinkLineComputer* linkLineComputer, std::string& linkLibraries, std::string& frameworkPath, std::string& linkPath, - bool forResponseFile, bool useWatcomQuote); + bool forResponseFile); // Expand rule variables in CMake of the type found in language rules void ExpandRuleVariables(std::string& string, diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index f17e012..bfc4857 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -315,7 +315,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Collect up flags to link in needed libraries. std::string linkLibs; this->CreateLinkLibs(linkLineComputer.get(), linkLibs, - useResponseFileForLibs, depends, useWatcomQuote); + useResponseFileForLibs, depends); // Construct object file lists that may be needed to expand the // rule. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index e0934b5..4488f06 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -514,7 +514,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( linkLineComputer->SetRelink(relink); this->CreateLinkLibs(linkLineComputer.get(), linkLibs, - useResponseFileForLibs, depends, useWatcomQuote); + useResponseFileForLibs, depends); } // Construct object file lists that may be needed to expand the diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 2c0c91c..e93c31d 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1602,8 +1602,7 @@ cmLinkLineComputer* cmMakefileTargetGenerator::CreateLinkLineComputer( void cmMakefileTargetGenerator::CreateLinkLibs( cmLinkLineComputer* linkLineComputer, std::string& linkLibs, - bool useResponseFile, std::vector& makefile_depends, - bool useWatcomQuote) + bool useResponseFile, std::vector& makefile_depends) { std::string frameworkPath; std::string linkPath; @@ -1612,7 +1611,7 @@ void cmMakefileTargetGenerator::CreateLinkLibs( this->GeneratorTarget->GetLinkInformation(config); this->LocalGenerator->OutputLinkLibraries(pcli, linkLineComputer, linkLibs, frameworkPath, linkPath, - useResponseFile, useWatcomQuote); + useResponseFile); linkLibs = frameworkPath + linkPath + linkLibs; if (useResponseFile && linkLibs.find_first_not_of(' ') != linkLibs.npos) { diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 846b310..526cbcd 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -155,8 +155,7 @@ protected: /** Create list of flags for link libraries. */ void CreateLinkLibs(cmLinkLineComputer* linkLineComputer, std::string& linkLibs, bool useResponseFile, - std::vector& makefile_depends, - bool useWatcomQuote); + std::vector& makefile_depends); /** Create lists of object files for linking and cleaning. */ void CreateObjectLists(bool useLinkScript, bool useArchiveRules, diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index a458bbb..ab086eb 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -475,11 +475,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->GetGlobalGenerator()->CreateLinkLineComputer( this->GetLocalGenerator(), this->GetLocalGenerator()->GetStateSnapshot().GetDirectory())); + linkLineComputer->SetUseWatcomQuote(useWatcomQuote); - localGen.GetTargetFlags(linkLineComputer.get(), this->GetConfigName(), - vars["LINK_LIBRARIES"], vars["FLAGS"], - vars["LINK_FLAGS"], frameworkPath, linkPath, - &genTarget, useWatcomQuote); + localGen.GetTargetFlags( + linkLineComputer.get(), this->GetConfigName(), vars["LINK_LIBRARIES"], + vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, &genTarget); if (this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") && (gt.GetType() == cmState::SHARED_LIBRARY || gt.IsExecutableWithExports())) { diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index d537cfd..e0fcb75 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -732,7 +732,7 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, cmLinkLineComputer linkLineComputer(lg, lg->GetStateSnapshot().GetDirectory()); lg->GetTargetFlags(&linkLineComputer, config, linkLibs, linkLanguageFlags, - linkFlags, frameworkPath, linkPath, target, false); + linkFlags, frameworkPath, linkPath, target); linkLibs = cmSystemTools::TrimWhitespace(linkLibs); linkFlags = cmSystemTools::TrimWhitespace(linkFlags); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 50f77f4..e0f4000 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -586,7 +586,7 @@ bool cmake::FindPackage(const std::vector& args) cmLinkLineComputer linkLineComputer(lg, lg->GetStateSnapshot().GetDirectory()); lg->GetTargetFlags(&linkLineComputer, buildType, linkLibs, flags, - linkFlags, frameworkPath, linkPath, gtgt, false); + linkFlags, frameworkPath, linkPath, gtgt); linkLibs = frameworkPath + linkPath + linkLibs; printf("%s\n", linkLibs.c_str()); -- cgit v0.12