Skip to content

Split: FoundationXML #2432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 62 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ endif()
# `target_link_libraries(Foundation PRIVATE CoreFoundation)`.
set(CoreFoundation_LIBRARIES $<TARGET_FILE:CoreFoundation>)
set(CFURLSessionInterface_LIBRARIES $<TARGET_FILE:CFURLSessionInterface>)
set(CFXMLInterface_LIBRARIES $<TARGET_FILE:CFXMLInterface>)
get_target_property(CoreFoundation_LINK_LIBRARIES CoreFoundation LINK_LIBRARIES)
foreach(library ${CoreFoundation_LINK_LIBRARIES})
if(NOT library STREQUAL Threads::Threads)
list(APPEND CoreFoundation_LIBRARIES -l${library})
list(APPEND CFURLSessionInterface_LIBRARIES -l${library})
list(APPEND CFXMLInterface_LIBRARIES -l${library})
endif()
endforeach()

Expand Down Expand Up @@ -264,18 +266,11 @@ add_swift_library(Foundation
Foundation/URLComponents.swift
Foundation/UserDefaults.swift
Foundation/UUID.swift
Foundation/XMLDocument.swift
Foundation/XMLDTD.swift
Foundation/XMLDTDNode.swift
Foundation/XMLElement.swift
Foundation/XMLNode.swift
Foundation/XMLParser.swift
TARGET
${CMAKE_C_COMPILER_TARGET}
LINK_FLAGS
${CoreFoundation_LIBRARIES}
${ICU_UC_LIBRARY} ${ICU_I18N_LIBRARY}
${LIBXML2_LIBRARIES}
${libdispatch_ldflags}
$<TARGET_FILE:uuid>
${Foundation_RPATH}
Expand Down Expand Up @@ -363,6 +358,48 @@ add_swift_library(FoundationNetworking
$<$<PLATFORM_ID:Windows>:CoreFoundationResources>
Foundation)

add_swift_library(FoundationXML
MODULE_NAME
FoundationXML
MODULE_LINK_NAME
FoundationXML
MODULE_PATH
${CMAKE_CURRENT_BINARY_DIR}/swift/FoundationXML.swiftmodule
SOURCES
Foundation/XMLDocument.swift
Foundation/XMLDTD.swift
Foundation/XMLDTDNode.swift
Foundation/XMLElement.swift
Foundation/XMLNode.swift
Foundation/XMLParser.swift
TARGET
${CMAKE_C_COMPILER_TARGET}
LINK_FLAGS
${MSVCRT_LINK_FLAGS}
-L${CMAKE_CURRENT_BINARY_DIR}
${libdispatch_ldflags}
-lFoundation
${Foundation_INTERFACE_LIBRARIES}
${CFXMLInterface_LIBRARIES}
${LIBXML2_LIBRARIES}
${Foundation_RPATH}
${WORKAROUND_SR9138}
${WORKAROUND_SR9995}
SWIFT_FLAGS
-DDEPLOYMENT_RUNTIME_SWIFT
-DNS_BUILDING_FOUNDATION_NETWORKING
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this one correct? Or necessary? I don't see it used anywhere else in the commit (unless it appears in some unexpanded file). If we rely on it because it was already used like this in FoundationNetworking, maybe it would be good to update it to something more “neutral”. If anyone knows the answer, I will not mind doing the PR, but I don’t exactly know what to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was, indeed, a mistake.

There is one file that is shared between the Foundation and FoundationNetworking builds containing internal calls; in Networking, we have to import Foundation, and that's what this guards. It is unnecessary in FoundationXML.

-Xcc -F${CMAKE_CURRENT_BINARY_DIR}
${deployment_enable_libdispatch}
-I;${CMAKE_CURRENT_BINARY_DIR}/swift
${libdispatch_cflags}
$<$<BOOL:ENABLE_TESTING>:-enable-testing>
$<$<NOT:$<CONFIG:Debug>>:-O>
DEPENDS
uuid
CoreFoundation
$<$<PLATFORM_ID:Windows>:CoreFoundationResources>
Foundation)



if(NOT BUILD_SHARED_LIBS)
Expand Down Expand Up @@ -423,6 +460,7 @@ if(ENABLE_TESTING)
uuid
Foundation
FoundationNetworking
FoundationXML
CoreFoundation)

add_swift_executable(TestFoundation
Expand Down Expand Up @@ -572,6 +610,7 @@ if(ENABLE_TESTING)
DEPENDS
Foundation
FoundationNetworking
FoundationXML
CoreFoundation
xdgTestHelper)

Expand Down Expand Up @@ -622,6 +661,8 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/swift/Foundation.swiftmodule
${CMAKE_CURRENT_BINARY_DIR}/swift/FoundationNetworking.swiftdoc
${CMAKE_CURRENT_BINARY_DIR}/swift/FoundationNetworking.swiftmodule
${CMAKE_CURRENT_BINARY_DIR}/swift/FoundationXML.swiftdoc
${CMAKE_CURRENT_BINARY_DIR}/swift/FoundationXML.swiftmodule
DESTINATION
lib/${swift_dir}/${swift_os}/${swift_arch})

Expand All @@ -630,22 +671,27 @@ set(Foundation_OUTPUT_FILE
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_${library_kind}_LIBRARY_PREFIX}Foundation${CMAKE_${library_kind}_LIBRARY_SUFFIX})
set(FoundationNetworking_OUTPUT_FILE
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_${library_kind}_LIBRARY_PREFIX}FoundationNetworking${CMAKE_${library_kind}_LIBRARY_SUFFIX})
set(FoundationXML_OUTPUT_FILE
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_${library_kind}_LIBRARY_PREFIX}FoundationXML${CMAKE_${library_kind}_LIBRARY_SUFFIX})

