@@ -17,12 +17,12 @@ import enum TSCUtility.Git
17
17
18
18
let sdkRoot : AbsolutePath ? = {
19
19
if let environmentPath = ProcessInfo . processInfo. environment [ " SDK_ROOT " ] {
20
- return AbsolutePath ( environmentPath)
20
+ return try ! AbsolutePath ( validating : environmentPath)
21
21
}
22
22
23
23
#if os(macOS)
24
24
let result = try ! Process . popen ( arguments: [ " xcrun " , " --sdk " , " macosx " , " --show-sdk-path " ] )
25
- let sdkRoot = try ! AbsolutePath ( result. utf8Output ( ) . spm_chomp ( ) )
25
+ let sdkRoot = try ! AbsolutePath ( validating : result. utf8Output ( ) . spm_chomp ( ) )
26
26
return sdkRoot
27
27
#else
28
28
return nil
@@ -31,21 +31,21 @@ let sdkRoot: AbsolutePath? = {
31
31
32
32
let toolchainPath : AbsolutePath = {
33
33
if let environmentPath = ProcessInfo . processInfo. environment [ " TOOLCHAIN_PATH " ] {
34
- return AbsolutePath ( environmentPath)
34
+ return try ! AbsolutePath ( validating : environmentPath)
35
35
}
36
36
37
37
#if os(macOS)
38
- let swiftcPath = try ! AbsolutePath ( sh ( " xcrun " , " --find " , " swift " ) . stdout. spm_chomp ( ) )
38
+ let swiftcPath = try ! AbsolutePath ( validating : sh ( " xcrun " , " --find " , " swift " ) . stdout. spm_chomp ( ) )
39
39
#else
40
- let swiftcPath = try ! AbsolutePath ( sh ( " which " , " swift " ) . stdout. spm_chomp ( ) )
40
+ let swiftcPath = try ! AbsolutePath ( validating : sh ( " which " , " swift " ) . stdout. spm_chomp ( ) )
41
41
#endif
42
42
let toolchainPath = swiftcPath. parentDirectory. parentDirectory. parentDirectory
43
43
return toolchainPath
44
44
} ( )
45
45
46
46
let clang : AbsolutePath = {
47
47
if let environmentPath = ProcessInfo . processInfo. environment [ " CLANG_PATH " ] {
48
- return AbsolutePath ( environmentPath)
48
+ return try ! AbsolutePath ( validating : environmentPath)
49
49
}
50
50
51
51
let clangPath = toolchainPath. appending ( components: " usr " , " bin " , " clang " )
@@ -54,7 +54,7 @@ let clang: AbsolutePath = {
54
54
55
55
let xcodebuild : AbsolutePath = {
56
56
#if os(macOS)
57
- let xcodebuildPath = try ! AbsolutePath ( sh ( " xcrun " , " --find " , " xcodebuild " ) . stdout. spm_chomp ( ) )
57
+ let xcodebuildPath = try ! AbsolutePath ( validating : sh ( " xcrun " , " --find " , " xcodebuild " ) . stdout. spm_chomp ( ) )
58
58
return xcodebuildPath
59
59
#else
60
60
fatalError ( " should not be used on other platforms than macOS " )
@@ -63,7 +63,7 @@ let xcodebuild: AbsolutePath = {
63
63
64
64
let swift : AbsolutePath = {
65
65
if let environmentPath = ProcessInfo . processInfo. environment [ " SWIFT_PATH " ] {
66
- return AbsolutePath ( environmentPath)
66
+ return try ! AbsolutePath ( validating : environmentPath)
67
67
}
68
68
69
69
let swiftPath = toolchainPath. appending ( components: " usr " , " bin " , " swift " )
@@ -72,7 +72,7 @@ let swift: AbsolutePath = {
72
72
73
73
let swiftc : AbsolutePath = {
74
74
if let environmentPath = ProcessInfo . processInfo. environment [ " SWIFTC_PATH " ] {
75
- return AbsolutePath ( environmentPath)
75
+ return try ! AbsolutePath ( validating : environmentPath)
76
76
}
77
77
78
78
let swiftcPath = toolchainPath. appending ( components: " usr " , " bin " , " swiftc " )
@@ -81,7 +81,7 @@ let swiftc: AbsolutePath = {
81
81
82
82
let lldb : AbsolutePath = {
83
83
if let environmentPath = ProcessInfo . processInfo. environment [ " LLDB_PATH " ] {
84
- return AbsolutePath ( environmentPath)
84
+ return try ! AbsolutePath ( validating : environmentPath)
85
85
}
86
86
87
87
// We check if it exists because lldb doesn't exist in Xcode's default toolchain.
@@ -91,7 +91,7 @@ let lldb: AbsolutePath = {
91
91
}
92
92
93
93
#if os(macOS)
94
- let lldbPath = try ! AbsolutePath ( sh ( " xcrun " , " --find " , " lldb " ) . stdout. spm_chomp ( ) )
94
+ let lldbPath = try ! AbsolutePath ( validating : sh ( " xcrun " , " --find " , " lldb " ) . stdout. spm_chomp ( ) )
95
95
return lldbPath
96
96
#else
97
97
fatalError ( " LLDB_PATH environment variable required " )
@@ -100,7 +100,7 @@ let lldb: AbsolutePath = {
100
100
101
101
let swiftpmBinaryDirectory : AbsolutePath = {
102
102
if let environmentPath = ProcessInfo . processInfo. environment [ " SWIFTPM_BIN_DIR " ] {
103
- return AbsolutePath ( environmentPath)
103
+ return try ! AbsolutePath ( validating : environmentPath)
104
104
}
105
105
106
106
return swift. parentDirectory
@@ -209,7 +209,10 @@ func fixture(
209
209
210
210
// Construct the expected path of the fixture.
211
211
// FIXME: This seems quite hacky; we should provide some control over where fixtures are found.
212
- let fixtureDir = AbsolutePath ( " ../../../Fixtures/ \( name) " , relativeTo: AbsolutePath ( #file) )
212
+ let fixtureDir = try AbsolutePath (
213
+ validating: " ../../../Fixtures/ \( name) " ,
214
+ relativeTo: AbsolutePath ( validating: #file)
215
+ )
213
216
214
217
// Check that the fixture is really there.
215
218
guard localFileSystem. isDirectory ( fixtureDir) else {
@@ -317,7 +320,10 @@ func binaryTargetsFixture(_ closure: (AbsolutePath) throws -> Void) throws {
317
320
let subpath = inputsPath. appending ( component: " SwiftFramework " )
318
321
let projectPath = subpath. appending ( component: " SwiftFramework.xcodeproj " )
319
322
try sh ( xcodebuild, " -project " , projectPath, " -scheme " , " SwiftFramework " , " -derivedDataPath " , tmpDir, " COMPILER_INDEX_STORE_ENABLE=NO " )
320
- let frameworkPath = AbsolutePath ( " Build/Products/Debug/SwiftFramework.framework " , relativeTo: tmpDir)
323
+ let frameworkPath = try AbsolutePath (
324
+ validating: " Build/Products/Debug/SwiftFramework.framework " ,
325
+ relativeTo: tmpDir
326
+ )
321
327
let xcframeworkPath = packagePath. appending ( component: " SwiftFramework.xcframework " )
322
328
try sh ( xcodebuild, " -create-xcframework " , " -framework " , frameworkPath, " -output " , xcframeworkPath)
323
329
}
0 commit comments