diff --git a/swift/extractor/infra/file/TargetFile.cpp b/swift/extractor/infra/file/TargetFile.cpp index a955d84ee03..4a16a155b30 100644 --- a/swift/extractor/infra/file/TargetFile.cpp +++ b/swift/extractor/infra/file/TargetFile.cpp @@ -36,11 +36,7 @@ void ensureParentDir(const fs::path& path) { fs::path initPath(const std::filesystem::path& target, const std::filesystem::path& dir) { fs::path ret{dir}; assert(!target.empty() && "target must be a non-empty path"); - if (target.is_absolute()) { - ret += target; - } else { - ret /= target; - } + ret /= target.relative_path(); ensureParentDir(ret); return ret; } diff --git a/swift/extractor/remapping/SwiftOutputRewrite.cpp b/swift/extractor/remapping/SwiftOutputRewrite.cpp index 2383d233ae5..914a54d93f1 100644 --- a/swift/extractor/remapping/SwiftOutputRewrite.cpp +++ b/swift/extractor/remapping/SwiftOutputRewrite.cpp @@ -21,7 +21,7 @@ static std::optional rewriteOutputFileMap(const fs::path& scratchDir, const fs::path& outputFileMapPath, const std::vector& inputs, PathRemapping& remapping) { - auto newMapPath = scratchDir / outputFileMapPath; + auto newMapPath = scratchDir / outputFileMapPath.relative_path(); // TODO: do not assume absolute path for the second parameter auto outputMapOrError = swift::OutputFileMap::loadFromPath(outputFileMapPath.c_str(), ""); @@ -41,8 +41,8 @@ static std::optional rewriteOutputFileMap(const fs::path& scratchDir, auto& newMap = newOutputMap.getOrCreateOutputMapForInput(key.c_str()); newMap.copyFrom(*oldMap); for (auto& entry : newMap) { - auto oldPath = entry.getSecond(); - auto newPath = scratchDir / oldPath; + fs::path oldPath = entry.getSecond(); + auto newPath = scratchDir / oldPath.relative_path(); entry.getSecond() = newPath; remapping[oldPath] = newPath; } @@ -91,7 +91,7 @@ PathRemapping rewriteOutputsInPlace(const fs::path& scratchDir, std::vector