@@ -2,30 +2,40 @@ diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
22index 16e05052609..114e768bdbb 100755
33--- a/swift/utils/build-script-impl
44+++ b/swift/utils/build-script-impl
5- @@ -2412,7 +2412,7 @@ for host in "${ALL_HOSTS[@]}"; do
6-
7- ;;
8- foundation_macros)
9- - if [[ ${host} == "macosx"* ]]; then
10- + if [[ ${host} == "macosx"* ]] || [[ "${host}" == "android-"* ]]; then
11- echo "Skipping Foundation Macros on OS X -- Foundation is part of the OS on this platform"
5+ @@ -2409,6 +2409,11 @@ for host in "${ALL_HOSTS[@]}"; do
126 continue
137 fi
14- @@ -2601,6 +2601,7 @@ for host in "${ALL_HOSTS[@]}"; do
15- if [[ "${host}" == "android-"* ]]; then
16- cmake_options+=(
17- -DCMAKE_HAVE_LIBC_PTHREAD=True
18- + -DSwiftFoundation_MODULE_TRIPLE:STRING="${ANDROID_ARCH}-unknown-linux-android"
8+
9+ + if [[ "${BUILD_SWIFT_TOOLS}" == "0" ]]; then
10+ + echo "Skipping building Foundation Macros for ${host}, because the host tools are not being built"
11+ + continue
12+ + fi
13+ +
14+ if [[ "${SKIP_CLEAN_FOUNDATION}" == "0" ]]
15+ then
16+ # The Swift project might have been changed, but CMake might
17+ @@ -2558,11 +2563,6 @@ for host in "${ALL_HOSTS[@]}"; do
18+ -DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}"
1919 )
2020 fi
21+ - if [[ "${host}" == "android-"* ]]; then
22+ - cmake_options+=(
23+ - -DCMAKE_HAVE_LIBC_PTHREAD=True
24+ - )
25+ - fi
2126 ;;
22- @@ -3113,7 +3113,7 @@ for host in "${ALL_HOSTS[@]}"; do
23- ;;
24- foundation|foundation_static|foundation_macros)
25- # FIXME: Foundation doesn't build from the script on OS X
26- - if [[ ${host} == "macosx"* ]]; then
27- + if [[ ${host} == "macosx"* ]] || [[ "${host}" == "android-"* && "${product}" == "foundation_macros" ]]; then
28- echo "Skipping Foundation on OS X -- Foundation does not build for this platform"
27+ libdispatch|libdispatch_static)
28+ LIBDISPATCH_BUILD_DIR=$(build_directory ${host} ${product})
29+ @@ -3009,6 +3009,11 @@ for host in "${ALL_HOSTS[@]}"; do
30+ continue
31+ fi
32+
33+ + if [[ "${BUILD_SWIFT_TOOLS}" == "0" && "${product}" == "foundation_macros" ]]; then
34+ + echo "Skipping installing Foundation Macros for ${host}, because the host tools are not being built"
35+ + continue
36+ + fi
37+ +
38+ if [[ -z "${INSTALL_FOUNDATION}" ]] ; then
2939 continue
3040 fi
3141diff --git a/swift-corelibs-foundation/CMakeLists.txt b/swift-corelibs-foundation/CMakeLists.txt
@@ -68,3 +78,18 @@ index 016bf294..5c42986a 100644
6878
6979 if(LINKER_SUPPORTS_BUILD_ID)
7080 target_link_options(Foundation PRIVATE "LINKER:--build-id=sha1")
81+ diff --git a/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake b/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake
82+ index cbdfc2a..bb4121d 100644
83+ --- a/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake
84+ +++ b/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake
85+ @@ -37,6 +37,10 @@ function(_swift_foundation_install_target module)
86+ set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
87+ if(CMAKE_Swift_COMPILER_TARGET)
88+ list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
89+ + else()
90+ + set(arg_list ${CMAKE_Swift_FLAGS})
91+ + separate_arguments(arg_list)
92+ + list(APPEND module_triple_command ${arg_list})
93+ endif()
94+ execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
95+ string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple")
0 commit comments