@@ -55,7 +55,11 @@ public struct Destination {
55
55
public let extraCPPFlags : [ String ]
56
56
57
57
/// Returns the bin directory for the host.
58
- private static func hostBinDir( ) -> AbsolutePath {
58
+ ///
59
+ /// - Parameter originalWorkingDirectory: The working directory when the program was launched.
60
+ private static func hostBinDir(
61
+ originalWorkingDirectory: AbsolutePath = currentWorkingDirectory
62
+ ) -> AbsolutePath {
59
63
#if Xcode
60
64
// For Xcode, set bin directory to the build directory containing the fake
61
65
// toolchain created during bootstraping. This is obviously not production ready
@@ -70,14 +74,18 @@ public struct Destination {
70
74
. parentDirectory. parentDirectory. appending ( components: " .build " , " debug " )
71
75
#else
72
76
return AbsolutePath (
73
- CommandLine . arguments [ 0 ] , relativeTo: currentWorkingDirectory ) . parentDirectory
77
+ CommandLine . arguments [ 0 ] , relativeTo: originalWorkingDirectory ) . parentDirectory
74
78
#endif
75
79
}
76
80
77
81
/// The destination describing the host OS.
78
- public static func hostDestination( _ binDir: AbsolutePath ? = nil ) throws -> Destination {
82
+ public static func hostDestination(
83
+ _ binDir: AbsolutePath ? = nil ,
84
+ originalWorkingDirectory: AbsolutePath = currentWorkingDirectory
85
+ ) throws -> Destination {
79
86
// Select the correct binDir.
80
- let binDir = binDir ?? Destination . hostBinDir ( )
87
+ let binDir = binDir ?? Destination . hostBinDir (
88
+ originalWorkingDirectory: originalWorkingDirectory)
81
89
82
90
#if os(macOS)
83
91
// Get the SDK.
0 commit comments