@@ -18,12 +18,19 @@ import struct SystemPackage.FilePath
18
18
public struct LinuxRecipe : SwiftSDKRecipe {
19
19
public enum TargetSwiftSource : Sendable {
20
20
case docker( baseSwiftDockerImage: String )
21
- case tarball
21
+ case localPackage( FilePath )
22
+ case remoteTarball
23
+ }
24
+
25
+ public enum HostSwiftSource : Sendable {
26
+ case localPackage( FilePath )
27
+ case remoteTarball
22
28
}
23
29
24
30
let mainTargetTriple : Triple
25
31
let linuxDistribution : LinuxDistribution
26
32
let targetSwiftSource : TargetSwiftSource
33
+ let hostSwiftSource : HostSwiftSource
27
34
let versionsConfiguration : VersionsConfiguration
28
35
29
36
var shouldUseDocker : Bool {
@@ -40,7 +47,9 @@ public struct LinuxRecipe: SwiftSDKRecipe {
40
47
swiftBranch: String ? ,
41
48
lldVersion: String ,
42
49
withDocker: Bool ,
43
- fromContainerImage: String ?
50
+ fromContainerImage: String ? ,
51
+ hostSwiftPackagePath: String ? ,
52
+ targetSwiftPackagePath: String ?
44
53
) throws {
45
54
let versionsConfiguration = try VersionsConfiguration (
46
55
swiftVersion: swiftVersion,
@@ -51,17 +60,28 @@ public struct LinuxRecipe: SwiftSDKRecipe {
51
60
)
52
61
53
62
let targetSwiftSource : LinuxRecipe . TargetSwiftSource
54
- if withDocker {
55
- let imageName = fromContainerImage ?? versionsConfiguration. swiftBaseDockerImage
56
- targetSwiftSource = . docker( baseSwiftDockerImage: imageName)
63
+ if let targetSwiftPackagePath {
64
+ targetSwiftSource = . localPackage( FilePath ( targetSwiftPackagePath) )
65
+ } else {
66
+ if withDocker {
67
+ let imageName = fromContainerImage ?? versionsConfiguration. swiftBaseDockerImage
68
+ targetSwiftSource = . docker( baseSwiftDockerImage: imageName)
69
+ } else {
70
+ targetSwiftSource = . remoteTarball
71
+ }
72
+ }
73
+ let hostSwiftSource : HostSwiftSource
74
+ if let hostSwiftPackagePath {
75
+ hostSwiftSource = . localPackage( FilePath ( hostSwiftPackagePath) )
57
76
} else {
58
- targetSwiftSource = . tarball
77
+ hostSwiftSource = . remoteTarball
59
78
}
60
79
61
80
self . init (
62
81
mainTargetTriple: targetTriple,
63
82
linuxDistribution: linuxDistribution,
64
83
targetSwiftSource: targetSwiftSource,
84
+ hostSwiftSource: hostSwiftSource,
65
85
versionsConfiguration: versionsConfiguration
66
86
)
67
87
}
@@ -70,11 +90,13 @@ public struct LinuxRecipe: SwiftSDKRecipe {
70
90
mainTargetTriple: Triple ,
71
91
linuxDistribution: LinuxDistribution ,
72
92
targetSwiftSource: TargetSwiftSource ,
93
+ hostSwiftSource: HostSwiftSource ,
73
94
versionsConfiguration: VersionsConfiguration
74
95
) {
75
96
self . mainTargetTriple = mainTargetTriple
76
97
self . linuxDistribution = linuxDistribution
77
98
self . targetSwiftSource = targetSwiftSource
99
+ self . hostSwiftSource = hostSwiftSource
78
100
self . versionsConfiguration = versionsConfiguration
79
101
}
80
102
@@ -112,12 +134,29 @@ public struct LinuxRecipe: SwiftSDKRecipe {
112
134
var downloadableArtifacts = try DownloadableArtifacts (
113
135
hostTriple: generator. hostTriple,
114
136
targetTriple: generator. targetTriple,
115
- shouldUseDocker: shouldUseDocker,
116
137
versionsConfiguration,
117
138
generator. pathsConfiguration
118
139
)
119
140
120
- try await generator. downloadArtifacts ( client, engine, downloadableArtifacts: & downloadableArtifacts)
141
+ try await generator. downloadArtifacts (
142
+ client,
143
+ engine,
144
+ downloadableArtifacts: & downloadableArtifacts,
145
+ itemsToDownload: { artifacts in
146
+ var items = [ artifacts. hostLLVM]
147
+ switch targetSwiftSource {
148
+ case . remoteTarball:
149
+ items. append ( artifacts. targetSwift)
150
+ case . docker, . localPackage: break
151
+ }
152
+ switch hostSwiftSource {
153
+ case . remoteTarball:
154
+ items. append ( artifacts. hostSwift)
155
+ case . localPackage: break
156
+ }
157
+ return items
158
+ }
159
+ )
121
160
122
161
if !self . shouldUseDocker {
123
162
guard case let . ubuntu( version) = linuxDistribution else {
@@ -134,9 +173,16 @@ public struct LinuxRecipe: SwiftSDKRecipe {
134
173
)
135
174
}
136
175
137
- try await generator. unpackHostSwift (
138
- hostSwiftPackagePath: downloadableArtifacts. hostSwift. localPath
139
- )
176
+ switch self . hostSwiftSource {
177
+ case . localPackage( let filePath) :
178
+ try await generator. rsync (
179
+ from: filePath. appending ( " usr " ) , to: generator. pathsConfiguration. toolchainDirPath
180
+ )
181
+ case . remoteTarball:
182
+ try await generator. unpackHostSwift (
183
+ hostSwiftPackagePath: downloadableArtifacts. hostSwift. localPath
184
+ )
185
+ }
140
186
141
187
switch self . targetSwiftSource {
142
188
case let . docker( baseSwiftDockerImage) :
@@ -145,7 +191,11 @@ public struct LinuxRecipe: SwiftSDKRecipe {
145
191
baseDockerImage: baseSwiftDockerImage,
146
192
sdkDirPath: sdkDirPath
147
193
)
148
- case . tarball:
194
+ case . localPackage( let filePath) :
195
+ try await generator. copyTargetSwift (
196
+ from: filePath. appending ( " usr/lib " ) , sdkDirPath: sdkDirPath
197
+ )
198
+ case . remoteTarball:
149
199
try await generator. unpackTargetSwiftPackage (
150
200
targetSwiftPackagePath: downloadableArtifacts. targetSwift. localPath,
151
201
relativePathToRoot: [ FilePath . Component ( versionsConfiguration. swiftDistributionName ( ) ) !] ,
0 commit comments