Skip to content

Commit 96621f9

Browse files
committed
Fix precondition failures with relative paths on the command line.
This is fallout from the AbsolutePath adoption changes.
1 parent cf9921b commit 96621f9

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

Sources/Commands/Options.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class Options {
2626
set { _build = newValue.asString }
2727
}
2828

29-
private var _build = getenv("SWIFT_BUILD_PATH")
29+
private var _build = getenv("SWIFT_BUILD_PATH")?.abspath
3030
}
3131

3232
public init()

Sources/Commands/SwiftBuildTool.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private enum BuildToolFlag: Argument {
8181

8282
switch argument {
8383
case Flag.chdir, Flag.C:
84-
self = try .chdir(AbsolutePath(forcePop()))
84+
self = try .chdir(AbsolutePath(forcePop().abspath))
8585
case "--verbose", "-v":
8686
self = .verbose(1)
8787
case "-Xcc":
@@ -91,7 +91,7 @@ private enum BuildToolFlag: Argument {
9191
case "-Xswiftc":
9292
self = try .xswiftc(forcePop())
9393
case "--build-path":
94-
self = try .buildPath(AbsolutePath(forcePop()))
94+
self = try .buildPath(AbsolutePath(forcePop().abspath))
9595
case "--build-tests":
9696
self = .buildTests
9797
case "--color":
@@ -103,7 +103,7 @@ private enum BuildToolFlag: Argument {
103103
case "--ignore-dependencies":
104104
self = .ignoreDependencies
105105
case "--xcconfig-overrides":
106-
self = try .xcconfigOverrides(AbsolutePath(forcePop()))
106+
self = try .xcconfigOverrides(AbsolutePath(forcePop().abspath))
107107
default:
108108
return nil
109109
}
@@ -173,10 +173,10 @@ public struct SwiftBuildTool: SwiftTool {
173173
fallthrough
174174

175175
case .clean(.build):
176-
let artifacts = ["debug", "release"].map{ AbsolutePath(opts.path.build, $0) }.map{ ($0, "\($0).yaml") }
176+
let artifacts = ["debug", "release"].map{ AbsolutePath(opts.path.build, $0) }.map{ ($0, AbsolutePath("\($0.asString).yaml")) }
177177
for (dir, yml) in artifacts {
178178
if dir.asString.isDirectory { try Utility.removeFileTree(dir.asString) }
179-
if yml.abspath.isFile { try Utility.removeFileTree(yml) }
179+
if yml.asString.isFile { try Utility.removeFileTree(yml.asString) }
180180
}
181181

182182
let db = opts.path.build.appending("build.db")

Sources/Commands/SwiftPackageTool.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ private enum PackageToolFlag: Argument {
103103

104104
switch argument {
105105
case Flag.chdir, Flag.C:
106-
self = try .chdir(AbsolutePath(forcePop()))
106+
self = try .chdir(AbsolutePath(forcePop().abspath))
107107
case "--type":
108108
self = try .initMode(forcePop())
109109
case "--format":
110110
self = try .showDepsMode(forcePop())
111111
case "--output":
112-
self = try .outputPath(AbsolutePath(forcePop()))
112+
self = try .outputPath(AbsolutePath(forcePop().abspath))
113113
case "--input":
114-
self = try .inputPath(AbsolutePath(forcePop()))
114+
self = try .inputPath(AbsolutePath(forcePop().abspath))
115115
case "--verbose", "-v":
116116
self = .verbose(1)
117117
case "--color":
@@ -129,7 +129,7 @@ private enum PackageToolFlag: Argument {
129129
case "-Xswiftc":
130130
self = try .xswiftc(forcePop())
131131
case "--xcconfig-overrides":
132-
self = try .xcconfigOverrides(AbsolutePath(forcePop()))
132+
self = try .xcconfigOverrides(AbsolutePath(forcePop().abspath))
133133
default:
134134
return nil
135135
}

Sources/Commands/SwiftTestTool.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private enum TestToolFlag: Argument {
7676
switch argument {
7777
case "--chdir", "-C":
7878
guard let path = pop() else { throw OptionParserError.expectedAssociatedValue(argument) }
79-
self = .chdir(AbsolutePath(path))
79+
self = .chdir(AbsolutePath(path.abspath))
8080
case "--skip-build":
8181
self = .skipBuild
8282
case "--build-path":
@@ -172,7 +172,7 @@ public struct SwiftTestTool: SwiftTool {
172172
throw TestError.testsExecutableNotFound
173173
}
174174

175-
return AbsolutePath(path)
175+
return AbsolutePath(path.abspath)
176176
}
177177
}
178178

Sources/Commands/ToolDefaults.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ struct ToolDefaults {
2020
// FIXME: This isn't correct; we need to handle a missing SWIFT_EXEC.
2121
static let SWIFT_EXEC = AbsolutePath(getenv("SWIFT_EXEC")!.abspath)
2222
static let llbuild = AbsolutePath(getenv("SWIFT_EXEC")!.abspath).appending("../swift-build-tool")
23-
static let libdir = AbsolutePath(argv0).parentDirectory
23+
static let libdir = AbsolutePath(argv0.abspath).parentDirectory
2424
#else
25-
static let SWIFT_EXEC = AbsolutePath(argv0).appending("../swiftc")
26-
static let llbuild = AbsolutePath(argv0).appending("../swift-build-tool")
27-
static let libdir = AbsolutePath(argv0).appending("../../lib/swift/pm")
25+
static let SWIFT_EXEC = AbsolutePath(argv0.abspath).appending("../swiftc")
26+
static let llbuild = AbsolutePath(argv0.abspath).appending("../swift-build-tool")
27+
static let libdir = AbsolutePath(argv0.abspath).appending("../../lib/swift/pm")
2828
#endif
2929
}

0 commit comments

Comments
 (0)