-
Notifications
You must be signed in to change notification settings - Fork 15
/
swift-android.patch
70 lines (66 loc) · 3.36 KB
/
swift-android.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
index 16e05052609..114e768bdbb 100755
--- a/swift/utils/build-script-impl
+++ b/swift/utils/build-script-impl
@@ -2412,7 +2412,7 @@ for host in "${ALL_HOSTS[@]}"; do
;;
foundation_macros)
- if [[ ${host} == "macosx"* ]]; then
+ if [[ ${host} == "macosx"* ]] || [[ "${host}" == "android-"* ]]; then
echo "Skipping Foundation Macros on OS X -- Foundation is part of the OS on this platform"
continue
fi
@@ -2601,6 +2601,7 @@ for host in "${ALL_HOSTS[@]}"; do
if [[ "${host}" == "android-"* ]]; then
cmake_options+=(
-DCMAKE_HAVE_LIBC_PTHREAD=True
+ -DSwiftFoundation_MODULE_TRIPLE:STRING="${ANDROID_ARCH}-unknown-linux-android"
)
fi
;;
@@ -3113,7 +3113,7 @@ for host in "${ALL_HOSTS[@]}"; do
;;
foundation|foundation_static|foundation_macros)
# FIXME: Foundation doesn't build from the script on OS X
- if [[ ${host} == "macosx"* ]]; then
+ if [[ ${host} == "macosx"* ]] || [[ "${host}" == "android-"* && "${product}" == "foundation_macros" ]]; then
echo "Skipping Foundation on OS X -- Foundation does not build for this platform"
continue
fi
diff --git a/swift-corelibs-foundation/CMakeLists.txt b/swift-corelibs-foundation/CMakeLists.txt
index 7f290d16..95366592 100644
--- a/swift-corelibs-foundation/CMakeLists.txt
+++ b/swift-corelibs-foundation/CMakeLists.txt
@@ -51,6 +51,7 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
endif()
endif()
+set(CMAKE_SHARED_LINKER_FLAGS "")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
diff --git a/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt b/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
index 016bf294..5c42986a 100644
--- a/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
+++ b/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
@@ -162,6 +162,10 @@ if(NOT BUILD_SHARED_LIBS)
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend _FoundationICU>")
target_compile_options(Foundation PRIVATE
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend swiftSynchronization>")
+ if(${CMAKE_SYSTEM_NAME} STREQUAL Android)
+ target_compile_options(Foundation PRIVATE
+ "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -public-autolink-library -Xfrontend android-spawn>")
+ endif()
endif()
set_target_properties(Foundation PROPERTIES
@@ -174,6 +174,12 @@
target_link_libraries(Foundation PUBLIC
swiftDispatch)
endif()
+ if(${CMAKE_SYSTEM_NAME} STREQUAL Android)
+ target_link_libraries(Foundation PRIVATE android-spawn)
+ list(GET CMAKE_FIND_ROOT_PATH 0 SPAWN_DIR)
+ target_include_directories(Foundation PUBLIC ${SPAWN_DIR}/usr/include)
+ target_link_directories(Foundation PUBLIC ${SPAWN_DIR}/usr/lib)
+ endif()
if(LINKER_SUPPORTS_BUILD_ID)
target_link_options(Foundation PRIVATE "LINKER:--build-id=sha1")