From 563ac22a1646f1287d1baac755e13cbe33c1fe7b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 27 Aug 2016 13:44:56 +0200 Subject: [PATCH] Convert: Replace trivial conversion with new method --- Source/cmDependsC.cxx | 4 ++-- Source/cmDependsFortran.cxx | 10 +++++----- Source/cmExtraEclipseCDT4Generator.cxx | 4 ++-- Source/cmGlobalGenerator.cxx | 4 ++-- Source/cmGlobalNinjaGenerator.cxx | 6 ++++-- Source/cmGlobalUnixMakefileGenerator3.cxx | 21 ++++++++++++++------- Source/cmGlobalVisualStudio7Generator.cxx | 3 ++- Source/cmListFileCache.cxx | 6 ++++-- Source/cmLocalGenerator.cxx | 10 ++++++---- Source/cmLocalNinjaGenerator.cxx | 2 +- Source/cmLocalUnixMakefileGenerator3.cxx | 11 +++++++---- Source/cmMakefileTargetGenerator.cxx | 9 ++++++--- Source/cmTarget.cxx | 3 ++- 13 files changed, 57 insertions(+), 36 deletions(-) diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 18e123e9c..928f7ec42 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -238,8 +238,8 @@ bool cmDependsC::WriteDependencies(const std::set& 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; diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index c57b55805..8c0acce5e 100644 --- a/Source/cmDependsFortran.cxx +++ b/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; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index e617b08c1..945ee40bc 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -904,8 +904,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { const std::vector 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 = ""; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 295f65b3c..50c5a42c9 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2547,8 +2547,8 @@ void cmGlobalGenerator::AddRuleHash(const std::vector& 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; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 2b8347901..939c5adc5 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -747,7 +747,8 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path) { cmLocalNinjaGenerator* ng = static_cast(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(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(), '/', '\\'); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index f115ecba9..bbc794dc1 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/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::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::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()) { diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 0a83b3a8a..67ac230ca 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/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 } diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 39d9e9704..3c5e33328 100644 --- a/Source/cmListFileCache.cxx +++ b/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"; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 20a1e21b3..2fa3f8687 100644 --- a/Source/cmLocalGenerator.cxx +++ b/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::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] != '.'; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 8c092e762..9e2c92088 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/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 = ""; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 33b010261..5b83b3d24 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/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::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); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 2d53669b1..b34cd6e07 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/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 depends; @@ -1171,7 +1173,8 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( for (std::vector::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"); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ed04d2fbe..d5274cd90 100644 --- a/Source/cmTarget.cxx +++ b/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; } }