Skip to content

Commit 3eaa563

Browse files
committed
Split: FoundationXML
Split the portions of Foundation that depend on libxml2 into their own module, FoundationXML. This is the last module to be split off.
1 parent 6a1ca96 commit 3eaa563

21 files changed

+1250
-484
lines changed

CMakeLists.txt

+62-7
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,13 @@ endif()
116116
# `target_link_libraries(Foundation PRIVATE CoreFoundation)`.
117117
set(CoreFoundation_LIBRARIES $<TARGET_FILE:CoreFoundation>)
118118
set(CFURLSessionInterface_LIBRARIES $<TARGET_FILE:CFURLSessionInterface>)
119+
set(CFXMLInterface_LIBRARIES $<TARGET_FILE:CFXMLInterface>)
119120
get_target_property(CoreFoundation_LINK_LIBRARIES CoreFoundation LINK_LIBRARIES)
120121
foreach(library ${CoreFoundation_LINK_LIBRARIES})
121122
if(NOT library STREQUAL Threads::Threads)
122123
list(APPEND CoreFoundation_LIBRARIES -l${library})
123124
list(APPEND CFURLSessionInterface_LIBRARIES -l${library})
125+
list(APPEND CFXMLInterface_LIBRARIES -l${library})
124126
endif()
125127
endforeach()
126128

@@ -264,18 +266,11 @@ add_swift_library(Foundation
264266
Foundation/URLComponents.swift
265267
Foundation/UserDefaults.swift
266268
Foundation/UUID.swift
267-
Foundation/XMLDocument.swift
268-
Foundation/XMLDTD.swift
269-
Foundation/XMLDTDNode.swift
270-
Foundation/XMLElement.swift
271-
Foundation/XMLNode.swift
272-
Foundation/XMLParser.swift
273269
TARGET
274270
${CMAKE_C_COMPILER_TARGET}
275271
LINK_FLAGS
276272
${CoreFoundation_LIBRARIES}
277273
${ICU_UC_LIBRARY} ${ICU_I18N_LIBRARY}
278-
${LIBXML2_LIBRARIES}
279274
${libdispatch_ldflags}
280275
$<TARGET_FILE:uuid>
281276
${Foundation_RPATH}
@@ -363,6 +358,48 @@ add_swift_library(FoundationNetworking
363358
$<$<PLATFORM_ID:Windows>:CoreFoundationResources>
364359
Foundation)
365360

361+
add_swift_library(FoundationXML
362+
MODULE_NAME
363+
FoundationXML
364+
MODULE_LINK_NAME
365+
FoundationXML
366+
MODULE_PATH
367+
${CMAKE_CURRENT_BINARY_DIR}/swift/FoundationXML.swiftmodule
368+
SOURCES
369+
Foundation/XMLDocument.swift
370+
Foundation/XMLDTD.swift
371+
Foundation/XMLDTDNode.swift
372+
Foundation/XMLElement.swift
373+
Foundation/XMLNode.swift
374+
Foundation/XMLParser.swift
375+
TARGET
376+
${CMAKE_C_COMPILER_TARGET}
377+
LINK_FLAGS
378+
${MSVCRT_LINK_FLAGS}
379+
-L${CMAKE_CURRENT_BINARY_DIR}
380+
${libdispatch_ldflags}
381+
-lFoundation
382+
${Foundation_INTERFACE_LIBRARIES}
383+
${CFXMLInterface_LIBRARIES}
384+
${LIBXML2_LIBRARIES}
385+
${Foundation_RPATH}
386+
${WORKAROUND_SR9138}
387+
${WORKAROUND_SR9995}
388+
SWIFT_FLAGS
389+
-DDEPLOYMENT_RUNTIME_SWIFT
390+
-DNS_BUILDING_FOUNDATION_NETWORKING
391+
-Xcc -F${CMAKE_CURRENT_BINARY_DIR}
392+
${deployment_enable_libdispatch}
393+
-I;${CMAKE_CURRENT_BINARY_DIR}/swift
394+
${libdispatch_cflags}
395+
$<$<BOOL:ENABLE_TESTING>:-enable-testing>
396+
$<$<NOT:$<CONFIG:Debug>>:-O>
397+
DEPENDS
398+
uuid
399+
CoreFoundation
400+
$<$<PLATFORM_ID:Windows>:CoreFoundationResources>
401+
Foundation)
402+
366403

367404

368405
if(NOT BUILD_SHARED_LIBS)
@@ -423,6 +460,7 @@ if(ENABLE_TESTING)
423460
uuid
424461
Foundation
425462
FoundationNetworking
463+
FoundationXML
426464
CoreFoundation)
427465

