Răsfoiți Sursa

Convert: Replace trivial conversion with new method

Stephen Kelly 9 ani în urmă
părinte
comite
563ac22a16

+ 2 - 2
Source/cmDependsC.cxx

@@ -238,8 +238,8 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
   // written by the original local generator for this directory
   // convert the dependencies to paths relative to the home output
   // directory.  We must do the same here.
-  std::string obj_i =
-    this->LocalGenerator->Convert(obj, cmOutputConverter::HOME_OUTPUT);
+  std::string obj_i = this->LocalGenerator->ConvertToRelativePath(
+    obj, cmOutputConverter::HOME_OUTPUT);
   std::string obj_m = this->LocalGenerator->ConvertToOutputFormat(
     obj_i, cmOutputConverter::MAKERULE);
   internalDepends << obj_i << std::endl;

+ 5 - 5
Source/cmDependsFortran.cxx

@@ -193,15 +193,15 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
       stamp += ".mod.stamp";
       fcStream << "\n";
       fcStream << "  \""
-               << this->LocalGenerator->Convert(
+               << this->LocalGenerator->ConvertToRelativePath(
                     mod_lower, cmOutputConverter::START_OUTPUT)
                << "\"\n";
       fcStream << "  \""
-               << this->LocalGenerator->Convert(
+               << this->LocalGenerator->ConvertToRelativePath(
                     mod_upper, cmOutputConverter::START_OUTPUT)
                << "\"\n";
       fcStream << "  \""
-               << this->LocalGenerator->Convert(
+               << this->LocalGenerator->ConvertToRelativePath(
                     stamp, cmOutputConverter::START_OUTPUT)
                << "\"\n";
     }
@@ -317,8 +317,8 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
   const char* src = info.Source.c_str();
 
   // Write the include dependencies to the output stream.
-  std::string obj_i =
-    this->LocalGenerator->Convert(obj, cmOutputConverter::HOME_OUTPUT);
+  std::string obj_i = this->LocalGenerator->ConvertToRelativePath(
+    obj, cmOutputConverter::HOME_OUTPUT);
   std::string obj_m = this->LocalGenerator->ConvertToOutputFormat(
     obj_i, cmOutputConverter::MAKERULE);
   internalDepends << obj_i << std::endl;

+ 2 - 2
Source/cmExtraEclipseCDT4Generator.cxx

@@ -904,8 +904,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
        it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
     const std::vector<cmGeneratorTarget*> targets =
       (*it)->GetGeneratorTargets();
-    std::string subdir = (*it)->Convert((*it)->GetCurrentBinaryDirectory(),
-                                        cmOutputConverter::HOME_OUTPUT);
+    std::string subdir = (*it)->ConvertToRelativePath(
+      (*it)->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
     if (subdir == ".") {
       subdir = "";
     }

+ 2 - 2
Source/cmGlobalGenerator.cxx

@@ -2547,8 +2547,8 @@ void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
 
   // Shorten the output name (in expected use case).
   cmOutputConverter converter(this->GetMakefiles()[0]->GetStateSnapshot());
-  std::string fname =
-    converter.Convert(outputs[0], cmOutputConverter::HOME_OUTPUT);
+  std::string fname = converter.ConvertToRelativePath(
+    outputs[0], cmOutputConverter::HOME_OUTPUT);
 
   // Associate the hash with this output.
   this->RuleHashes[fname] = hash;

+ 4 - 2
Source/cmGlobalNinjaGenerator.cxx

@@ -747,7 +747,8 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path)
 {
   cmLocalNinjaGenerator* ng =
     static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
-  std::string convPath = ng->Convert(path, cmOutputConverter::HOME_OUTPUT);
+  std::string convPath =
+    ng->ConvertToRelativePath(path, cmOutputConverter::HOME_OUTPUT);
   convPath = this->NinjaOutputPath(convPath);
 #ifdef _WIN32
   std::replace(convPath.begin(), convPath.end(), '/', '\\');
@@ -760,7 +761,8 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaFolderRule(
 {
   cmLocalNinjaGenerator* ng =
     static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
-  std::string convPath = ng->Convert(path + "/all", cmOutputConverter::HOME);
+  std::string convPath =
+    ng->ConvertToRelativePath(path + "/all", cmOutputConverter::HOME);
   convPath = this->NinjaOutputPath(convPath);
 #ifdef _WIN32
   std::replace(convPath.begin(), convPath.end(), '/', '\\');

+ 14 - 7
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -311,11 +311,14 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
   cmakefileStream
     << "# The top level Makefile was generated from the following files:\n"
     << "set(CMAKE_MAKEFILE_DEPENDS\n"
-    << "  \"" << lg->Convert(cache, cmOutputConverter::START_OUTPUT) << "\"\n";
+    << "  \""
+    << lg->ConvertToRelativePath(cache, cmOutputConverter::START_OUTPUT)
+    << "\"\n";
   for (std::vector<std::string>::const_iterator i = lfiles.begin();
        i != lfiles.end(); ++i) {
     cmakefileStream << "  \""
-                    << lg->Convert(*i, cmOutputConverter::START_OUTPUT)
+                    << lg->ConvertToRelativePath(
+                         *i, cmOutputConverter::START_OUTPUT)
                     << "\"\n";
   }
   cmakefileStream << "  )\n\n";
@@ -329,10 +332,12 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
   cmakefileStream << "# The corresponding makefile is:\n"
                   << "set(CMAKE_MAKEFILE_OUTPUTS\n"
                   << "  \""
-                  << lg->Convert(makefileName, cmOutputConverter::START_OUTPUT)
+                  << lg->ConvertToRelativePath(makefileName,
+                                               cmOutputConverter::START_OUTPUT)
                   << "\"\n"
                   << "  \""
-                  << lg->Convert(check, cmOutputConverter::START_OUTPUT)
+                  << lg->ConvertToRelativePath(check,
+                                               cmOutputConverter::START_OUTPUT)
                   << "\"\n";
   cmakefileStream << "  )\n\n";
 
@@ -345,7 +350,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
     for (std::vector<std::string>::const_iterator k = outfiles.begin();
          k != outfiles.end(); ++k) {
       cmakefileStream << "  \""
-                      << lg->Convert(*k, cmOutputConverter::HOME_OUTPUT)
+                      << lg->ConvertToRelativePath(
+                           *k, cmOutputConverter::HOME_OUTPUT)
                       << "\"\n";
     }
 
@@ -358,7 +364,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
       tmpStr += cmake::GetCMakeFilesDirectory();
       tmpStr += "/CMakeDirectoryInformation.cmake";
       cmakefileStream << "  \""
-                      << lg->Convert(tmpStr, cmOutputConverter::HOME_OUTPUT)
+                      << lg->ConvertToRelativePath(
+                           tmpStr, cmOutputConverter::HOME_OUTPUT)
                       << "\"\n";
     }
     cmakefileStream << "  )\n\n";
@@ -519,7 +526,7 @@ void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
       tname += "/fast";
     }
     cmOutputConverter conv(mf->GetStateSnapshot());
-    tname = conv.Convert(tname, cmOutputConverter::HOME_OUTPUT);
+    tname = conv.ConvertToRelativePath(tname, cmOutputConverter::HOME_OUTPUT);
     cmSystemTools::ConvertToOutputSlashes(tname);
     makeCommand.push_back(tname);
     if (this->Makefiles.empty()) {

+ 2 - 1
Source/cmGlobalVisualStudio7Generator.cxx

@@ -385,7 +385,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
       if (vcprojName) {
         cmLocalGenerator* lg = target->GetLocalGenerator();
         std::string dir = lg->GetCurrentBinaryDirectory();
-        dir = root->Convert(dir.c_str(), cmOutputConverter::START_OUTPUT);
+        dir = root->ConvertToRelativePath(dir.c_str(),
+                                          cmOutputConverter::START_OUTPUT);
         if (dir == ".") {
           dir = ""; // msbuild cannot handle ".\" prefix
         }

+ 4 - 2
Source/cmListFileCache.cxx

@@ -402,7 +402,8 @@ void cmListFileBacktrace::PrintTitle(std::ostream& out) const
   cmOutputConverter converter(this->Bottom);
   cmListFileContext lfc = *this->Cur;
   if (!this->Bottom.GetState()->GetIsInTryCompile()) {
-    lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
+    lfc.FilePath =
+      converter.ConvertToRelativePath(lfc.FilePath, cmOutputConverter::HOME);
   }
   out << (lfc.Line ? " at " : " in ") << lfc;
 }
@@ -427,7 +428,8 @@ void cmListFileBacktrace::PrintCallStack(std::ostream& out) const
     }
     cmListFileContext lfc = *i;
     if (!this->Bottom.GetState()->GetIsInTryCompile()) {
-      lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
+      lfc.FilePath =
+        converter.ConvertToRelativePath(lfc.FilePath, cmOutputConverter::HOME);
     }
     out << "  " << lfc << "\n";
   }

+ 6 - 4
Source/cmLocalGenerator.cxx

@@ -176,7 +176,7 @@ void cmLocalGenerator::GenerateTestFiles()
     // TODO: Use add_subdirectory instead?
     fout << "subdirs(";
     std::string outP = children[i].GetDirectory().GetCurrentBinary();
-    fout << this->Convert(outP, START_OUTPUT);
+    fout << this->ConvertToRelativePath(outP, START_OUTPUT);
     fout << ")" << std::endl;
   }
 }
