@@ -44,15 +44,27 @@ extension BuildPlan {
44
44
}
45
45
46
46
// Add flags for binary dependencies.
47
- for binaryPath in dependencies. libraryBinaryPaths {
47
+ var dynamicLibraries : Set < Substring > = [ ]
48
+ for binaryPath in dependencies. sharedLibraryBinaries {
49
+ if binaryPath. basename. starts ( with: " lib " ) , binaryPath. extension == " so " {
50
+ buildProduct. additionalFlags += [ " -L " , binaryPath. parentDirectory. pathString]
51
+ dynamicLibraries. insert ( binaryPath. basenameWithoutExt. dropFirst ( 3 ) )
52
+ } else {
53
+ self . observabilityScope. emit ( error: " unexpected binary library " )
54
+ }
55
+ }
56
+ for binaryPath in dependencies. xcframeworkBinaries {
48
57
if binaryPath. extension == " framework " {
49
58
buildProduct. additionalFlags += [ " -framework " , binaryPath. basenameWithoutExt]
50
59
} else if binaryPath. basename. starts ( with: " lib " ) {
51
- buildProduct . additionalFlags += [ " -l \ ( binaryPath. basenameWithoutExt. dropFirst ( 3 ) ) " ]
60
+ dynamicLibraries . insert ( binaryPath. basenameWithoutExt. dropFirst ( 3 ) )
52
61
} else {
53
62
self . observabilityScope. emit ( error: " unexpected binary framework " )
54
63
}
55
64
}
65
+ for dynamicLibrary : Substring in dynamicLibraries {
66
+ buildProduct. additionalFlags += [ " -l \( dynamicLibrary) " ]
67
+ }
56
68
57
69
// Don't link libc++ or libstd++ when building for Embedded Swift.
58
70
// Users can still link it manually for embedded platforms when needed,
@@ -102,7 +114,7 @@ extension BuildPlan {
102
114
buildProduct. staticTargets = dependencies. staticTargets. map ( \. module)
103
115
buildProduct. dylibs = dependencies. dylibs
104
116
buildProduct. objects += try dependencies. staticTargets. flatMap { try $0. objects }
105
- buildProduct. libraryBinaryPaths = dependencies. libraryBinaryPaths
117
+ buildProduct. libraryBinaryPaths = dependencies. xcframeworkBinaries
106
118
buildProduct. availableTools = dependencies. availableTools
107
119
}
108
120
@@ -113,7 +125,8 @@ extension BuildPlan {
113
125
dylibs: [ ProductBuildDescription ] ,
114
126
staticTargets: [ ModuleBuildDescription ] ,
115
127
systemModules: [ ResolvedModule ] ,
116
- libraryBinaryPaths: Set < AbsolutePath > ,
128
+ sharedLibraryBinaries: Set < AbsolutePath > ,
129
+ xcframeworkBinaries: Set < AbsolutePath > ,
117
130
availableTools: [ String : AbsolutePath ]
118
131
) {
119
132
let product = productDescription. product
@@ -230,7 +243,8 @@ extension BuildPlan {
230
243
var linkLibraries = [ ProductBuildDescription] ( )
231
244
var staticTargets = [ ModuleBuildDescription] ( )
232
245
var systemModules = [ ResolvedModule] ( )
233
- var libraryBinaryPaths : Set < AbsolutePath > = [ ]
246
+ var sharedLibraryBinaries : Set < AbsolutePath > = [ ]
247
+ var xcframeworkBinaries : Set < AbsolutePath > = [ ]
234
248
var availableTools = [ String: AbsolutePath] ( )
235
249
236
250
for dependency in allDependencies {
@@ -294,11 +308,17 @@ extension BuildPlan {
294
308
triple: productDescription. buildParameters. triple
295
309
)
296
310
for library in libraries {
297
- libraryBinaryPaths . insert ( library. libraryPath)
311
+ xcframeworkBinaries . insert ( library. libraryPath)
298
312
}
299
313
case . artifactsArchive:
300
- let tools = try self . parseArtifactsArchive (
301
- for: binaryTarget, triple: productDescription. buildParameters. triple
314
+ let libraries = try self . parseLibraries (
315
+ in: binaryTarget, triple: productDescription. buildParameters. triple
316
+ )
317
+ for library in libraries {
318
+ sharedLibraryBinaries. insert ( library. libraryPath)
319
+ }
320
+ let tools = try self . parseExecutables (
321
+ in: binaryTarget, triple: productDescription. buildParameters. triple
302
322
)
303
323
tools. forEach { availableTools [ $0. name] = $0. executablePath }
304
324
case . unknown:
@@ -326,14 +346,6 @@ extension BuildPlan {
326
346
} )
327
347
}
328
348
329
- return ( linkLibraries, staticTargets, systemModules, libraryBinaryPaths, availableTools)
330
- }
331
-
332
- /// Extracts the artifacts from an artifactsArchive
333
- private func parseArtifactsArchive( for binaryTarget: BinaryModule , triple: Triple ) throws -> [ ExecutableInfo ] {
334
- try self . externalExecutablesCache. memoize ( key: binaryTarget) {
335
- let execInfos = try binaryTarget. parseArtifactArchives ( for: triple, fileSystem: self . fileSystem)
336
- return execInfos. filter { !$0. supportedTriples. isEmpty }
337
- }
349
+ return ( linkLibraries, staticTargets, systemModules, sharedLibraryBinaries, xcframeworkBinaries, availableTools)
338
350
}
339
351
}
0 commit comments