33
44import PackageDescription
55
6+ let platformsWithThreads : [ Platform ] = [
7+ . iOS,
8+ . macOS,
9+ . tvOS,
10+ . watchOS,
11+ . macCatalyst,
12+ . driverKit,
13+ . android,
14+ . linux,
15+ . windows,
16+ ]
17+
618var dispatchIncludeFlags : [ CSetting ]
719if let environmentPath = Context . environment [ " DISPATCH_INCLUDE_PATH " ] {
820 dispatchIncludeFlags = [ . unsafeFlags( [
@@ -28,11 +40,12 @@ let coreFoundationBuildSettings: [CSetting] = [
2840 . headerSearchPath( " internalInclude " ) ,
2941 . define( " DEBUG " , . when( configuration: . debug) ) ,
3042 . define( " CF_BUILDING_CF " ) ,
31- . define( " DEPLOYMENT_ENABLE_LIBDISPATCH " ) ,
43+ . define( " DEPLOYMENT_ENABLE_LIBDISPATCH " , . when ( platforms : platformsWithThreads ) ) ,
3244 . define( " DEPLOYMENT_RUNTIME_SWIFT " ) ,
3345 . define( " HAVE_STRUCT_TIMESPEC " ) ,
34- . define( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " ) ,
46+ . define( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " , . when ( platforms : platformsWithThreads ) ) ,
3547 . define( " _GNU_SOURCE " , . when( platforms: [ . linux, . android] ) ) ,
48+ . define( " _WASI_EMULATED_SIGNAL " , . when( platforms: [ . wasi] ) ) ,
3649 . unsafeFlags( [
3750 " -Wno-shorten-64-to-32 " ,
3851 " -Wno-deprecated-declarations " ,
@@ -61,8 +74,9 @@ let interfaceBuildSettings: [CSetting] = [
6174 . define( " CF_BUILDING_CF " ) ,
6275 . define( " DEPLOYMENT_ENABLE_LIBDISPATCH " ) ,
6376 . define( " HAVE_STRUCT_TIMESPEC " ) ,
64- . define( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " ) ,
77+ . define( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " , . when ( platforms : platformsWithThreads ) ) ,
6578 . define( " _GNU_SOURCE " , . when( platforms: [ . linux, . android] ) ) ,
79+ . define( " _WASI_EMULATED_SIGNAL " , . when( platforms: [ . wasi] ) ) ,
6680 . unsafeFlags( [
6781 " -Wno-shorten-64-to-32 " ,
6882 " -Wno-deprecated-declarations " ,
@@ -144,7 +158,8 @@ let package = Package(
144158 . product( name: " FoundationEssentials " , package : " swift-foundation " ) ,
145159 " Foundation " ,
146160 " CoreFoundation " ,
147- " _CFXMLInterface "
161+ " _CFXMLInterface " ,
162+ . target( name: " BlocksRuntime " , condition: . when( platforms: [ . wasi] ) ) ,
148163 ] ,
149164 path: " Sources/FoundationXML " ,
150165 exclude: [
@@ -170,6 +185,7 @@ let package = Package(
170185 name: " CoreFoundation " ,
171186 dependencies: [
172187 . product( name: " _FoundationICU " , package : " swift-foundation-icu " ) ,
188+ . target( name: " BlocksRuntime " , condition: . when( platforms: [ . wasi] ) ) ,
173189 ] ,
174190 path: " Sources/CoreFoundation " ,
175191 exclude: [
@@ -178,6 +194,17 @@ let package = Package(
178194 ] ,
179195 cSettings: coreFoundationBuildSettings
180196 ) ,
197+ . target(
198+ name: " BlocksRuntime " ,
199+ path: " Sources/CoreFoundation/BlockRuntime " ,
200+ exclude: [
201+ " CMakeLists.txt "
202+ ] ,
203+ cSettings: [
204+ // For CFTargetConditionals.h
205+ . headerSearchPath( " ../include " ) ,
206+ ]
207+ ) ,
181208 . target(
182209 name: " _CFXMLInterface " ,
183210 dependencies: [
0 commit comments