@@ -15,13 +15,13 @@ import GeneratorEngine
15
15
import struct SystemPackage. FilePath
16
16
17
17
public struct WebAssemblyRecipe : SwiftSDKRecipe {
18
- let hostSwiftPackagePath : FilePath
18
+ let hostSwiftPackagePath : FilePath ?
19
19
let targetSwiftPackagePath : FilePath
20
20
let wasiSysroot : FilePath
21
21
let swiftVersion : String
22
22
23
23
public init (
24
- hostSwiftPackagePath: FilePath ,
24
+ hostSwiftPackagePath: FilePath ? ,
25
25
targetSwiftPackagePath: FilePath ,
26
26
wasiSysroot: FilePath ,
27
27
swiftVersion: String
@@ -48,22 +48,27 @@ public struct WebAssemblyRecipe: SwiftSDKRecipe {
48
48
) async throws -> SwiftSDKProduct {
49
49
let pathsConfiguration = generator. pathsConfiguration
50
50
logGenerationStep ( " Copying Swift binaries for the host triple... " )
51
- try await generator. rsync ( from: self . hostSwiftPackagePath. appending ( " usr " ) , to: pathsConfiguration. toolchainDirPath)
51
+ if let hostSwiftPackagePath {
52
+ try await generator. rsync ( from: hostSwiftPackagePath. appending ( " usr " ) , to: pathsConfiguration. toolchainDirPath)
52
53
53
- logGenerationStep ( " Removing unused toolchain components... " )
54
- let liblldbNames : [ String ] = try await {
55
- let libDirPath = pathsConfiguration. toolchainDirPath. appending ( " usr/lib " )
56
- return try await generator. contentsOfDirectory ( at: libDirPath) . filter { dirEntry in
57
- // liblldb is version suffixed: liblldb.so.17.0.0
58
- dirEntry. hasPrefix ( " liblldb " )
59
- }
60
- } ( )
61
- try await generator. removeToolchainComponents (
62
- pathsConfiguration. toolchainDirPath,
63
- platforms: unusedDarwinPlatforms + [ " embedded " ] ,
64
- libraries: unusedHostLibraries + liblldbNames,
65
- binaries: unusedHostBinaries + [ " lldb " , " lldb-argdumper " , " lldb-server " ]
66
- )
54
+ logGenerationStep ( " Removing unused toolchain components... " )
55
+ let liblldbNames : [ String ] = try await {
56
+ let libDirPath = pathsConfiguration. toolchainDirPath. appending ( " usr/lib " )
57
+ guard await generator. doesFileExist ( at: libDirPath) else {
58
+ return [ ]
59
+ }
60
+ return try await generator. contentsOfDirectory ( at: libDirPath) . filter { dirEntry in
61
+ // liblldb is version suffixed: liblldb.so.17.0.0
62
+ dirEntry. hasPrefix ( " liblldb " )
63
+ }
64
+ } ( )
65
+ try await generator. removeToolchainComponents (
66
+ pathsConfiguration. toolchainDirPath,
67
+ platforms: unusedDarwinPlatforms + [ " embedded " ] ,
68
+ libraries: unusedHostLibraries + liblldbNames,
69
+ binaries: unusedHostBinaries + [ " lldb " , " lldb-argdumper " , " lldb-server " ]
70
+ )
71
+ }
67
72
68
73
try await self . copyTargetSwift ( from: self . targetSwiftPackagePath. appending ( " usr/lib " ) , generator: generator)
69
74
0 commit comments