|
| 1 | +# This source file is part of the Swift.org open source project |
| 2 | +# |
| 3 | +# Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors |
| 4 | +# Licensed under Apache License v2.0 with Runtime Library Exception |
| 5 | +# |
| 6 | +# See http://swift.org/LICENSE.txt for license information |
| 7 | +# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 8 | +# |
| 9 | + |
1 | 10 | script = Script() |
2 | 11 |
|
3 | | -cf = StaticLibrary("CoreFoundation") |
| 12 | +cf = DynamicLibrary("CoreFoundation", uses_swift_runtime_object=False) |
4 | 13 |
|
5 | 14 | cf.GCC_PREFIX_HEADER = 'Base.subproj/CoreFoundation_Prefix.h' |
6 | 15 |
|
7 | 16 | if Configuration.current.target.sdk == OSType.Linux: |
8 | | - cf.CFLAGS = '-DDEPLOYMENT_TARGET_LINUX -D_GNU_SOURCE ' |
| 17 | + cf.CFLAGS = '-DDEPLOYMENT_TARGET_LINUX -D_GNU_SOURCE -DCF_CHARACTERSET_DATA_DIR="CharacterSets" ' |
| 18 | + cf.LDFLAGS = '-Wl,@./linux.ld -Wl,-Bsymbolic ' |
9 | 19 | Configuration.current.requires_pkg_config = True |
10 | 20 | elif Configuration.current.target.sdk == OSType.FreeBSD: |
11 | | - cf.CFLAGS = '-DDEPLOYMENT_TARGET_FREEBSD -I/usr/local/include -I/usr/local/include/libxml2 ' |
| 21 | + cf.CFLAGS = '-DDEPLOYMENT_TARGET_FREEBSD -I/usr/local/include -I/usr/local/include/libxml2 -I/usr/local/include/curl ' |
| 22 | + cf.LDFLAGS = '' |
12 | 23 | elif Configuration.current.target.sdk == OSType.MacOSX: |
13 | 24 | cf.CFLAGS = '-DDEPLOYMENT_TARGET_MACOSX ' |
| 25 | + cf.LDFLAGS = '-licucore -twolevel_namespace -Wl,-alias_list,Base.subproj/DarwinSymbolAliases -sectcreate __UNICODE __csbitmaps CharacterSets/CFCharacterSetBitmaps.bitmap -sectcreate __UNICODE __properties CharacterSets/CFUniCharPropertyDatabase.data -sectcreate __UNICODE __data CharacterSets/CFUnicodeData-L.mapping -segprot __UNICODE r r ' |
| 26 | +elif Configuration.current.target.sdk == OSType.Win32 and Configuration.current.target.environ == EnvironmentType.Cygnus: |
| 27 | + cf.CFLAGS = '-DDEPLOYMENT_TARGET_LINUX -D_GNU_SOURCE -mcmodel=large ' |
| 28 | + cf.LDFLAGS = '${SWIFT_USE_LINKER} -lswiftGlibc `icu-config --ldflags` -Wl,--allow-multiple-definition ' |
14 | 29 |
|
15 | 30 | cf.ASFLAGS = " ".join([ |
16 | | - '-DCF_CHARACTERSET_BITMAP=\\"CharacterSets/CFCharacterSetBitmaps.bitmap\\"', |
| 31 | + '-DCF_CHARACTERSET_BITMAP=\\"CharacterSets/CFCharacterSetBitmaps.bitmap\\"', |
17 | 32 | '-DCF_CHARACTERSET_UNICHAR_DB=\\"CharacterSets/CFUniCharPropertyDatabase.data\\"', |
18 | 33 | '-DCF_CHARACTERSET_UNICODE_DATA_B=\\"CharacterSets/CFUnicodeData-B.mapping\\"', |
19 | 34 | '-DCF_CHARACTERSET_UNICODE_DATA_L=\\"CharacterSets/CFUnicodeData-L.mapping\\"', |
20 | 35 | ]) |
21 | 36 |
|
22 | | -cf.ROOT_HEADERS_FOLDER_PATH = "${PREFIX}/lib/swift" |
23 | | -cf.PUBLIC_HEADERS_FOLDER_PATH = "${PREFIX}/lib/swift/CoreFoundation" |
24 | | -cf.PRIVATE_HEADERS_FOLDER_PATH = "${PREFIX}/lib/swift/CoreFoundation" |
25 | | -cf.PROJECT_HEADERS_FOLDER_PATH = "${PREFIX}/lib/swift/CoreFoundation" |
26 | | -cf.PUBLIC_MODULE_FOLDER_PATH = "${PREFIX}/lib/swift/CoreFoundation" |
| 37 | +cf.CFLAGS += " ".join([ |
| 38 | + '-I${DSTROOT}${PREFIX}/include', |
| 39 | + '-I${DSTROOT}${PREFIX}/local/include', |
| 40 | +]) + " " |
| 41 | +cf.LDFLAGS += " ".join([ |
| 42 | + '-L${DSTROOT}${PREFIX}/lib', |
| 43 | + '-L${DSTROOT}${PREFIX}/local/lib', |
| 44 | +]) + " " |
| 45 | + |
| 46 | +# For now, we do not distinguish between public and private headers (they are all private to Foundation) |
| 47 | +# These are really part of CF, which should ultimately be a separate target |
| 48 | +cf.ROOT_HEADERS_FOLDER_PATH = "${PREFIX}/include" |
| 49 | +cf.PUBLIC_HEADERS_FOLDER_PATH = "${PREFIX}/include/CoreFoundation" |
| 50 | +cf.PRIVATE_HEADERS_FOLDER_PATH = "${PREFIX}/include/CoreFoundation" |
| 51 | +cf.PROJECT_HEADERS_FOLDER_PATH = "${PREFIX}/include/CoreFoundation" |
| 52 | + |
| 53 | +cf.PUBLIC_MODULE_FOLDER_PATH = "${PREFIX}/include/CoreFoundation" |
27 | 54 |
|
28 | 55 | cf.CFLAGS += " ".join([ |
29 | | - '-DU_SHOW_DRAFT_API', |
30 | | - '-DCF_BUILDING_CF', |
31 | | - '-DDEPLOYMENT_RUNTIME_SWIFT', |
| 56 | + '-DU_SHOW_DRAFT_API=1', |
| 57 | + '-DCF_BUILDING_CF=1', |
| 58 | + '-DDEPLOYMENT_RUNTIME_C=1', |
32 | 59 | '-fconstant-cfstrings', |
33 | 60 | '-fexceptions', |
34 | 61 | '-Wno-shorten-64-to-32', |
|
38 | 65 | '-Wno-unused-variable', |
39 | 66 | '-Wno-int-conversion', |
40 | 67 | '-Wno-unused-function', |
41 | | - '-I${SYSROOT}/usr/include/libxml2', |
42 | 68 | '-I./', |
43 | 69 | ]) |
44 | 70 |
|
| 71 | +if Configuration.current.requires_pkg_config: |
| 72 | + pkg_config_dependencies = [ |
| 73 | + 'libcurl', |
| 74 | + 'libxml-2.0', |
| 75 | + ] |
| 76 | + for package_name in pkg_config_dependencies: |
| 77 | + try: |
| 78 | + package = PkgConfig(package_name) |
| 79 | + except PkgConfig.Error as e: |
| 80 | + sys.exit("pkg-config error for package {}: {}".format(package_name, e)) |
| 81 | + cf.CFLAGS += ' {} '.format(' '.join(package.cflags)) |
| 82 | + cf.LDFLAGS += ' {} '.format(' '.join(package.ldflags)) |
| 83 | +else: |
| 84 | + cf.CFLAGS += ''.join([ |
| 85 | + '-I${SYSROOT}/usr/include/curl ', |
| 86 | + '-I${SYSROOT}/usr/include/libxml2 ', |
| 87 | + ]) |
| 88 | + cf.LDFLAGS += ''.join([ |
| 89 | + '-lcurl ', |
| 90 | + '-lxml2 ', |
| 91 | + ]) |
| 92 | + |
| 93 | +triple = Configuration.current.target.triple |
| 94 | +if triple == "armv7-none-linux-androideabi": |
| 95 | + cf.LDFLAGS += '-llog ' |
| 96 | +else: |
| 97 | + cf.LDFLAGS += '-lpthread ' |
| 98 | + |
| 99 | +cf.LDFLAGS += '-ldl -lm ' |
| 100 | + |
| 101 | +# Configure use of Dispatch in CoreFoundation and Foundation if libdispatch is being built |
| 102 | +cf.CFLAGS += '-DDEPLOYMENT_ENABLE_LIBDISPATCH=1 ' |
| 103 | +cf.LDFLAGS += '-ldispatch -rpath \$$ORIGIN ' |
| 104 | + |
| 105 | +if "XCTEST_BUILD_DIR" in Configuration.current.variables: |
| 106 | + cf.LDFLAGS += '-L${XCTEST_BUILD_DIR}' |
| 107 | + |
45 | 108 | headers = CopyHeaders( |
46 | 109 | module = 'Base.subproj/module.modulemap', |
47 | 110 | public = [ |
|
76 | 139 | 'Collections.subproj/CFArray.h', |
77 | 140 | 'RunLoop.subproj/CFRunLoop.h', |
78 | 141 | 'URL.subproj/CFURLAccess.h', |
| 142 | + 'URL.subproj/CFURLSessionInterface.h', |
79 | 143 | 'Locale.subproj/CFDateFormatter.h', |
80 | 144 | 'RunLoop.subproj/CFMachPort.h', |
81 | 145 | 'PlugIn.subproj/CFPlugInCOM.h', |
|
88 | 152 | 'NumberDate.subproj/CFNumber.h', |
89 | 153 | 'Collections.subproj/CFData.h', |
90 | 154 | 'String.subproj/CFAttributedString.h', |
91 | | - 'AppServices.subproj/CFNotificationCenter.h', |
| 155 | + 'Base.subproj/CoreFoundation_Prefix.h', |
| 156 | + 'AppServices.subproj/CFNotificationCenter.h' |
92 | 157 | ], |
93 | 158 | private = [ |
94 | | - 'Base.subproj/CFAsmMacros.h', |
95 | 159 | 'Base.subproj/ForSwiftFoundationOnly.h', |
96 | 160 | 'Base.subproj/ForFoundationOnly.h', |
| 161 | + 'Base.subproj/CFAsmMacros.h', |
97 | 162 | 'String.subproj/CFBurstTrie.h', |
98 | 163 | 'Error.subproj/CFError_Private.h', |
99 | 164 | 'URL.subproj/CFURLPriv.h', |
|
130 | 195 | 'StringEncodings.subproj/CFICUConverters.h', |
131 | 196 | 'String.subproj/CFRegularExpression.h', |
132 | 197 | 'String.subproj/CFRunArray.h', |
133 | | - 'URL.subproj/CFURLSessionInterface.h', |
| 198 | + 'Locale.subproj/CFDateFormatter_Private.h', |
| 199 | + 'Locale.subproj/CFLocale_Private.h', |
| 200 | + 'Parsing.subproj/CFPropertyList_Private.h', |
134 | 201 | ], |
135 | 202 | project = [ |
136 | 203 | ]) |
137 | 204 |
|
138 | 205 | cf.add_phase(headers) |
139 | 206 |
|
140 | | -sources = CompileSources([ |
| 207 | +sources_list = [ |
| 208 | + '../uuid/uuid.c', |
| 209 | + # 'AppServices.subproj/CFUserNotification.c', |
141 | 210 | 'Base.subproj/CFBase.c', |
142 | 211 | 'Base.subproj/CFFileUtilities.c', |
143 | 212 | 'Base.subproj/CFPlatform.c', |
|
182 | 251 | 'PlugIn.subproj/CFBundle_Locale.c', |
183 | 252 | 'PlugIn.subproj/CFBundle_Resources.c', |
184 | 253 | 'PlugIn.subproj/CFBundle_Strings.c', |
| 254 | + 'PlugIn.subproj/CFBundle_Main.c', |
| 255 | + 'PlugIn.subproj/CFBundle_ResourceFork.c', |
| 256 | + 'PlugIn.subproj/CFBundle_Executable.c', |
| 257 | + 'PlugIn.subproj/CFBundle_DebugStrings.c', |
185 | 258 | 'PlugIn.subproj/CFPlugIn.c', |
186 | 259 | 'PlugIn.subproj/CFPlugIn_Factory.c', |
187 | 260 | 'PlugIn.subproj/CFPlugIn_Instance.c', |
188 | 261 | 'PlugIn.subproj/CFPlugIn_PlugIn.c', |
189 | 262 | 'Preferences.subproj/CFApplicationPreferences.c', |
190 | 263 | 'Preferences.subproj/CFPreferences.c', |
| 264 | + 'Preferences.subproj/CFXMLPreferencesDomain.c', |
191 | 265 | 'RunLoop.subproj/CFRunLoop.c', |
192 | 266 | 'RunLoop.subproj/CFSocket.c', |
193 | 267 | 'Stream.subproj/CFConcreteStreams.c', |
|
218 | 292 | 'String.subproj/CFRegularExpression.c', |
219 | 293 | 'String.subproj/CFAttributedString.c', |
220 | 294 | 'String.subproj/CFRunArray.c', |
221 | | -]) |
| 295 | +] |
222 | 296 |
|
| 297 | +sources = CompileSources(sources_list) |
223 | 298 | sources.add_dependency(headers) |
224 | 299 | cf.add_phase(sources) |
| 300 | + |
225 | 301 | script.add_product(cf) |
226 | | -script.generate() |
227 | 302 |
|
| 303 | +LIBS_DIRS = "" |
| 304 | +if "XCTEST_BUILD_DIR" in Configuration.current.variables: |
| 305 | + LIBS_DIRS += "${XCTEST_BUILD_DIR}:" |
| 306 | +if "PREFIX" in Configuration.current.variables: |
| 307 | + LIBS_DIRS += Configuration.current.variables["PREFIX"]+"/lib:" |
| 308 | + |
| 309 | +Configuration.current.variables["LIBS_DIRS"] = LIBS_DIRS |
| 310 | + |
| 311 | +extra_script = """ |
| 312 | +rule InstallCoreFoundation |
| 313 | + command = mkdir -p "${DSTROOT}/${PREFIX}/lib"; $ |
| 314 | + mkdir -p "${DSTROOT}/${PREFIX}/include"; $ |
| 315 | + rsync -a "${BUILD_DIR}/CoreFoundation/${PREFIX}/include/CoreFoundation" "${DSTROOT}/${PREFIX}/include/"; $ |
| 316 | + cp "${BUILD_DIR}/CoreFoundation/${DYLIB_PREFIX}CoreFoundation${DYLIB_SUFFIX}" "${DSTROOT}/${PREFIX}/lib" |
228 | 317 |
|
| 318 | +build ${BUILD_DIR}/.install: InstallCoreFoundation ${BUILD_DIR}/CoreFoundation/${DYLIB_PREFIX}CoreFoundation${DYLIB_SUFFIX} |
| 319 | +
|
| 320 | +build install: phony | ${BUILD_DIR}/.install |
| 321 | +
|
| 322 | +""" |
| 323 | + |
| 324 | +script.add_text(extra_script) |
| 325 | + |
| 326 | +script.generate() |
0 commit comments