From 2d888e339064d39ae894b4df567441539c8c65da Mon Sep 17 00:00:00 2001 From: Daniel Eiband Date: Thu, 29 Aug 2019 17:31:44 +0200 Subject: cmSourceFile: Rename mutating GetFullPath() overload Rename mutating GetFullPath() overload to ResolveFullPath(). --- Source/cmCPluginAPI.cxx | 2 +- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmExtraCodeLiteGenerator.cxx | 2 +- Source/cmExtraEclipseCDT4Generator.cxx | 2 +- Source/cmExtraKateGenerator.cxx | 2 +- Source/cmExtraSublimeTextGenerator.cxx | 6 +++--- Source/cmFLTKWrapUICommand.cxx | 2 +- Source/cmFileAPICodemodel.cxx | 2 +- Source/cmGeneratorTarget.cxx | 18 +++++++++--------- Source/cmGhsMultiTargetGenerator.cxx | 4 ++-- Source/cmGlobalGenerator.cxx | 2 +- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmJsonObjects.cxx | 2 +- Source/cmLocalGenerator.cxx | 4 ++-- Source/cmLocalVisualStudio7Generator.cxx | 4 ++-- Source/cmMakefile.cxx | 4 ++-- Source/cmOutputRequiredFilesCommand.cxx | 4 ++-- Source/cmQtAutoGenInitializer.cxx | 6 +++--- Source/cmSourceFile.cxx | 6 +++--- Source/cmSourceFile.h | 15 ++++++++------- 20 files changed, 46 insertions(+), 45 deletions(-) diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index f0c1845d63..b20f5959ff 100644 --- a/Source/cmCPluginAPI.cxx +++ b/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 = diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 487d0debb5..6b16b93ecf 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/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 = diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 7f71a2c835..09567293aa 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/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 diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 6c94aae048..43f1e1219d 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/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); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 2bfbb0d4f9..7ac73cfba7 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -254,7 +254,7 @@ std::string cmExtraKateGenerator::GenerateFilesString( continue; } - tmp = sf->GetFullPath(); + tmp = sf->ResolveFullPath(); files.insert(tmp); } } diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 6f4472b45c..52ba968d0e 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/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())) + .insert(MapSourceFileFlags::value_type( + sourceFile->ResolveFullPath(), std::vector())) .first; } std::vector& flags = sourceFileFlagsIter->second; diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index 21500510ef..ea9e672f32 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -112,7 +112,7 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector const& args, if (classNum) { sourceListValue += ";"; } - sourceListValue += generatedSourcesClasses[classNum]->GetFullPath(); + sourceListValue += generatedSourcesClasses[classNum]->ResolveFullPath(); } std::string const varName = target + "_FLTK_UI_SRCS"; diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 08db7c7714..4e344380f6 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/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; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cc37232039..5fbff2b2a7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/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; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index e7b20ed8fd..658f65d241 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -488,7 +488,7 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj) std::set 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(); }); } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4342e9f51b..bfccb1276e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/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")) { diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index b0c065f5ac..f4c47ce4a3 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/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]); } diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 4948b01949..52e28d3bd0 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -327,7 +327,7 @@ static Json::Value DumpSourceFilesList( fileData.IsGenerated = file->GetIsGenerated(); std::vector& groupFileList = fileGroups[fileData]; - groupFileList.push_back(file->GetFullPath()); + groupFileList.push_back(file->ResolveFullPath()); } const std::string& baseDir = target->Makefile->GetCurrentSourceDirectory(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7177694068..78133dbf95 100644 --- a/Source/cmLocalGenerator.cxx +++ b/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; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 795cee40a9..f88c3e9b17 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/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); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f101cdc00f..5f09ce3aaa 100644 --- a/Source/cmMakefile.cxx +++ b/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 } diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 3d8ebc38f3..187f0ab8df 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/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; diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index bd96c08cd8..155167b103 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/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; } diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 5d738d5210..4deb94ae98 100644 --- a/Source/cmSourceFile.cxx +++ b/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 diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index ccd5b621eb..774cb283c1 100644 --- a/Source/cmSourceFile.h +++ b/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; /** -- cgit v1.2.1