mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Add prototypes to avoid dependency
Avoid a dependency on ICU headers on Apple platforms, rather than rely on corelibs-foundation being checked out. This simplifies the dependencies and unblocks build bots.
This commit is contained in:
@@ -31,12 +31,6 @@ set(ICU_UC_LIBRARY "")
|
||||
|
||||
set(swift_stubs_c_compile_flags ${SWIFT_RUNTIME_CORE_CXX_FLAGS})
|
||||
list(APPEND swift_stubs_c_compile_flags -DswiftCore_EXPORTS)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
# Our shims need ICU headers. For now, use the ones inside corelibs-foundation
|
||||
#
|
||||
# TODO: Get them from the SDK instead
|
||||
list(APPEND swift_stubs_c_compile_flags -I${CMAKE_CURRENT_LIST_DIR}/../../../../swift-corelibs-foundation/bootstrap/x86_64-apple-darwin/usr/local/include/)
|
||||
endif()
|
||||
|
||||
add_swift_library(swiftStdlibStubs OBJECT_LIBRARY TARGET_LIBRARY
|
||||
${swift_stubs_sources}
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "../SwiftShims/UnicodeShims.h"
|
||||
|
||||
#if !defined(__APPLE__)
|
||||
#include "swift/Basic/Lazy.h"
|
||||
#include "swift/Runtime/Config.h"
|
||||
@@ -22,7 +24,6 @@
|
||||
#include <algorithm>
|
||||
#include <mutex>
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdocumentation"
|
||||
@@ -35,9 +36,6 @@
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#include "../SwiftShims/UnicodeShims.h"
|
||||
|
||||
#if !defined(__APPLE__)
|
||||
static const UCollator *MakeRootCollator() {
|
||||
UErrorCode ErrorCode = U_ZERO_ERROR;
|
||||
UCollator *root = ucol_open("", &ErrorCode);
|
||||
@@ -303,6 +301,24 @@ template <typename T, typename U> const T *ptr_cast(const U *p) {
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <stdint.h>
|
||||
extern "C" {
|
||||
// Declare a few external functions to avoid a dependency on ICU headers.
|
||||
typedef struct UBreakIterator UBreakIterator;
|
||||
typedef enum UBreakIteratorType {} UBreakIteratorType;
|
||||
typedef enum UErrorCode {} UErrorCode;
|
||||
typedef uint16_t UChar;
|
||||
|
||||
void ubrk_close(UBreakIterator *);
|
||||
UBreakIterator *ubrk_open(UBreakIteratorType, const char *, const UChar *,
|
||||
int32_t, UErrorCode *);
|
||||
int32_t ubrk_preceding(UBreakIterator *, int32_t);
|
||||
int32_t ubrk_following(UBreakIterator *, int32_t);
|
||||
void ubrk_setText(UBreakIterator *, const UChar *, int32_t, UErrorCode *);
|
||||
}
|
||||
#endif // defined(__APPLE__)
|
||||
|
||||
void swift::__swift_stdlib_ubrk_close(
|
||||
swift::__swift_stdlib_UBreakIterator *bi) {
|
||||
ubrk_close(ptr_cast<UBreakIterator>(bi));
|
||||
|
||||
Reference in New Issue
Block a user