@@ -2237,7 +2237,8 @@ std::string cmLocalGenerator::ConstructComment(
     for (std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
          o != ccg.GetOutputs().end(); ++o) {
       comment += sep;
-      comment += this->Convert(*o, cmOutputConverter::START_OUTPUT);
+      comment +=
+        this->ConvertToRelativePath(*o, cmOutputConverter::START_OUTPUT);
       sep = ", ";
     }
     return comment;
@@ -2505,13 +2506,14 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
   const char* fullPath = source.GetFullPath().c_str();
 
   // Try referencing the source relative to the source tree.
-  std::string relFromSource = this->Convert(fullPath, START);
+  std::string relFromSource = this->ConvertToRelativePath(fullPath, START);
   assert(!relFromSource.empty());
   bool relSource = !cmSystemTools::FileIsFullPath(relFromSource.c_str());
   bool subSource = relSource && relFromSource[0] != '.';
 
   // Try referencing the source relative to the binary tree.
-  std::string relFromBinary = this->Convert(fullPath, START_OUTPUT);
+  std::string relFromBinary =
+    this->ConvertToRelativePath(fullPath, START_OUTPUT);
   assert(!relFromBinary.empty());
   bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary.c_str());
   bool subBinary = relBinary && relFromBinary[0] != '.';

