Skip to content

Build Foundation with DEPLOYMENT_RUNTIME_SWIFT disabled #1559

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 3 commits into from
May 30, 2018
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
1 change: 1 addition & 0 deletions CoreFoundation/Locale.subproj/CFCalendar.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


#include <CoreFoundation/CFCalendar.h>
#include <CoreFoundation/CFLocaleInternal.h>
#include <CoreFoundation/CFRuntime.h>
#include "CFInternal.h"
#include "CFPriv.h"
Expand Down
1 change: 1 addition & 0 deletions CoreFoundation/Locale.subproj/CFLocale.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

// Note the header file is in the OpenSource set (stripped to almost nothing), but not the .c file

#include <CoreFoundation/CFInternal.h>
#include <CoreFoundation/CFLocale.h>
#include <CoreFoundation/CFLocale_Private.h>
#include <CoreFoundation/CFString.h>
Expand Down
11 changes: 10 additions & 1 deletion CoreFoundation/Parsing.subproj/CFXMLInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

#include <CoreFoundation/CFRuntime.h>
#include <CoreFoundation/CFInternal.h>
#include <libxml/globals.h>
#include <libxml/xmlerror.h>
#include <libxml/parser.h>
Expand All @@ -22,7 +23,7 @@
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <libxml/dict.h>
#include "CFInternal.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

So we don't use CFInternal.h here at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't removed, it moved up & uses qualified path. Check line 15: <CoreFoundation/CFInternal.h>

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thanks. Misread the diff.

#include "CFXMLInterface.h"

/*
libxml2 does not have nullability annotations and does not import well into swift when given potentially differing versions of the library that might be installed on the host operating system. This is a simple C wrapper to simplify some of that interface layer to libxml2.
Expand Down Expand Up @@ -110,6 +111,7 @@ typedef struct {
xmlNotationPtr notation;
} _cfxmlNotation;

#if DEPLOYMENT_RUNTIME_SWIFT
static xmlExternalEntityLoader __originalLoader = NULL;

static xmlParserInputPtr _xmlExternalEntityLoader(const char *urlStr, const char * ID, xmlParserCtxtPtr context) {
Expand All @@ -119,30 +121,36 @@ static xmlParserInputPtr _xmlExternalEntityLoader(const char *urlStr, const char
}
return __originalLoader(urlStr, ID, context);
}
#endif // DEPLOYMENT_RUNTIME_SWIFT

void _CFSetupXMLInterface(void) {
#if DEPLOYMENT_RUNTIME_SWIFT
static dispatch_once_t xmlInitGuard;
dispatch_once(&xmlInitGuard, ^{
xmlInitParser();
// set up the external entity loader
__originalLoader = xmlGetExternalEntityLoader();
xmlSetExternalEntityLoader(_xmlExternalEntityLoader);
});
#endif // DEPLOYMENT_RUNTIME_SWIFT
}

_CFXMLInterfaceParserInput _CFXMLInterfaceNoNetExternalEntityLoader(const char *URL, const char *ID, _CFXMLInterfaceParserContext ctxt) {
return xmlNoNetExternalEntityLoader(URL, ID, ctxt);
}

#if DEPLOYMENT_RUNTIME_SWIFT
static void _errorCallback(void *ctx, const char *msg, ...) {
xmlParserCtxtPtr context = __CFSwiftBridge.NSXMLParser.getContext((_CFXMLInterface)ctx);
xmlErrorPtr error = xmlCtxtGetLastError(context);
// TODO: reporting
// _reportError(error, (_CFXMLInterface)ctx);
}
#endif // DEPLOYMENT_RUNTIME_SWIFT

_CFXMLInterfaceSAXHandler _CFXMLInterfaceCreateSAXHandler() {
_CFXMLInterfaceSAXHandler saxHandler = (_CFXMLInterfaceSAXHandler)calloc(1, sizeof(struct _xmlSAXHandler));
#if DEPLOYMENT_RUNTIME_SWIFT
saxHandler->internalSubset = (internalSubsetSAXFunc)__CFSwiftBridge.NSXMLParser.internalSubset;
saxHandler->isStandalone = (isStandaloneSAXFunc)__CFSwiftBridge.NSXMLParser.isStandalone;

Expand All @@ -168,6 +176,7 @@ _CFXMLInterfaceSAXHandler _CFXMLInterfaceCreateSAXHandler() {
saxHandler->externalSubset = (externalSubsetSAXFunc)__CFSwiftBridge.NSXMLParser.externalSubset;

saxHandler->initialized = XML_SAX2_MAGIC; // make sure start/endElementNS are used
#endif //if DEPLOYMENT_RUNTIME_SWIFT
return saxHandler;
}

Expand Down
2 changes: 1 addition & 1 deletion CoreFoundation/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
'String.subproj/CFRegularExpression.c',
'String.subproj/CFAttributedString.c',
'String.subproj/CFRunArray.c',
'Base.subproj/CFKnownLocations.h',
'Base.subproj/CFKnownLocations.c',
]

sources = CompileSources(sources_list)
Expand Down
2 changes: 1 addition & 1 deletion lib/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def generate_products(self):
script = flags + commands

for product in self.products:
script += product.generate()
script += "".join([product_build_command for product_build_command in product.generate() if not isinstance(product_build_command, list)])

script += """

Expand Down