Prechádzať zdrojové kódy

cmLinkLineComputer: Move FrameworkPath computation from cmLocalGenerator

Add UseWatcomQuote state, and remove corresponding method parameters.
Stephen Kelly 9 rokov pred
rodič
commit
f03d446e96

+ 2 - 1
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()) {

+ 16 - 0
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<std::string> const& fwDirs = cli.GetFrameworkPaths();
+    for (std::vector<std::string>::const_iterator fdi = fwDirs.begin();
+         fdi != fwDirs.end(); ++fdi) {
+      frameworkPath += fwSearchFlag;
+      frameworkPath += this->ConvertToOutputFormat(*fdi);
+      frameworkPath += " ";
+    }
+  }
+  return frameworkPath;
+}

+ 3 - 0
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);

+ 5 - 18
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<std::string> const& fwDirs = cli.GetFrameworkPaths();
-    for (std::vector<std::string>::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);
 

+ 2 - 2
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<std::string>& 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,

+ 1 - 1
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.

+ 1 - 1
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

+ 2 - 3
Source/cmMakefileTargetGenerator.cxx

@@ -1602,8 +1602,7 @@ cmLinkLineComputer* cmMakefileTargetGenerator::CreateLinkLineComputer(
 
 void cmMakefileTargetGenerator::CreateLinkLibs(
   cmLinkLineComputer* linkLineComputer, std::string& linkLibs,
-  bool useResponseFile, std::vector<std::string>& makefile_depends,
-  bool useWatcomQuote)
+  bool useResponseFile, std::vector<std::string>& 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) {

+ 1 - 2
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<std::string>& makefile_depends,
-                      bool useWatcomQuote);
+                      std::vector<std::string>& makefile_depends);
 
   /** Create lists of object files for linking and cleaning.  */
   void CreateObjectLists(bool useLinkScript, bool useArchiveRules,

+ 4 - 4
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())) {

+ 1 - 1
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);

+ 1 - 1
Source/cmake.cxx

@@ -586,7 +586,7 @@ bool cmake::FindPackage(const std::vector<std::string>& 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());