428466
add_swift_executable(TestFoundation
@@ -572,6 +610,7 @@ if(ENABLE_TESTING)
572610
DEPENDS
573611
Foundation
574612
FoundationNetworking
613+
FoundationXML
575614
CoreFoundation
576615
xdgTestHelper)
577616

@@ -622,6 +661,8 @@ install(FILES
622661
${CMAKE_CURRENT_BINARY_DIR}/swift/Foundation.swiftmodule
623662
${CMAKE_CURRENT_BINARY_DIR}/swift/FoundationNetworking.swiftdoc
624663
${CMAKE_CURRENT_BINARY_DIR}/swift/FoundationNetworking.swiftmodule
664+
${CMAKE_CURRENT_BINARY_DIR}/swift/FoundationXML.swiftdoc
665+
${CMAKE_CURRENT_BINARY_DIR}/swift/FoundationXML.swiftmodule
625666
DESTINATION
626667
lib/${swift_dir}/${swift_os}/${swift_arch})
627668

@@ -630,22 +671,27 @@ set(Foundation_OUTPUT_FILE
630671
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_${library_kind}_LIBRARY_PREFIX}Foundation${CMAKE_${library_kind}_LIBRARY_SUFFIX})
631672
set(FoundationNetworking_OUTPUT_FILE
632673
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_${library_kind}_LIBRARY_PREFIX}FoundationNetworking${CMAKE_${library_kind}_LIBRARY_SUFFIX})
674+
set(FoundationXML_OUTPUT_FILE
675+
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_${library_kind}_LIBRARY_PREFIX}FoundationXML${CMAKE_${library_kind}_LIBRARY_SUFFIX})
633676

