3
3
4
4
import PackageDescription
5
5
6
- let buildSettings : [ CSetting ] = [
6
+ let coreFoundationBuildSettings : [ CSetting ] = [
7
7
. headerSearchPath( " internalInclude " ) ,
8
8
. define( " DEBUG " , . when( configuration: . debug) ) ,
9
9
. define( " CF_BUILDING_CF " ) ,
10
- . define( " DEPLOYMENT_RUNTIME_SWIFT " ) ,
11
10
. define( " DEPLOYMENT_ENABLE_LIBDISPATCH " ) ,
11
+ . define( " DEPLOYMENT_RUNTIME_SWIFT " ) ,
12
12
. define( " HAVE_STRUCT_TIMESPEC " ) ,
13
13
. define( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " ) ,
14
14
. define( " _GNU_SOURCE " , . when( platforms: [ . linux, . android] ) ) ,
15
- . define( " CF_CHARACTERSET_UNICODE_DATA_L " , to: " \" \( Context . packageDirectory) /Sources/CoreFoundation/CFUnicodeData-L.mapping \" " ) ,
16
- . define( " CF_CHARACTERSET_UNICODE_DATA_B " , to: " \" \( Context . packageDirectory) /Sources/CoreFoundation/CFUnicodeData-B.mapping \" " ) ,
17
- . define( " CF_CHARACTERSET_UNICHAR_DB " , to: " \" \( Context . packageDirectory) /Sources/CoreFoundation/CFUniCharPropertyDatabase.data \" " ) ,
18
- . define( " CF_CHARACTERSET_BITMAP " , to: " \" \( Context . packageDirectory) /Sources/CoreFoundation/CFCharacterSetBitmaps.bitmap \" " ) ,
19
15
. unsafeFlags( [
20
16
" -Wno-shorten-64-to-32 " ,
21
17
" -Wno-deprecated-declarations " ,
@@ -29,6 +25,8 @@ let buildSettings: [CSetting] = [
29
25
" -fdollars-in-identifiers " ,
30
26
" -fno-common " ,
31
27
" -fcf-runtime-abi=swift " ,
28
+ " -include " ,
29
+ " \( Context . packageDirectory) /Sources/CoreFoundation/internalInclude/CoreFoundation_Prefix.h " ,
32
30
// /EHsc for Windows
33
31
] ) ,
34
32
. unsafeFlags( [ " -I/usr/lib/swift " ] , . when( platforms: [ . linux, . android] ) ) // dispatch
@@ -40,7 +38,6 @@ let interfaceBuildSettings: [CSetting] = [
40
38
. headerSearchPath( " ../CoreFoundation/include " ) ,
41
39
. define( " DEBUG " , . when( configuration: . debug) ) ,
42
40
. define( " CF_BUILDING_CF " ) ,
43
- . define( " DEPLOYMENT_RUNTIME_SWIFT " ) ,
44
41
. define( " DEPLOYMENT_ENABLE_LIBDISPATCH " ) ,
45
42
. define( " HAVE_STRUCT_TIMESPEC " ) ,
46
43
. define( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " ) ,
@@ -63,9 +60,15 @@ let interfaceBuildSettings: [CSetting] = [
63
60
. unsafeFlags( [ " -I/usr/lib/swift " ] , . when( platforms: [ . linux, . android] ) ) // dispatch
64
61
]
65
62
63
+ let swiftBuildSettings : [ SwiftSetting ] = [
64
+ . define( " DEPLOYMENT_RUNTIME_SWIFT " ) ,
65
+ . define( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " ) ,
66
+ ]
67
+
66
68
let package = Package (
67
69
name: " swift-corelibs-foundation " ,
68
- platforms: [ . macOS( " 13.3 " ) , . iOS( " 16.4 " ) , . tvOS( " 16.4 " ) , . watchOS( " 9.4 " ) ] ,
70
+ // Deployment target note: This package only builds for non-Darwin targets.
71
+ platforms: [ . macOS( " 99.9 " ) ] ,
69
72
products: [
70
73
. library( name: " Foundation " , targets: [ " Foundation " ] ) ,
71
74
. library( name: " FoundationXML " , targets: [ " FoundationXML " ] ) ,
@@ -75,7 +78,8 @@ let package = Package(
75
78
dependencies: [
76
79
. package (
77
80
url: " https://github.com/apple/swift-foundation-icu " ,
78
- from: " 0.0.5 " ) ,
81
+ from: " 0.0.5 "
82
+ ) ,
79
83
. package (
80
84
url: " https://github.com/apple/swift-foundation " ,
81
85
revision: " e991656bd02af48530811f1871b3351961b75d29 "
@@ -90,37 +94,37 @@ let package = Package(
90
94
" _CoreFoundation "
91
95
] ,
92
96
path: " Sources/Foundation " ,
93
- swiftSettings: [ . define ( " DEPLOYMENT_RUNTIME_SWIFT " ) , . define ( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " ) ]
97
+ swiftSettings: swiftBuildSettings
94
98
) ,
95
99
. target(
96
100
name: " FoundationXML " ,
97
101
dependencies: [
98
102
. product( name: " FoundationEssentials " , package : " swift-foundation " ) ,
99
- " Foundation " ,
103
+ . targetItem ( name : " Foundation " , condition : nil ) ,
100
104
" _CoreFoundation " ,
101
105
" _CFXMLInterface "
102
106
] ,
103
107
path: " Sources/FoundationXML " ,
104
- swiftSettings: [ . define ( " DEPLOYMENT_RUNTIME_SWIFT " ) , . define ( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " ) ]
108
+ swiftSettings: swiftBuildSettings
105
109
) ,
106
110
. target(
107
111
name: " FoundationNetworking " ,
108
112
dependencies: [
109
113
. product( name: " FoundationEssentials " , package : " swift-foundation " ) ,
110
- " Foundation " ,
114
+ . targetItem ( name : " Foundation " , condition : nil ) ,
111
115
" _CoreFoundation " ,
112
116
" _CFURLSessionInterface "
113
117
] ,
114
118
path: " Sources/FoundationNetworking " ,
115
- swiftSettings: [ . define ( " DEPLOYMENT_RUNTIME_SWIFT " ) , . define ( " SWIFT_CORELIBS_FOUNDATION_HAS_THREADS " ) ]
119
+ swiftSettings: swiftBuildSettings
116
120
) ,
117
121
. target(
118
122
name: " _CoreFoundation " ,
119
123
dependencies: [
120
124
. product( name: " FoundationICU " , package : " swift-foundation-icu " ) ,
121
125
] ,
122
126
path: " Sources/CoreFoundation " ,
123
- cSettings: buildSettings
127
+ cSettings: coreFoundationBuildSettings
124
128
) ,
125
129
. target(
126
130
name: " _CFXMLInterface " ,
@@ -158,33 +162,36 @@ let package = Package(
158
162
) ,
159
163
. executableTarget(
160
164
name: " plutil " ,
161
- dependencies: [ " Foundation " ]
165
+ dependencies: [
166
+ . targetItem( name: " Foundation " , condition: nil )
167
+ ]
162
168
) ,
163
169
. executableTarget(
164
170
name: " xdgTestHelper " ,
165
171
dependencies: [
166
- " Foundation " ,
167
- " FoundationNetworking "
172
+ . targetItem( name: " Foundation " , condition: nil ) ,
173
+ . targetItem( name: " FoundationXML " , condition: nil ) ,
174
+ . targetItem( name: " FoundationNetworking " , condition: nil )
168
175
]
169
176
) ,
170
177
. target(
171
178
// swift-corelibs-foundation has a copy of XCTest's sources so:
172
179
// (1) we do not depend on the toolchain's XCTest, which depends on toolchain's Foundation, which we cannot pull in at the same time as a Foundation package
173
180
// (2) we do not depend on a swift-corelibs-xctest Swift package, which depends on Foundation, which causes a circular dependency in swiftpm
174
181
// We believe Foundation is the only project that needs to take this rather drastic measure.
175
- name: " XCTest " ,
182
+ name: " XCTest " ,
176
183
dependencies: [
177
- " Foundation "
178
- ] ,
184
+ . targetItem ( name : " Foundation " , condition : nil )
185
+ ] ,
179
186
path: " Sources/XCTest "
180
187
) ,
181
188
. testTarget(
182
189
name: " TestFoundation " ,
183
190
dependencies: [
184
- " Foundation " ,
185
- " FoundationXML " ,
186
- " FoundationNetworking " ,
187
- " XCTest " ,
191
+ . targetItem ( name : " Foundation " , condition : nil ) ,
192
+ . targetItem ( name : " FoundationXML " , condition : nil ) ,
193
+ . targetItem ( name : " FoundationNetworking " , condition : nil ) ,
194
+ . targetItem ( name : " XCTest " , condition : . when ( platforms : [ . linux ] ) ) ,
188
195
" xdgTestHelper "
189
196
] ,
190
197
resources: [
0 commit comments