Skip to content

Commit cabb453

Browse files
authored
Merge pull request #2579 from aciidb0mb3r/tmp-dir-5.2
[PackageLoading] Use temporary directory when compiling manifest
2 parents 4f8700b + 95ac3b9 commit cabb453

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Sources/PackageLoading/ManifestLoader.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,10 @@ public final class ManifestLoader: ManifestLoaderProtocol {
533533

534534
cmd += [manifestPath.pathString]
535535

536-
try withTemporaryFile { file in
536+
try withTemporaryDirectory(removeTreeOnDeinit: true) { tmpDir in
537537
// Set path to compiled manifest executable.
538-
cmd += ["-o", file.path.pathString]
539-
540-
try Process.popen(arguments: cmd)
538+
let file = tmpDir.appending(components: "\(packageIdentity)-manifest")
539+
cmd += ["-o", file.pathString]
541540

542541
// Compile the manifest.
543542
let compilerResult = try Process.popen(arguments: cmd)
@@ -550,7 +549,7 @@ public final class ManifestLoader: ManifestLoaderProtocol {
550549
}
551550

552551
// Pass the fd in arguments.
553-
cmd = [file.path.pathString, "-fileno", "1"]
552+
cmd = [file.pathString, "-fileno", "1"]
554553

555554
#if os(macOS)
556555
// If enabled, use sandbox-exec on macOS. This provides some safety against

0 commit comments

Comments
 (0)