3
3
4
4
import PackageDescription
5
5
6
+ let platformsWithThreads : [ Platform ] = [
7
+ . iOS,
8
+ . macOS,
9
+ . tvOS,
10
+ . watchOS,
11
+ . macCatalyst,
12
+ . driverKit,
13
+ . android,
14
+ . linux,
15
+ . windows,
16
+ ]
17
+
6
18
var dispatchIncludeFlags : [ CSetting ]
7
19
if let environmentPath = Context . environment [ " DISPATCH_INCLUDE_PATH " ] {
8
20
dispatchIncludeFlags = [ . unsafeFlags( [
@@ -28,11 +40,12 @@ let coreFoundationBuildSettings: [CSetting] = [
28
40
. headerSearchPath( " internalInclude " ) ,
29
41
. define( " DEBUG " , . when( configuration: . debug) ) ,
30
42
. define( " CF_BUILDING_CF " ) ,
31
- . define( " DEPLOYMENT_ENABLE_LIBDISPATCH " ) ,
43
+ . define( " DEPLOYMENT_ENABLE_LIBDISPATCH " , . when ( platforms : platformsWithThreads ) ) ,
32
44
. define( " DEPLOYMENT_RUNTIME_SWIFT " ) ,
33
45
. define( " HAVE_STRUCT_TIMESPEC " ) ,
34
- . define( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " ) ,
46
+ . define( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " , . when ( platforms : platformsWithThreads ) ) ,
35
47
. define( " _GNU_SOURCE " , . when( platforms: [ . linux, . android] ) ) ,
48
+ . define( " _WASI_EMULATED_SIGNAL " , . when( platforms: [ . wasi] ) ) ,
36
49
. unsafeFlags( [
37
50
" -Wno-shorten-64-to-32 " ,
38
51
" -Wno-deprecated-declarations " ,
@@ -61,8 +74,9 @@ let interfaceBuildSettings: [CSetting] = [
61
74
. define( " CF_BUILDING_CF " ) ,
62
75
. define( " DEPLOYMENT_ENABLE_LIBDISPATCH " ) ,
63
76
. define( " HAVE_STRUCT_TIMESPEC " ) ,
64
- . define( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " ) ,
77
+ . define( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " , . when ( platforms : platformsWithThreads ) ) ,
65
78
. define( " _GNU_SOURCE " , . when( platforms: [ . linux, . android] ) ) ,
79
+ . define( " _WASI_EMULATED_SIGNAL " , . when( platforms: [ . wasi] ) ) ,
66
80
. unsafeFlags( [
67
81
" -Wno-shorten-64-to-32 " ,
68
82
" -Wno-deprecated-declarations " ,
@@ -144,7 +158,8 @@ let package = Package(
144
158
. product( name: " FoundationEssentials " , package : " swift-foundation " ) ,
145
159
" Foundation " ,
146
160
" CoreFoundation " ,
147
- " _CFXMLInterface "
161
+ " _CFXMLInterface " ,
162
+ . target( name: " BlocksRuntime " , condition: . when( platforms: [ . wasi] ) ) ,
148
163
] ,
149
164
path: " Sources/FoundationXML " ,
150
165
exclude: [
@@ -170,6 +185,7 @@ let package = Package(
170
185
name: " CoreFoundation " ,
171
186
dependencies: [
172
187
. product( name: " _FoundationICU " , package : " swift-foundation-icu " ) ,
188
+ . target( name: " BlocksRuntime " , condition: . when( platforms: [ . wasi] ) ) ,
173
189
] ,
174
190
path: " Sources/CoreFoundation " ,
175
191
exclude: [
@@ -178,6 +194,17 @@ let package = Package(
178
194
] ,
179
195
cSettings: coreFoundationBuildSettings
180
196
) ,
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
+ ) ,
181
208
. target(
182
209
name: " _CFXMLInterface " ,
183
210
dependencies: [
0 commit comments