if(CMAKE_SYSTEM_NAME STREQUAL Windows AND BUILD_SHARED_LIBS)
install(FILES
${Foundation_OUTPUT_FILE}
${FoundationNetworking_OUTPUT_FILE}
${FoundationXML_OUTPUT_FILE}
DESTINATION
bin)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}Foundation${CMAKE_IMPORT_LIBRARY_SUFFIX}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}FoundationNetworking${CMAKE_IMPORT_LIBRARY_SUFFIX}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}FoundationXML${CMAKE_IMPORT_LIBRARY_SUFFIX}
DESTINATION
lib/${swift_dir}/${swift_os})
else()
install(FILES
${Foundation_OUTPUT_FILE}
${FoundationNetworking_OUTPUT_FILE}
${FoundationXML_OUTPUT_FILE}
DESTINATION
lib/${swift_dir}/${swift_os})
endif()
Expand All @@ -669,6 +715,15 @@ install(FILES
CoreFoundation/URL.subproj/module.map
DESTINATION
lib/swift/CFURLSessionInterface)
install(DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/CFXMLInterface.framework/Headers/
DESTINATION
lib/swift/CFXMLInterface
FILES_MATCHING PATTERN "*.h")
install(FILES
CoreFoundation/Parsing.subproj/module.map
DESTINATION
lib/swift/CFXMLInterface)
install(PROGRAMS
${CMAKE_CURRENT_BINARY_DIR}/plutil${CMAKE_EXECUTABLE_SUFFIX}
DESTINATION
Expand Down
64 changes: 0 additions & 64 deletions CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <CoreFoundation/CFLocaleInternal.h>
#include <CoreFoundation/CFCalendar.h>
#include <CoreFoundation/CFPriv.h>
#include <CoreFoundation/CFXMLInterface.h>
#include <CoreFoundation/CFRegularExpression.h>
#include <CoreFoundation/CFLogUtilities.h>
#include <CoreFoundation/CFDateIntervalFormatter.h>
Expand Down Expand Up @@ -187,68 +186,6 @@ struct _NSMutableStringBridge {
void (*_cfAppendCString)(CFTypeRef str, const char *chars, CFIndex appendLength);
};

struct _NSXMLParserBridge {
_CFXMLInterface _Nullable (*_Nonnull currentParser)(void);
_CFXMLInterfaceParserInput _Nullable (*_Nonnull _xmlExternalEntityWithURL)(_CFXMLInterface /*interface*/, const char * /*url*/, const char * /*identifier*/, _CFXMLInterfaceParserContext /*context*/, _CFXMLInterfaceExternalEntityLoader /*originalLoaderFunction*/);

_CFXMLInterfaceParserContext _Nonnull (*_Nonnull getContext)(_CFXMLInterface ctx);

void (*internalSubset)(_CFXMLInterface ctx, const unsigned char *name, const unsigned char *ExternalID, const unsigned char *SystemID);
int (*isStandalone)(_CFXMLInterface ctx);
int (*hasInternalSubset)(_CFXMLInterface ctx);
int (*hasExternalSubset)(_CFXMLInterface ctx);
_CFXMLInterfaceEntity _Nullable (*_Nonnull getEntity)(_CFXMLInterface ctx, const unsigned char *name);
void (*notationDecl)(_CFXMLInterface ctx,
const unsigned char *name,
const unsigned char *publicId,
const unsigned char *systemId);
void (*attributeDecl)(_CFXMLInterface ctx,
const unsigned char *elem,
const unsigned char *fullname,
int type,
int def,
const unsigned char *defaultValue,
_CFXMLInterfaceEnumeration tree);
void (*elementDecl)(_CFXMLInterface ctx,
const unsigned char *name,
int type,
_CFXMLInterfaceElementContent content);
void (*unparsedEntityDecl)(_CFXMLInterface ctx,
const unsigned char *name,
const unsigned char *publicId,
const unsigned char *systemId,
const unsigned char *notationName);
void (*startDocument)(_CFXMLInterface ctx);
void (*endDocument)(_CFXMLInterface ctx);
void (*startElementNs)(_CFXMLInterface ctx,
const unsigned char *localname,
const unsigned char *_Nullable prefix,
const unsigned char *_Nullable URI,
int nb_namespaces,
const unsigned char *_Nullable *_Nonnull namespaces,
int nb_attributes,
int nb_defaulted,
const unsigned char *_Nullable *_Nonnull attributes);
void (*endElementNs)(_CFXMLInterface ctx,
const unsigned char *localname,
const unsigned char *_Nullable prefix,
const unsigned char *_Nullable URI);
void (*characters)(_CFXMLInterface ctx,
const unsigned char *ch,
int len);
void (*processingInstruction)(_CFXMLInterface ctx,
const unsigned char *target,
const unsigned char *data);
void (*cdataBlock)(_CFXMLInterface ctx,
const unsigned char *value,
int len);
void (*comment)(_CFXMLInterface ctx, const unsigned char *value);
void (*externalSubset)(_CFXMLInterface ctx,
const unsigned char *name,
const unsigned char *ExternalID,
const unsigned char *SystemID);
};

struct _NSRunLoop {
_Nonnull CFTypeRef (*_Nonnull _new)(CFRunLoopRef rl);
};
Expand Down Expand Up @@ -327,7 +264,6 @@ struct _CFSwiftBridge {
struct _NSMutableSetBridge NSMutableSet;
struct _NSStringBridge NSString;
struct _NSMutableStringBridge NSMutableString;
struct _NSXMLParserBridge NSXMLParser;
struct _NSRunLoop NSRunLoop;
struct _NSCharacterSetBridge NSCharacterSet;
struct _NSMutableCharacterSetBridge NSMutableCharacterSet;
Expand Down
Loading