634677
if(CMAKE_SYSTEM_NAME STREQUAL Windows AND BUILD_SHARED_LIBS)
635678
install(FILES
636679
${Foundation_OUTPUT_FILE}
637680
${FoundationNetworking_OUTPUT_FILE}
681+
${FoundationXML_OUTPUT_FILE}
638682
DESTINATION
639683
bin)
640684
install(FILES
641685
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}Foundation${CMAKE_IMPORT_LIBRARY_SUFFIX}
642686
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}FoundationNetworking${CMAKE_IMPORT_LIBRARY_SUFFIX}
687+
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}FoundationXML${CMAKE_IMPORT_LIBRARY_SUFFIX}
643688
DESTINATION
644689
lib/${swift_dir}/${swift_os})
645690
else()
646691
install(FILES
647692
${Foundation_OUTPUT_FILE}
648693
${FoundationNetworking_OUTPUT_FILE}
694+
${FoundationXML_OUTPUT_FILE}
649695
DESTINATION
650696
lib/${swift_dir}/${swift_os})
651697
endif()
@@ -669,6 +715,15 @@ install(FILES
669715
CoreFoundation/URL.subproj/module.map
670716
DESTINATION
671717
lib/swift/CFURLSessionInterface)
718+
install(DIRECTORY
719+
${CMAKE_CURRENT_BINARY_DIR}/CFXMLInterface.framework/Headers/
720+
DESTINATION
721+
lib/swift/CFXMLInterface
722+
FILES_MATCHING PATTERN "*.h")
723+
install(FILES
724+
CoreFoundation/Parser.subproj/module.map
725+
DESTINATION
726+
lib/swift/CFXMLInterface)
672727
install(PROGRAMS
673728
${CMAKE_CURRENT_BINARY_DIR}/plutil${CMAKE_EXECUTABLE_SUFFIX}
674729
DESTINATION

CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h

-64
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <CoreFoundation/CFLocaleInternal.h>
2222
#include <CoreFoundation/CFCalendar.h>
2323
#include <CoreFoundation/CFPriv.h>
24-
#include <CoreFoundation/CFXMLInterface.h>
2524
#include <CoreFoundation/CFRegularExpression.h>
2625
#include <CoreFoundation/CFLogUtilities.h>
2726
#include <CoreFoundation/CFDateIntervalFormatter.h>
@@ -187,68 +186,6 @@ struct _NSMutableStringBridge {
187186
void (*_cfAppendCString)(CFTypeRef str, const char *chars, CFIndex appendLength);
188187
};
189188

190-
struct _NSXMLParserBridge {
191-
_CFXMLInterface _Nullable (*_Nonnull currentParser)(void);
192-
_CFXMLInterfaceParserInput _Nullable (*_Nonnull _xmlExternalEntityWithURL)(_CFXMLInterface /*interface*/, const char * /*url*/, const char * /*identifier*/, _CFXMLInterfaceParserContext /*context*/, _CFXMLInterfaceExternalEntityLoader /*originalLoaderFunction*/);
193-
194-
_CFXMLInterfaceParserContext _Nonnull (*_Nonnull getContext)(_CFXMLInterface ctx);
195-
196-
void (*internalSubset)(_CFXMLInterface ctx, const unsigned char *name, const unsigned char *ExternalID, const unsigned char *SystemID);
197-
int (*isStandalone)(_CFXMLInterface ctx);
198-
int (*hasInternalSubset)(_CFXMLInterface ctx);
199-
int (*hasExternalSubset)(_CFXMLInterface ctx);
200-
_CFXMLInterfaceEntity _Nullable (*_Nonnull getEntity)(_CFXMLInterface ctx, const unsigned char *name);
201-
void (*notationDecl)(_CFXMLInterface ctx,
202-
const unsigned char *name,
203-
const unsigned char *publicId,
204-
const unsigned char *systemId);
205-
void (*attributeDecl)(_CFXMLInterface ctx,
206-
const unsigned char *elem,
207-
const unsigned char *fullname,
208-
int type,
209-
int def,
210-
const unsigned char *defaultValue,
211-
_CFXMLInterfaceEnumeration tree);
212-
void (*elementDecl)(_CFXMLInterface ctx,
213-
const unsigned char *name,
214-
int type,
215-
_CFXMLInterfaceElementContent content);
216-
void (*unparsedEntityDecl)(_CFXMLInterface ctx,
217-
const unsigned char *name,
218-
const unsigned char *publicId,
219-
const unsigned char *systemId,
220-
const unsigned char *notationName);
221-
void (*startDocument)(_CFXMLInterface ctx);
222-
void (*endDocument)(_CFXMLInterface ctx);
223-
void (*startElementNs)(_CFXMLInterface ctx,
224-
const unsigned char *localname,
225-
const unsigned char *_Nullable prefix,
226-
const unsigned char *_Nullable URI,
227-
int nb_namespaces,
228-
const unsigned char *_Nullable *_Nonnull namespaces,
229-
int nb_attributes,
230-
int nb_defaulted,
231-
const unsigned char *_Nullable *_Nonnull attributes);
232-
void (*endElementNs)(_CFXMLInterface ctx,
233-
const unsigned char *localname,
234-
const unsigned char *_Nullable prefix,
235-
const unsigned char *_Nullable URI);
236-
void (*characters)(_CFXMLInterface ctx,
237-
const unsigned char *ch,
238-
int len);
239-
void (*processingInstruction)(_CFXMLInterface ctx,
240-
const unsigned char *target,
241-
const unsigned char *data);
242-
void (*cdataBlock)(_CFXMLInterface ctx,
243-
const unsigned char *value,
244-
int len);
245-
void (*comment)(_CFXMLInterface ctx, const unsigned char *value);
246-
void (*externalSubset)(_CFXMLInterface ctx,
247-
const unsigned char *name,
248-
const unsigned char *ExternalID,
249-
const unsigned char *SystemID);
250-
};
251-
252189
struct _NSRunLoop {
253190
_Nonnull CFTypeRef (*_Nonnull _new)(CFRunLoopRef rl);
254191
};
@@ -327,7 +264,6 @@ struct _CFSwiftBridge {
327264
struct _NSMutableSetBridge NSMutableSet;
328265
struct _NSStringBridge NSString;
329266
struct _NSMutableStringBridge NSMutableString;
330-
struct _NSXMLParserBridge NSXMLParser;
331267
struct _NSRunLoop NSRunLoop;
332268
struct _NSCharacterSetBridge NSCharacterSet;
333269
struct _NSMutableCharacterSetBridge NSMutableCharacterSet;

0 commit comments

Comments
 (0)