@@ -17,12 +17,12 @@ import enum TSCUtility.Git
1717
1818let sdkRoot : AbsolutePath ? = {
1919 if let environmentPath = ProcessInfo . processInfo. environment [ " SDK_ROOT " ] {
20- return AbsolutePath ( environmentPath)
20+ return try ! AbsolutePath ( validating : environmentPath)
2121 }
2222
2323 #if os(macOS)
2424 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 ( ) )
2626 return sdkRoot
2727 #else
2828 return nil
@@ -31,21 +31,21 @@ let sdkRoot: AbsolutePath? = {
3131
3232let toolchainPath : AbsolutePath = {
3333 if let environmentPath = ProcessInfo . processInfo. environment [ " TOOLCHAIN_PATH " ] {
34- return AbsolutePath ( environmentPath)
34+ return try ! AbsolutePath ( validating : environmentPath)
3535 }
3636
3737 #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 ( ) )
3939 #else
40- let swiftcPath = try ! AbsolutePath ( sh ( " which " , " swift " ) . stdout. spm_chomp ( ) )
40+ let swiftcPath = try ! AbsolutePath ( validating : sh ( " which " , " swift " ) . stdout. spm_chomp ( ) )
4141 #endif
4242 let toolchainPath = swiftcPath. parentDirectory. parentDirectory. parentDirectory
4343 return toolchainPath
4444} ( )
4545
4646let clang : AbsolutePath = {
4747 if let environmentPath = ProcessInfo . processInfo. environment [ " CLANG_PATH " ] {
48- return AbsolutePath ( environmentPath)
48+ return try ! AbsolutePath ( validating : environmentPath)
4949 }
5050
5151 let clangPath = toolchainPath. appending ( components: " usr " , " bin " , " clang " )
@@ -54,7 +54,7 @@ let clang: AbsolutePath = {
5454
5555let xcodebuild : AbsolutePath = {
5656 #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 ( ) )
5858 return xcodebuildPath
5959 #else
6060 fatalError ( " should not be used on other platforms than macOS " )
@@ -63,7 +63,7 @@ let xcodebuild: AbsolutePath = {
6363
6464let swift : AbsolutePath = {
6565 if let environmentPath = ProcessInfo . processInfo. environment [ " SWIFT_PATH " ] {
66- return AbsolutePath ( environmentPath)
66+ return try ! AbsolutePath ( validating : environmentPath)
6767 }
6868
6969 let swiftPath = toolchainPath. appending ( components: " usr " , " bin " , " swift " )
@@ -72,7 +72,7 @@ let swift: AbsolutePath = {
7272
7373let swiftc : AbsolutePath = {
7474 if let environmentPath = ProcessInfo . processInfo. environment [ " SWIFTC_PATH " ] {
75- return AbsolutePath ( environmentPath)
75+ return try ! AbsolutePath ( validating : environmentPath)
7676 }
7777
7878 let swiftcPath = toolchainPath. appending ( components: " usr " , " bin " , " swiftc " )
@@ -81,7 +81,7 @@ let swiftc: AbsolutePath = {
8181
8282let lldb : AbsolutePath = {
8383 if let environmentPath = ProcessInfo . processInfo. environment [ " LLDB_PATH " ] {
84- return AbsolutePath ( environmentPath)
84+ return try ! AbsolutePath ( validating : environmentPath)
8585 }
8686
8787 // We check if it exists because lldb doesn't exist in Xcode's default toolchain.
@@ -91,7 +91,7 @@ let lldb: AbsolutePath = {
9191 }
9292
9393 #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 ( ) )
9595 return lldbPath
9696 #else
9797 fatalError ( " LLDB_PATH environment variable required " )
@@ -100,7 +100,7 @@ let lldb: AbsolutePath = {
100100
101101let swiftpmBinaryDirectory : AbsolutePath = {
102102 if let environmentPath = ProcessInfo . processInfo. environment [ " SWIFTPM_BIN_DIR " ] {
103- return AbsolutePath ( environmentPath)
103+ return try ! AbsolutePath ( validating : environmentPath)
104104 }
105105
106106 return swift. parentDirectory
@@ -209,7 +209,10 @@ func fixture(
209209
210210 // Construct the expected path of the fixture.
211211 // 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+ )
213216
214217 // Check that the fixture is really there.
215218 guard localFileSystem. isDirectory ( fixtureDir) else {
@@ -317,7 +320,10 @@ func binaryTargetsFixture(_ closure: (AbsolutePath) throws -> Void) throws {
317320 let subpath = inputsPath. appending ( component: " SwiftFramework " )
318321 let projectPath = subpath. appending ( component: " SwiftFramework.xcodeproj " )
319322 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+ )
321327 let xcframeworkPath = packagePath. appending ( component: " SwiftFramework.xcframework " )
322328 try sh ( xcodebuild, " -create-xcframework " , " -framework " , frameworkPath, " -output " , xcframeworkPath)
323329 }
0 commit comments