Browse Source

cmSourceFile: Rename mutating GetFullPath() overload

Rename mutating GetFullPath() overload to ResolveFullPath().
Daniel Eiband 6 years ago
parent
commit
2d888e3390

+ 1 - 1
Source/cmCPluginAPI.cxx

@@ -536,7 +536,7 @@ void CCONV* cmGetSource(void* arg, const char* name)
       // Create a proxy source file object for this source.
       cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile;
       sf->RealSourceFile = rsf;
-      sf->FullPath = rsf->GetFullPath();
+      sf->FullPath = rsf->ResolveFullPath();
       sf->SourceName =
         cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath);
       sf->SourceExtension =

+ 1 - 1
Source/cmExtraCodeBlocksGenerator.cxx

@@ -371,7 +371,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
               isCFile = cm->IsSourceExtension(srcext);
             }
 
-            std::string const& fullPath = s->GetFullPath();
+            std::string const& fullPath = s->ResolveFullPath();
 
             // Check file position relative to project root dir.
             const std::string relative =

+ 1 - 1
Source/cmExtraCodeLiteGenerator.cxx

@@ -223,7 +223,7 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles(
       gt->GetSourceFiles(sources,
                          makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
       for (cmSourceFile* s : sources) {
-        std::string const& fullPath = s->GetFullPath();
+        std::string const& fullPath = s->ResolveFullPath();
         std::string const& extLower =
           cmSystemTools::LowerCase(s->GetExtension());
         // check whether it is a source or a include file

+ 1 - 1
Source/cmExtraEclipseCDT4Generator.cxx

@@ -524,7 +524,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml)
                              makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
           for (cmSourceFile* sf : files) {
             // Add the file to the list of sources.
-            std::string const& source = sf->GetFullPath();
+            std::string const& source = sf->ResolveFullPath();
             cmSourceGroup* sourceGroup =
               makefile->FindSourceGroup(source, sourceGroups);
             sourceGroup->AssignSource(sf);

+ 1 - 1
Source/cmExtraKateGenerator.cxx

@@ -254,7 +254,7 @@ std::string cmExtraKateGenerator::GenerateFilesString(
         continue;
       }
 
-      tmp = sf->GetFullPath();
+      tmp = sf->ResolveFullPath();
       files.insert(tmp);
     }
   }

+ 3 - 3
Source/cmExtraSublimeTextGenerator.cxx

@@ -243,12 +243,12 @@ void cmExtraSublimeTextGenerator::AppendTarget(
                            makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
     for (cmSourceFile* sourceFile : sourceFiles) {
       MapSourceFileFlags::iterator sourceFileFlagsIter =
-        sourceFileFlags.find(sourceFile->GetFullPath());
+        sourceFileFlags.find(sourceFile->ResolveFullPath());
       if (sourceFileFlagsIter == sourceFileFlags.end()) {
         sourceFileFlagsIter =
           sourceFileFlags
-            .insert(MapSourceFileFlags::value_type(sourceFile->GetFullPath(),
-                                                   std::vector<std::string>()))
+            .insert(MapSourceFileFlags::value_type(
+              sourceFile->ResolveFullPath(), std::vector<std::string>()))
             .first;
       }
       std::vector<std::string>& flags = sourceFileFlagsIter->second;

+ 1 - 1
Source/cmFLTKWrapUICommand.cxx

@@ -112,7 +112,7 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
     if (classNum) {
       sourceListValue += ";";
     }
-    sourceListValue += generatedSourcesClasses[classNum]->GetFullPath();
+    sourceListValue += generatedSourcesClasses[classNum]->ResolveFullPath();
   }
 
   std::string const varName = target + "_FLTK_UI_SRCS";

+ 1 - 1
Source/cmFileAPICodemodel.cxx

@@ -999,7 +999,7 @@ Json::Value Target::DumpSource(cmGeneratorTarget::SourceAndKind const& sk,
 {
   Json::Value source = Json::objectValue;
 
-  std::string const path = sk.Source.Value->GetFullPath();
+  std::string const path = sk.Source.Value->ResolveFullPath();
   source["path"] = RelativeIfUnder(this->TopSource, path);
   if (sk.Source.Value->GetIsGenerated()) {
     source["isGenerated"] = true;

+ 9 - 9
Source/cmGeneratorTarget.cxx

@@ -1351,7 +1351,7 @@ bool processSources(cmGeneratorTarget const* tgt,
     for (std::string& src : entry.Values) {
       cmSourceFile* sf = mf->GetOrCreateSource(src);
       std::string e;
-      std::string fullPath = sf->GetFullPath(&e);
+      std::string fullPath = sf->ResolveFullPath(&e);
       if (fullPath.empty()) {
         if (!e.empty()) {
           cmake* cm = tgt->GetLocalGenerator()->GetCMakeInstance();
@@ -1619,7 +1619,7 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
       // Both names would have been auto generated from Visual Studio
       // where the user supplied the file name and Visual Studio
       // appended the suffix.
-      std::string resx = sf->GetFullPath();
+      std::string resx = sf->ResolveFullPath();
       std::string hFileName = resx.substr(0, resx.find_last_of('.')) + ".h";
       files.ExpectedResxHeaders.insert(hFileName);
     } else if (ext == "appxmanifest") {
@@ -1635,12 +1635,12 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
       // Both names would have been auto generated from Visual Studio
       // where the user supplied the file name and Visual Studio
       // appended the suffix.
-      std::string xaml = sf->GetFullPath();
+      std::string xaml = sf->ResolveFullPath();
       std::string hFileName = xaml + ".h";
       std::string cppFileName = xaml + ".cpp";
       files.ExpectedXamlHeaders.insert(hFileName);
       files.ExpectedXamlSources.insert(cppFileName);
-    } else if (header_regex.find(sf->GetFullPath())) {
+    } else if (header_regex.find(sf->ResolveFullPath())) {
       kind = SourceKindHeader;
     } else {
       kind = SourceKindExtra;
@@ -2648,7 +2648,7 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target)
           this->GlobalGenerator->GetFilenameTargetDepends(sf);
         if (cmContains(tgts, this->GeneratorTarget)) {
           std::ostringstream e;
-          e << "Evaluation output file\n  \"" << sf->GetFullPath()
+          e << "Evaluation output file\n  \"" << sf->ResolveFullPath()
             << "\"\ndepends on the sources of a target it is used in.  This "
                "is a dependency loop and is not allowed.";
           this->GeneratorTarget->LocalGenerator->IssueMessage(
@@ -2690,7 +2690,7 @@ void cmTargetTraceDependencies::Trace()
     }
 
     // Queue the source needed to generate this file, if any.
-    this->FollowName(sf->GetFullPath());
+    this->FollowName(sf->ResolveFullPath());
 
     // Queue dependencies added programmatically by commands.
     this->FollowNames(sf->GetDepends());
@@ -2711,7 +2711,7 @@ void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf)
     this->SourceQueue.push(sf);
 
     // Make sure this file is in the target at the end.
-    this->NewSources.push_back(sf->GetFullPath());
+    this->NewSources.push_back(sf->ResolveFullPath());
   }
 }
 
@@ -6095,7 +6095,7 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles(
       const char* sep = "";
       for (cmSourceFile* f : files) {
         firstConfigFiles += sep;
-        firstConfigFiles += f->GetFullPath();
+        firstConfigFiles += f->ResolveFullPath();
         sep = "\n  ";
       }
 
@@ -6103,7 +6103,7 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles(
       sep = "";
       for (cmSourceFile* f : configFiles) {
         thisConfigFiles += sep;
-        thisConfigFiles += f->GetFullPath();
+        thisConfigFiles += f->ResolveFullPath();
         sep = "\n  ";
       }
       std::ostringstream e;

+ 2 - 2
Source/cmGhsMultiTargetGenerator.cxx

@@ -488,7 +488,7 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
   std::set<std::string> groupNames;
   for (auto& sf : sources) {
     cmSourceGroup* sourceGroup =
-      this->Makefile->FindSourceGroup(sf->GetFullPath(), sourceGroups);
+      this->Makefile->FindSourceGroup(sf->ResolveFullPath(), sourceGroups);
     std::string gn = sourceGroup->GetFullName();
     groupFiles[gn].push_back(sf);
     groupNames.insert(std::move(gn));
@@ -543,7 +543,7 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
   for (auto& n : groupFilesList) {
     std::sort(groupFiles[n].begin(), groupFiles[n].end(),
               [](cmSourceFile* l, cmSourceFile* r) {
-                return l->GetFullPath() < r->GetFullPath();
+                return l->ResolveFullPath() < r->ResolveFullPath();
               });
   }
 

+ 1 - 1
Source/cmGlobalGenerator.cxx

@@ -2974,7 +2974,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
     auto const sourcesEnd = cmRemoveDuplicates(sources);
     for (cmSourceFile* sf : cmMakeRange(sources.cbegin(), sourcesEnd)) {
       Json::Value& lj_source = lj_sources.append(Json::objectValue);
-      std::string const& sfp = sf->GetFullPath();
+      std::string const& sfp = sf->ResolveFullPath();
       fout << sfp << "\n";
       lj_source["file"] = sfp;
       if (const char* svalue = sf->GetProperty("LABELS")) {

+ 1 - 1
Source/cmGlobalVisualStudio8Generator.cxx

@@ -195,7 +195,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
     if (cmSourceFile* file = mf->AddCustomCommandToOutput(
           stamps, no_byproducts, listFiles, no_main_dependency, commandLines,
           "Checking Build System", no_working_directory, true, false)) {
-      gt->AddSource(file->GetFullPath());
+      gt->AddSource(file->ResolveFullPath());
     } else {
       cmSystemTools::Error("Error adding rule for " + stamps[0]);
     }

+ 1 - 1
Source/cmJsonObjects.cxx

@@ -327,7 +327,7 @@ static Json::Value DumpSourceFilesList(
 
     fileData.IsGenerated = file->GetIsGenerated();
     std::vector<std::string>& groupFileList = fileGroups[fileData];
-    groupFileList.push_back(file->GetFullPath());
+    groupFileList.push_back(file->ResolveFullPath());
   }
 
   const std::string& baseDir = target->Makefile->GetCurrentSourceDirectory();

+ 2 - 2
Source/cmLocalGenerator.cxx

@@ -1179,7 +1179,7 @@ void cmLocalGenerator::GetTargetFlags(
             if (sf->GetExtension() == "def") {
               linkFlags += defFlag;
               linkFlags += this->ConvertToOutputFormat(
-                cmSystemTools::CollapseFullPath(sf->GetFullPath()), SHELL);
+                cmSystemTools::CollapseFullPath(sf->ResolveFullPath()), SHELL);
               linkFlags += " ";
             }
           }
@@ -1727,7 +1727,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
   // Check for a source file in this directory that matches the
   // dependency.
   if (cmSourceFile* sf = this->Makefile->GetSource(inName)) {
-    dep = sf->GetFullPath();
+    dep = sf->ResolveFullPath();
     return true;
   }
 

+ 2 - 2
Source/cmLocalVisualStudio7Generator.cxx

@@ -102,7 +102,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
       if (cmSourceFile* file = this->Makefile->AddCustomCommandToOutput(
             force.c_str(), no_depends, no_main_dependency, force_commands, " ",
             0, true)) {
-        l->AddSource(file->GetFullPath());
+        l->AddSource(file->ResolveFullPath());
       }
     }
   }
@@ -268,7 +268,7 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
   if (cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str())) {
     // Finalize the source file path now since we're adding this after
     // the generator validated all project-named sources.
-    file->GetFullPath();
+    file->ResolveFullPath();
     return file;
   } else {
     cmSystemTools::Error("Error adding rule for " + makefileIn);

+ 2 - 2
Source/cmMakefile.cxx

@@ -1112,7 +1112,7 @@ void cmMakefile::AddCustomCommandOldStyle(
     if (sf && !sf->GetPropertyAsBool("__CMAKE_RULE")) {
       cmTargetMap::iterator ti = this->Targets.find(target);
       if (ti != this->Targets.end()) {
-        ti->second.AddSource(sf->GetFullPath());
+        ti->second.AddSource(sf->ResolveFullPath());
       } else {
         cmSystemTools::Error("Attempt to add a custom rule to a target "
                              "that does not exist yet for target " +
@@ -3322,7 +3322,7 @@ void cmMakefile::AddTargetObject(std::string const& tgtName,
   sf->SetProperty("EXTERNAL_OBJECT", "1");
 #if !defined(CMAKE_BOOTSTRAP)
   this->SourceGroups[this->ObjectLibrariesSourceGroupIndex].AddGroupFile(
-    sf->GetFullPath());
+    sf->ResolveFullPath());
 #endif
 }
 

+ 2 - 2
Source/cmOutputRequiredFilesCommand.cxx

@@ -325,7 +325,7 @@ protected:
       cmSourceFile* srcFile = this->Makefile->GetSource(
         cmSystemTools::GetFilenameWithoutExtension(path));
       if (srcFile) {
-        if (srcFile->GetFullPath() == path) {
+        if (srcFile->ResolveFullPath() == path) {
           found = true;
         } else {
           // try to guess which include path to use
@@ -334,7 +334,7 @@ protected:
               incpath += "/";
             }
             incpath += path;
-            if (srcFile->GetFullPath() == incpath) {
+            if (srcFile->ResolveFullPath() == incpath) {
               // set the path to the guessed path
               info->FullPath = incpath;
               found = true;

+ 3 - 3
Source/cmQtAutoGenInitializer.cxx

@@ -647,7 +647,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
       // Since we're iterating over source files that might be not in the
       // target we need to check for path errors (not existing files).
       std::string pathError;
-      std::string const& fullPath = sf->GetFullPath(&pathError);
+      std::string const& fullPath = sf->ResolveFullPath(&pathError);
       if (!pathError.empty() || fullPath.empty()) {
         continue;
       }
@@ -703,7 +703,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
       MUFile const& muf = *pair.second;
       if (muf.MocIt || muf.UicIt) {
         // Search for the default header file and a private header
-        std::string const& srcPath = muf.SF->GetFullPath();
+        std::string const& srcPath = muf.SF->ResolveFullPath();
         std::string basePath =
           cmStrCat(cmQtAutoGen::SubDirPrefix(srcPath),
                    cmSystemTools::GetFilenameWithoutLastExtension(srcPath));
@@ -761,7 +761,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
       // Since we're iterating over source files that might be not in the
       // target we need to check for path errors (not existing files).
       std::string pathError;
-      std::string const& fullPath = sf->GetFullPath(&pathError);
+      std::string const& fullPath = sf->ResolveFullPath(&pathError);
       if (!pathError.empty() || fullPath.empty()) {
         continue;
       }

+ 3 - 3
Source/cmSourceFile.cxx

@@ -65,7 +65,7 @@ std::string const& cmSourceFile::GetOrDetermineLanguage()
         this->Location.DirectoryIsAmbiguous()) {
       // Finalize the file location to get the extension and set the
       // language.
-      this->GetFullPath();
+      this->ResolveFullPath();
     } else {
       // Use the known extension to get the language if possible.
       std::string ext =
@@ -94,7 +94,7 @@ cmSourceFileLocation const& cmSourceFile::GetLocation() const
   return this->Location;
 }
 
-std::string const& cmSourceFile::GetFullPath(std::string* error)
+std::string const& cmSourceFile::ResolveFullPath(std::string* error)
 {
   if (this->FullPath.empty()) {
     if (this->FindFullPath(error)) {
@@ -269,7 +269,7 @@ const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
   // LOCATION property we must commit now.
   if (prop == propLOCATION) {
     // Commit to a location.
-    this->GetFullPath();
+    this->ResolveFullPath();
   }
 
   // Similarly, LANGUAGE can be determined by the file extension

+ 8 - 7
Source/cmSourceFile.h

@@ -63,14 +63,15 @@ public:
   bool GetIsGenerated() const { return this->IsGenerated; }
 
   /**
-   * The full path to the file.  The non-const version of this method
-   * may attempt to locate the file on disk and finalize its location.
-   * The const version of this method may return an empty string if
-   * the non-const version has not yet been called (yes this is a
-   * horrible interface, but is necessary for backwards
-   * compatibility).
+   * Resolves the full path to the file.  Attempts to locate the file on disk
+   * and finalizes its location.
+   */
+  std::string const& ResolveFullPath(std::string* error = nullptr);
+
+  /**
+   * The resolved full path to the file.  The returned file name might be empty
+   * if the path has not yet been resolved.
    */
-  std::string const& GetFullPath(std::string* error = nullptr);
   std::string const& GetFullPath() const;
 
   /**