File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ ##===----------------------------------------------------------------------===##
2+ ##
3+ ## This source file is part of the Swift open source project
4+ ##
5+ ## Copyright (c) 2024 Apple Inc. and the Swift project authors
6+ ## Licensed under Apache License v2.0
7+ ##
8+ ## See LICENSE.txt for license information
9+ ## See CONTRIBUTORS.md for the list of Swift project authors
10+ ##
11+ ## SPDX-License-Identifier: Apache-2.0
12+ ##
13+ ##===----------------------------------------------------------------------===##
14+
15+ # Build the vendored version of the BlocksRuntime library, which is used by
16+ # platforms that don't support libdispatch.
17+
18+ add_library (BlocksRuntime
19+ data.c
20+ runtime.c)
21+
22+ target_include_directories (BlocksRuntime PUBLIC
23+ ${CMAKE_CURRENT_SOURCE_DIR} /include
24+ # For CFTargetConditionals.h
25+ ${CMAKE_CURRENT_SOURCE_DIR} /../include )
26+
27+ set_target_properties (BlocksRuntime PROPERTIES
28+ POSITION_INDEPENDENT_CODE FALSE )
29+
30+ add_library (BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime)
31+
32+ if (NOT BUILD_SHARED_LIBS )
33+ set_property (GLOBAL APPEND PROPERTY Foundation_EXPORTS BlocksRuntime)
34+ install (TARGETS BlocksRuntime
35+ ARCHIVE DESTINATION lib/swift$<$<NOT :$<BOOL :${BUILD_SHARED_LIBS} >>:_static>/${SWIFT_SYSTEM_NAME}
36+ LIBRARY DESTINATION lib/swift$<$<NOT :$<BOOL :${BUILD_SHARED_LIBS} >>:_static>/${SWIFT_SYSTEM_NAME} )
37+ endif ()
Original file line number Diff line number Diff line change @@ -118,6 +118,12 @@ target_link_libraries(CoreFoundation
118118 _FoundationICU
119119 dispatch)
120120
121+ if (CMAKE_SYSTEM_NAME STREQUAL WASI)
122+ # On WASI, we use vendored BlocksRuntime instead of the one from libdispatch
123+ add_subdirectory (BlockRuntime)
124+ target_link_libraries (CoreFoundation PRIVATE BlocksRuntime)
125+ endif ()
126+
121127set_property (GLOBAL APPEND PROPERTY Foundation_EXPORTS CoreFoundation)
122128
123129# Copy Headers to known directory for direct client (XCTest) test builds
Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ target_link_libraries(_CFXMLInterface PRIVATE
3333 dispatch
3434 LibXml2::LibXml2)
3535
36+ if (CMAKE_SYSTEM_NAME STREQUAL WASI)
37+ target_link_libraries (_CFXMLInterface PRIVATE BlocksRuntime)
38+ endif ()
39+
3640if (NOT BUILD_SHARED_LIBS )
3741 set_property (GLOBAL APPEND PROPERTY Foundation_EXPORTS _CFXMLInterface)
3842 install (TARGETS _CFXMLInterface
You can’t perform that action at this time.
0 commit comments