diff options
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator3.cxx')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 78 |
1 files changed, 29 insertions, 49 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 464df68..3a65a80 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -38,7 +38,6 @@ #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" #include "cmState.h" -#include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" @@ -110,7 +109,7 @@ private: cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3( cmGlobalGenerator* gg, cmMakefile* mf) - : cmLocalCommonGenerator(gg, mf, mf->GetCurrentBinaryDirectory()) + : cmLocalCommonGenerator(gg, mf, WorkDir::CurBin) { this->MakefileVariableSize = 0; this->ColorMakefile = false; @@ -177,8 +176,8 @@ void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath() { // Compute the path to use when referencing the current output // directory from the top output directory. - this->HomeRelativeOutputPath = this->MaybeConvertToRelativePath( - this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); + this->HomeRelativeOutputPath = + this->MaybeRelativeToTopBinDir(this->GetCurrentBinaryDirectory()); if (this->HomeRelativeOutputPath == ".") { this->HomeRelativeOutputPath.clear(); } @@ -474,11 +473,9 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() infoFileStream << "# Relative path conversion top directories.\n" << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \"" - << this->StateSnapshot.GetDirectory().GetRelativePathTopSource() - << "\")\n" + << this->GetRelativePathTopSource() << "\")\n" << "set(CMAKE_RELATIVE_PATH_TOP_BINARY \"" - << this->StateSnapshot.GetDirectory().GetRelativePathTopBinary() - << "\")\n" + << this->GetRelativePathTopBinary() << "\")\n" << "\n"; /* clang-format on */ @@ -561,8 +558,8 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule( } // Construct the left hand side of the rule. - std::string tgt = this->ConvertToMakefilePath( - this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), target)); + std::string tgt = + this->ConvertToMakefilePath(this->MaybeRelativeToTopBinDir(target)); const char* space = ""; if (tgt.size() == 1) { @@ -586,11 +583,9 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule( } else { // Split dependencies into multiple rule lines. This allows for // very long dependency lists even on older make implementations. - std::string binDir = this->GetBinaryDirectory(); for (std::string const& depend : depends) { os << tgt << space << ": " - << this->ConvertToMakefilePath( - this->MaybeConvertToRelativePath(binDir, depend)) + << this->ConvertToMakefilePath(this->MaybeRelativeToTopBinDir(depend)) << '\n'; } } @@ -968,7 +963,6 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( // Add each command line to the set of commands. std::vector<std::string> commands1; - std::string currentBinDir = this->GetCurrentBinaryDirectory(); for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) { // Build the command line in a single string. std::string cmd = ccg.GetCommand(c); @@ -993,7 +987,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( // working directory will be the start-output directory. bool had_slash = cmd.find('/') != std::string::npos; if (workingDir.empty()) { - cmd = this->MaybeConvertToRelativePath(currentBinDir, cmd); + cmd = this->MaybeRelativeToCurBinDir(cmd); } bool has_slash = cmd.find('/') != std::string::npos; if (had_slash && !has_slash) { @@ -1017,8 +1011,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( if (!outputs.empty()) { output = outputs[0]; if (workingDir.empty()) { - output = this->MaybeConvertToRelativePath( - this->GetCurrentBinaryDirectory(), output); + output = this->MaybeRelativeToCurBinDir(output); } output = this->ConvertToOutputFormat(output, cmOutputConverter::SHELL); @@ -1097,18 +1090,16 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand( if (!files.empty()) { fout << "file(REMOVE_RECURSE\n"; for (std::string const& file : files) { - std::string fc = this->MaybeConvertToRelativePath(currentBinDir, file); + std::string fc = this->MaybeRelativeToCurBinDir(file); fout << " " << cmOutputConverter::EscapeForCMake(fc) << "\n"; } fout << ")\n"; } { - std::string remove = - cmStrCat("$(CMAKE_COMMAND) -P ", - this->ConvertToOutputFormat( - this->MaybeConvertToRelativePath( - this->GetCurrentBinaryDirectory(), cleanfile), - cmOutputConverter::SHELL)); + std::string remove = cmStrCat( + "$(CMAKE_COMMAND) -P ", + this->ConvertToOutputFormat(this->MaybeRelativeToCurBinDir(cleanfile), + cmOutputConverter::SHELL)); commands.push_back(std::move(remove)); } @@ -1146,7 +1137,6 @@ void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand( } const auto& rootLG = this->GetGlobalGenerator()->GetLocalGenerators().at(0); - std::string const& binaryDir = rootLG->GetCurrentBinaryDirectory(); std::string const& currentBinaryDir = this->GetCurrentBinaryDirectory(); std::string cleanfile = cmStrCat(currentBinaryDir, "/CMakeFiles/cmake_directory_clean.cmake"); @@ -1159,19 +1149,18 @@ void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand( } fout << "file(REMOVE_RECURSE\n"; for (std::string const& cfl : cleanFiles) { - std::string fc = rootLG->MaybeConvertToRelativePath( - binaryDir, cmSystemTools::CollapseFullPath(cfl, currentBinaryDir)); + std::string fc = rootLG->MaybeRelativeToCurBinDir( + cmSystemTools::CollapseFullPath(cfl, currentBinaryDir)); fout << " " << cmOutputConverter::EscapeForCMake(fc) << "\n"; } fout << ")\n"; } // Create command { - std::string remove = - cmStrCat("$(CMAKE_COMMAND) -P ", - this->ConvertToOutputFormat( - rootLG->MaybeConvertToRelativePath(binaryDir, cleanfile), - cmOutputConverter::SHELL)); + std::string remove = cmStrCat( + "$(CMAKE_COMMAND) -P ", + this->ConvertToOutputFormat(rootLG->MaybeRelativeToCurBinDir(cleanfile), + cmOutputConverter::SHELL)); commands.push_back(std::move(remove)); } } @@ -1521,13 +1510,11 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( // Setup relative path top directories. if (cmProp relativePathTopSource = mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE")) { - this->StateSnapshot.GetDirectory().SetRelativePathTopSource( - relativePathTopSource->c_str()); + this->SetRelativePathTopSource(*relativePathTopSource); } if (cmProp relativePathTopBinary = mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY")) { - this->StateSnapshot.GetDirectory().SetRelativePathTopBinary( - relativePathTopBinary->c_str()); + this->SetRelativePathTopBinary(*relativePathTopBinary); } } else { cmSystemTools::Error("Directory Information file not found"); @@ -1964,8 +1951,7 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( cm::erase_if(includes, ::NotInProjectDir(sourceDir, binaryDir)); } for (std::string const& include : includes) { - cmakefileStream << " \"" - << this->MaybeConvertToRelativePath(binaryDir, include) + cmakefileStream << " \"" << this->MaybeRelativeToTopBinDir(include) << "\"\n"; } cmakefileStream << " )\n"; @@ -2004,12 +1990,9 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( for (auto const& compilerPair : compilerPairs) { for (auto const& src : compilerPair.second) { cmakefileStream << R"( "" ")" - << this->MaybeConvertToRelativePath( - this->GetBinaryDirectory(), compilerPair.first) + << this->MaybeRelativeToTopBinDir(compilerPair.first) << R"(" "custom" ")" - << this->MaybeConvertToRelativePath( - this->GetBinaryDirectory(), src) - << "\"\n"; + << this->MaybeRelativeToTopBinDir(src) << "\"\n"; } } } else { @@ -2018,11 +2001,9 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( for (auto const& compilerPair : compilerPairs) { for (auto const& src : compilerPair.second) { cmakefileStream << " \"" << src << "\" \"" - << this->MaybeConvertToRelativePath( - this->GetBinaryDirectory(), compilerPair.first) + << this->MaybeRelativeToTopBinDir(compilerPair.first) << "\" \"" << depFormat << "\" \"" - << this->MaybeConvertToRelativePath( - this->GetBinaryDirectory(), compilerPair.first) + << this->MaybeRelativeToTopBinDir(compilerPair.first) << ".d\"\n"; } } @@ -2066,8 +2047,7 @@ 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->MaybeConvertToRelativePath(this->GetBinaryDirectory(), tgt); + std::string tgt2 = this->MaybeRelativeToTopBinDir(tgt); // The target may have been written with windows paths. cmSystemTools::ConvertToOutputSlashes(tgt2); |