+ 1 - 1
Source/cmLocalNinjaGenerator.cxx

@@ -41,7 +41,7 @@ void cmLocalNinjaGenerator::Generate()
 {
   // Compute the path to use when referencing the current output
   // directory from the top output directory.
-  this->HomeRelativeOutputPath = this->Convert(
+  this->HomeRelativeOutputPath = this->ConvertToRelativePath(
     this->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
   if (this->HomeRelativeOutputPath == ".") {
     this->HomeRelativeOutputPath = "";

+ 7 - 4
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -140,7 +140,7 @@ void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath()
 {
   // Compute the path to use when referencing the current output
   // directory from the top output directory.
-  this->HomeRelativeOutputPath = this->Convert(
+  this->HomeRelativeOutputPath = this->ConvertToRelativePath(
     this->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
   if (this->HomeRelativeOutputPath == ".") {
     this->HomeRelativeOutputPath = "";
@@ -966,7 +966,8 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
       // working directory will be the start-output directory.
       bool had_slash = cmd.find('/') != cmd.npos;
       if (workingDir.empty()) {
-        cmd = this->Convert(cmd, cmOutputConverter::START_OUTPUT);
+        cmd =
+          this->ConvertToRelativePath(cmd, cmOutputConverter::START_OUTPUT);
       }
       bool has_slash = cmd.find('/') != cmd.npos;
       if (had_slash && !has_slash) {
@@ -1851,7 +1852,8 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
     for (std::vector<std::string>::iterator i = includes.begin();
          i != includes.end(); ++i) {
       cmakefileStream << "  \""
-                      << this->Convert(*i, cmOutputConverter::HOME_OUTPUT)
+                      << this->ConvertToRelativePath(
+                           *i, cmOutputConverter::HOME_OUTPUT)
                       << "\"\n";
     }
     cmakefileStream << "  )\n";
@@ -1915,7 +1917,8 @@ std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall(
   // Add the target.
   if (!tgt.empty()) {
     // The make target is always relative to the top of the build tree.
-    std::string tgt2 = this->Convert(tgt, cmOutputConverter::HOME_OUTPUT);
+    std::string tgt2 =
+      this->ConvertToRelativePath(tgt, cmOutputConverter::HOME_OUTPUT);
 
     // The target may have been written with windows paths.
     cmSystemTools::ConvertToOutputSlashes(tgt2);

+ 6 - 3
Source/cmMakefileTargetGenerator.cxx

@@ -312,8 +312,10 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()(
   output += "/";
   output += cmSystemTools::GetFilenameName(input);
   this->Generator->CleanFiles.push_back(
-    this->Generator->Convert(output, cmOutputConverter::START_OUTPUT));
-  output = this->Generator->Convert(output, cmOutputConverter::HOME_OUTPUT);
+    this->Generator->LocalGenerator->ConvertToRelativePath(
+      output, cmOutputConverter::START_OUTPUT));
+  output = this->Generator->LocalGenerator->ConvertToRelativePath(
+    output, cmOutputConverter::HOME_OUTPUT);
 
   // Create a rule to copy the content into the bundle.
   std::vector<std::string> depends;
@@ -1171,7 +1173,8 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
   for (std::vector<std::string>::const_iterator i =
          this->ExternalObjects.begin();
        i != this->ExternalObjects.end(); ++i) {
-    object = this->Convert(*i, cmOutputConverter::START_OUTPUT);
+    object = this->LocalGenerator->ConvertToRelativePath(
+      *i, cmOutputConverter::START_OUTPUT);
     *this->BuildFileStream << " " << lineContinue << "\n"
                            << this->Makefile->GetSafeDefinition(
                                 "CMAKE_OBJECT_NAME");

+ 2 - 1
Source/cmTarget.cxx

@@ -602,7 +602,8 @@ void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const
        it != this->TLLCommands.end(); ++it) {
     if (it->first == sig) {
       cmListFileContext lfc = it->second;
-      lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
+      lfc.FilePath =
+        converter.ConvertToRelativePath(lfc.FilePath, cmOutputConverter::HOME);
       s << " * " << lfc << std::endl;
     }
   }