summaryrefslogtreecommitdiffstats
path: root/Source/cmTransformDepfile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-05-12 19:51:47 (GMT)
committerBrad King <brad.king@kitware.com>2021-05-13 16:47:25 (GMT)
commit15fa3200715869d5acb94a282feb301d2e10a0eb (patch)
tree9c5d6c18b03b2917cc54d7fa2cfa5b9c89d8e4b0 /Source/cmTransformDepfile.cxx
parent1879f1bcbc4e2fbd9eaca4eff351ab928c4a3268 (diff)
downloadCMake-15fa3200715869d5acb94a282feb301d2e10a0eb.zip
CMake-15fa3200715869d5acb94a282feb301d2e10a0eb.tar.gz
CMake-15fa3200715869d5acb94a282feb301d2e10a0eb.tar.bz2
cmLocalGenerator: Factor out relative path conversion helpers
Most calls to `MaybeConvertToRelativePath` use one of our common work directories (e.g. top of the build tree) as the local path. Add helpers for each of the common cases to simplify and clarify call sites.
Diffstat (limited to 'Source/cmTransformDepfile.cxx')
-rw-r--r--Source/cmTransformDepfile.cxx13
1 files changed, 4 insertions, 9 deletions
diff --git a/Source/cmTransformDepfile.cxx b/Source/cmTransformDepfile.cxx
index 6e0366c..6927300 100644
--- a/Source/cmTransformDepfile.cxx
+++ b/Source/cmTransformDepfile.cxx
@@ -40,10 +40,9 @@ void WriteDepfile(cmDepfileFormat format, cmsys::ofstream& fout,
const cmLocalGenerator& lg,
const cmGccDepfileContent& content)
{
- const auto& binDir = lg.GetBinaryDirectory();
std::function<std::string(const std::string&)> formatPath =
- [&lg, &binDir](const std::string& path) -> std::string {
- return lg.MaybeConvertToRelativePath(binDir, path);
+ [&lg](const std::string& path) -> std::string {
+ return lg.MaybeRelativeToTopBinDir(path);
};
if (lg.GetGlobalGenerator()->GetName() == "Xcode") {
// full paths must be preserved for Xcode compliance
@@ -93,8 +92,6 @@ std::string ConvertToTLogOutputPath(const std::string& path)
void WriteVsTlog(cmsys::ofstream& fout, const cmLocalGenerator& lg,
const cmGccDepfileContent& content)
{
- const auto& binDir = lg.GetBinaryDirectory();
-
for (auto const& dep : content) {
fout << '^';
bool first = true;
@@ -103,13 +100,11 @@ void WriteVsTlog(cmsys::ofstream& fout, const cmLocalGenerator& lg,
fout << '|';
}
first = false;
- fout << ConvertToTLogOutputPath(
- lg.MaybeConvertToRelativePath(binDir, rule));
+ fout << ConvertToTLogOutputPath(lg.MaybeRelativeToTopBinDir(rule));
}
fout << "\r\n";
for (auto const& path : dep.paths) {
- fout << ConvertToTLogOutputPath(
- lg.MaybeConvertToRelativePath(binDir, path))
+ fout << ConvertToTLogOutputPath(lg.MaybeRelativeToTopBinDir(path))
<< "\r\n";
}
}