@@ -148,9 +148,7 @@ let libSwiftPath = {
148148 return libSwiftPath
149149} ( )
150150
151- let swiftToolchainPath = envStringValue ( " SWIFT_TOOLCHAIN_PATH " ) ?? ( development ? " /Volumes/BuildMachine/swift-project " : " " )
152- let swiftToolchainVersion = envStringValue ( " SWIFT_TOOLCHAIN_VERSION " ) ?? ( development ? " 6.0.2 " : " " )
153- let swiftToolchainSupported = envBoolValue ( " SWIFT_TOOLCHAIN_SUPPORTED " , default: !swiftToolchainVersion. isEmpty)
151+ let swiftCheckoutPath = " \( Context . packageDirectory) /.build/checkouts/swift "
154152
155153let releaseVersion = envIntValue ( " TARGET_RELEASE " , default: 2024 )
156154
@@ -167,6 +165,11 @@ var sharedCSettings: [CSetting] = [
167165 . define( " NDEBUG " , . when( configuration: . release) ) ,
168166]
169167
168+ var sharedCXXSettings : [ CXXSetting ] = [
169+ . unsafeFlags( [ " -I " , libSwiftPath] , . when( platforms: . nonDarwinPlatforms) ) ,
170+ . define( " NDEBUG " , . when( configuration: . release) ) ,
171+ ]
172+
170173var sharedSwiftSettings : [ SwiftSetting ] = [
171174 . enableUpcomingFeature( " InternalImportsByDefault " ) ,
172175 . enableExperimentalFeature( " Extern " ) ,
@@ -175,48 +178,21 @@ var sharedSwiftSettings: [SwiftSetting] = [
175178 . define( " OPENATTRIBUTEGRAPH_RELEASE_ \( releaseVersion) " ) ,
176179]
177180
178- // Modified from: https://github.com/swiftlang/swift/blob/main/SwiftCompilerSources/Package.swift
179- //
180- // Create a couple of symlinks to an existing Ninja build:
181- //
182- // ```shell
183- // cd $OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_PATH
184- // mkdir -p build/Default
185- // ln -s build/<Ninja-Build>/llvm-<os+arch> build/Default/llvm
186- // ln -s build/<Ninja-Build>/swift-<os+arch> build/Default/swift
187- // ```
188- //
189- // where <$OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_PATH> is the parent directory of the swift repository.
190-
191- if !swiftToolchainPath. isEmpty {
192- sharedCSettings. append (
193- . unsafeFlags(
194- [
195- " -static " ,
196- " -DCOMPILED_WITH_SWIFT " ,
197- " -DPURE_BRIDGING_MODE " ,
198- " -UIBOutlet " , " -UIBAction " , " -UIBInspectable " ,
199- " -I \( swiftToolchainPath) /swift/include " ,
200- " -I \( swiftToolchainPath) /swift/stdlib/public/SwiftShims " ,
201- " -I \( swiftToolchainPath) /llvm-project/llvm/include " ,
202- " -I \( swiftToolchainPath) /llvm-project/clang/include " ,
203- " -I \( swiftToolchainPath) /build/Default/swift/include " ,
204- " -I \( swiftToolchainPath) /build/Default/llvm/include " ,
205- " -I \( swiftToolchainPath) /build/Default/llvm/tools/clang/include " ,
206- " -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING " , // Required to fix LLVM link issue
207- ]
208- )
209- )
210- }
211- if !swiftToolchainVersion. isEmpty {
212- sharedCSettings. append (
213- . define( " OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_VERSION " , to: swiftToolchainVersion)
214- )
215- }
216- if swiftToolchainSupported {
217- sharedCSettings. append ( . define( " OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED " ) )
218- sharedSwiftSettings. append ( . define( " OPENATTRIBUTEGRAPH_SWIFT_TOOLCHAIN_SUPPORTED " ) )
219- }
181+ sharedCSettings. append (
182+ . unsafeFlags( [
183+ " -isystem " , " \( swiftCheckoutPath) /include " ,
184+ " -isystem " , " \( swiftCheckoutPath) /stdlib/include " ,
185+ " -isystem " , " \( swiftCheckoutPath) /stdlib/public/SwiftShims " ,
186+ ] )
187+ )
188+ sharedCXXSettings. append (
189+ . unsafeFlags( [
190+ " -isystem " , " \( swiftCheckoutPath) /include " ,
191+ " -isystem " , " \( swiftCheckoutPath) /stdlib/include " ,
192+ " -isystem " , " \( swiftCheckoutPath) /stdlib/public/SwiftShims " ,
193+ ] )
194+ )
195+
220196if releaseVersion >= 2021 {
221197 for year in 2021 ... releaseVersion {
222198 sharedSwiftSettings. append ( . define( " OPENATTRIBUTEGRAPH_SUPPORT_ \( year) _API " ) )
@@ -232,6 +208,7 @@ if libraryEvolutionCondition {
232208}
233209if !compatibilityTestCondition {
234210 sharedCSettings. append ( . define( " OPENATTRIBUTEGRAPH " ) )
211+ sharedCXXSettings. append ( . define( " OPENATTRIBUTEGRAPH " ) )
235212 sharedSwiftSettings. append ( . define( " OPENATTRIBUTEGRAPH " ) )
236213}
237214
@@ -256,10 +233,16 @@ extension [Platform] {
256233
257234// MARK: - Targets
258235
236+ let swiftClonePlugin = Target . plugin (
237+ name: " CloneSwiftPlugin " ,
238+ capability: . buildTool( )
239+ )
240+
259241let openAttributeGraphTarget = Target . target (
260242 name: " OpenAttributeGraph " ,
261243 dependencies: [ " OpenAttributeGraphCxx " ] ,
262244 cSettings: sharedCSettings,
245+ cxxSettings: sharedCXXSettings,
263246 swiftSettings: sharedSwiftSettings
264247)
265248// FIXME: Merge into one target
@@ -270,13 +253,16 @@ let openAttributeGraphSPITarget = Target.target(
270253 cSettings: sharedCSettings + [
271254 . define( " __COREFOUNDATION_FORSWIFTFOUNDATIONONLY__ " , to: " 1 " , . when( platforms: . nonDarwinPlatforms) ) ,
272255 ] ,
256+ cxxSettings: sharedCXXSettings,
273257 linkerSettings: [
274258 . linkedLibrary( " z " ) ,
275- ]
259+ ] ,
260+ plugins: [ . plugin( name: swiftClonePlugin. name) ]
276261)
277262let openAttributeGraphShimsTarget = Target . target (
278263 name: " OpenAttributeGraphShims " ,
279264 cSettings: sharedCSettings,
265+ cxxSettings: sharedCXXSettings,
280266 swiftSettings: sharedSwiftSettings
281267)
282268
@@ -289,6 +275,7 @@ let openAttributeGraphTestsTarget = Target.testTarget(
289275 ] ,
290276 exclude: [ " README.md " ] ,
291277 cSettings: sharedCSettings,
278+ cxxSettings: sharedCXXSettings,
292279 swiftSettings: sharedSwiftSettings
293280)
294281let openAttributeGraphCxxTestsTarget = Target . testTarget (
@@ -298,6 +285,7 @@ let openAttributeGraphCxxTestsTarget = Target.testTarget(
298285 ] ,
299286 exclude: [ " README.md " ] ,
300287 cSettings: sharedCSettings + [ . define( " SWIFT_TESTING " ) ] ,
288+ cxxSettings: sharedCXXSettings,
301289 swiftSettings: sharedSwiftSettings + [ . interoperabilityMode( . Cxx) ]
302290)
303291let openAttributeGraphShimsTestsTarget = Target . testTarget (
@@ -307,6 +295,7 @@ let openAttributeGraphShimsTestsTarget = Target.testTarget(
307295 ] ,
308296 exclude: [ " README.md " ] ,
309297 cSettings: sharedCSettings,
298+ cxxSettings: sharedCXXSettings,
310299 swiftSettings: sharedSwiftSettings
311300)
312301let openAttributeGraphCompatibilityTestsTarget = Target . testTarget (
@@ -316,6 +305,7 @@ let openAttributeGraphCompatibilityTestsTarget = Target.testTarget(
316305 ] + ( compatibilityTestCondition ? [ ] : [ " OpenAttributeGraph " ] ) ,
317306 exclude: [ " README.md " ] ,
318307 cSettings: sharedCSettings,
308+ cxxSettings: sharedCXXSettings,
319309 swiftSettings: sharedSwiftSettings
320310)
321311
@@ -331,6 +321,7 @@ let package = Package(
331321 . package ( url: " https://github.com/apple/swift-numerics " , from: " 1.0.2 " ) ,
332322 ] ,
333323 targets: [
324+ swiftClonePlugin,
334325 openAttributeGraphTarget,
335326 openAttributeGraphSPITarget,
336327 openAttributeGraphShimsTarget,
0 commit comments