@@ -165,7 +165,7 @@ var sharedCSettings: [CSetting] = [
165165 . define( " NDEBUG " , . when( configuration: . release) ) ,
166166]
167167
168- var sharedCXXSettings : [ CXXSetting ] = [
168+ var sharedCxxSettings : [ CXXSetting ] = [
169169 . unsafeFlags( [ " -I " , libSwiftPath] , . when( platforms: . nonDarwinPlatforms) ) ,
170170 . define( " NDEBUG " , . when( configuration: . release) ) ,
171171]
@@ -185,7 +185,7 @@ sharedCSettings.append(
185185 " -isystem " , " \( swiftCheckoutPath) /stdlib/public/SwiftShims " ,
186186 ] )
187187)
188- sharedCXXSettings . append (
188+ sharedCxxSettings . append (
189189 . unsafeFlags( [
190190 " -isystem " , " \( swiftCheckoutPath) /include " ,
191191 " -isystem " , " \( swiftCheckoutPath) /stdlib/include " ,
@@ -208,7 +208,7 @@ if libraryEvolutionCondition {
208208}
209209if !compatibilityTestCondition {
210210 sharedCSettings. append ( . define( " OPENATTRIBUTEGRAPH " ) )
211- sharedCXXSettings . append ( . define( " OPENATTRIBUTEGRAPH " ) )
211+ sharedCxxSettings . append ( . define( " OPENATTRIBUTEGRAPH " ) )
212212 sharedSwiftSettings. append ( . define( " OPENATTRIBUTEGRAPH " ) )
213213}
214214
@@ -231,38 +231,49 @@ extension [Platform] {
231231 }
232232}
233233
234- // MARK: - Targets
234+ // MARK: - Plugin
235235
236236let swiftClonePlugin = Target . plugin (
237237 name: " CloneSwiftPlugin " ,
238238 capability: . buildTool( )
239239)
240240
241- let openAttributeGraphTarget = Target . target (
242- name: " OpenAttributeGraph " ,
243- dependencies: [ " OpenAttributeGraphCxx " ] ,
244- cSettings: sharedCSettings,
245- cxxSettings: sharedCXXSettings,
246- swiftSettings: sharedSwiftSettings
241+ // MARK: - Targets
242+
243+ let platformTarget = Target . target (
244+ name: " Platform " ,
245+ cSettings: [
246+ . define( " _GNU_SOURCE " , . when( platforms: [ . linux] ) ) ,
247+ ]
247248)
248249// FIXME: Merge into one target
249250// OpenAttributeGraph is a C++ & Swift mix target.
250251// The SwiftPM support for such usage is still in progress.
251- let openAttributeGraphSPITarget = Target . target (
252+ let openAttributeGraphCxxTarget = Target . target (
252253 name: " OpenAttributeGraphCxx " ,
254+ dependencies: [ . target( name: platformTarget. name) ] ,
253255 cSettings: sharedCSettings + [
254256 . define( " __COREFOUNDATION_FORSWIFTFOUNDATIONONLY__ " , to: " 1 " , . when( platforms: . nonDarwinPlatforms) ) ,
255257 ] ,
256- cxxSettings: sharedCXXSettings ,
258+ cxxSettings: sharedCxxSettings ,
257259 linkerSettings: [
258260 . linkedLibrary( " z " ) ,
259261 ] ,
260262 plugins: [ . plugin( name: swiftClonePlugin. name) ]
261263)
264+ let openAttributeGraphTarget = Target . target (
265+ name: " OpenAttributeGraph " ,
266+ dependencies: [
267+ . target( name: openAttributeGraphCxxTarget. name) ,
268+ ] ,
269+ cSettings: sharedCSettings,
270+ cxxSettings: sharedCxxSettings,
271+ swiftSettings: sharedSwiftSettings
272+ )
262273let openAttributeGraphShimsTarget = Target . target (
263274 name: " OpenAttributeGraphShims " ,
264275 cSettings: sharedCSettings,
265- cxxSettings: sharedCXXSettings ,
276+ cxxSettings: sharedCxxSettings ,
266277 swiftSettings: sharedSwiftSettings
267278)
268279
@@ -271,41 +282,41 @@ let openAttributeGraphShimsTarget = Target.target(
271282let openAttributeGraphTestsTarget = Target . testTarget (
272283 name: " OpenAttributeGraphTests " ,
273284 dependencies: [
274- " OpenAttributeGraph " ,
285+ . target ( name : openAttributeGraphTarget . name ) ,
275286 ] ,
276287 exclude: [ " README.md " ] ,
277288 cSettings: sharedCSettings,
278- cxxSettings: sharedCXXSettings ,
289+ cxxSettings: sharedCxxSettings ,
279290 swiftSettings: sharedSwiftSettings
280291)
281292let openAttributeGraphCxxTestsTarget = Target . testTarget (
282293 name: " OpenAttributeGraphCxxTests " ,
283294 dependencies: [
284- " OpenAttributeGraphCxx " ,
295+ . target ( name : openAttributeGraphCxxTarget . name ) ,
285296 ] ,
286297 exclude: [ " README.md " ] ,
287298 cSettings: sharedCSettings + [ . define( " SWIFT_TESTING " ) ] ,
288- cxxSettings: sharedCXXSettings ,
299+ cxxSettings: sharedCxxSettings ,
289300 swiftSettings: sharedSwiftSettings + [ . interoperabilityMode( . Cxx) ]
290301)
291302let openAttributeGraphShimsTestsTarget = Target . testTarget (
292303 name: " OpenAttributeGraphShimsTests " ,
293304 dependencies: [
294- " OpenAttributeGraphShims " ,
305+ . target ( name : openAttributeGraphShimsTarget . name ) ,
295306 ] ,
296307 exclude: [ " README.md " ] ,
297308 cSettings: sharedCSettings,
298- cxxSettings: sharedCXXSettings ,
309+ cxxSettings: sharedCxxSettings ,
299310 swiftSettings: sharedSwiftSettings
300311)
301312let openAttributeGraphCompatibilityTestsTarget = Target . testTarget (
302313 name: " OpenAttributeGraphCompatibilityTests " ,
303314 dependencies: [
304315 . product( name: " Numerics " , package : " swift-numerics " ) ,
305- ] + ( compatibilityTestCondition ? [ ] : [ " OpenAttributeGraph " ] ) ,
316+ ] + ( compatibilityTestCondition ? [ ] : [ . target ( name : openAttributeGraphTarget . name ) ] ) ,
306317 exclude: [ " README.md " ] ,
307318 cSettings: sharedCSettings,
308- cxxSettings: sharedCXXSettings ,
319+ cxxSettings: sharedCxxSettings ,
309320 swiftSettings: sharedSwiftSettings
310321)
311322
@@ -314,16 +325,17 @@ let openAttributeGraphCompatibilityTestsTarget = Target.testTarget(
314325let package = Package (
315326 name: " OpenAttributeGraph " ,
316327 products: [
317- . library( name: " OpenAttributeGraph " , type: . dynamic, targets: [ " OpenAttributeGraph " , " OpenAttributeGraphCxx " ] ) ,
318- . library( name: " OpenAttributeGraphShims " , type: . dynamic, targets: [ " OpenAttributeGraph " , " OpenAttributeGraphCxx " , " OpenAttributeGraphShims " ] ) ,
328+ . library( name: " OpenAttributeGraph " , type: . dynamic, targets: [ openAttributeGraphTarget . name , openAttributeGraphCxxTarget . name ] ) ,
329+ . library( name: " OpenAttributeGraphShims " , type: . dynamic, targets: [ openAttributeGraphTarget . name , openAttributeGraphCxxTarget . name , openAttributeGraphShimsTarget . name ] ) ,
319330 ] ,
320331 dependencies: [
321332 . package ( url: " https://github.com/apple/swift-numerics " , from: " 1.0.2 " ) ,
322333 ] ,
323334 targets: [
324335 swiftClonePlugin,
336+ platformTarget,
325337 openAttributeGraphTarget,
326- openAttributeGraphSPITarget ,
338+ openAttributeGraphCxxTarget ,
327339 openAttributeGraphShimsTarget,
328340 ] ,
329341 cxxLanguageStandard: . cxx20
@@ -362,6 +374,6 @@ if attributeGraphCondition {
362374 default : nil
363375 }
364376} else {
365- openAttributeGraphShimsTarget. dependencies. append ( " OpenAttributeGraph " )
377+ openAttributeGraphShimsTarget. dependencies. append ( . target ( name : openAttributeGraphTarget . name ) )
366378 package . platforms = [ . iOS( . v13) , . macOS( . v10_15) , . macCatalyst( . v13) , . tvOS( . v13) , . watchOS( . v5) ]
367379}
0 commit comments