Skip to content

Commit

Permalink
Change how building Foundation macros is disabled and Foundation is c…
Browse files Browse the repository at this point in the history
…onfigured on the CI
  • Loading branch information
finagolfin committed Jan 24, 2025
1 parent 486e8be commit c3914d8
Showing 1 changed file with 44 additions and 19 deletions.
63 changes: 44 additions & 19 deletions swift-android.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,40 @@ 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"
@@ -2409,6 +2409,11 @@ for host in "${ALL_HOSTS[@]}"; do
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"

+ if [[ "${BUILD_SWIFT_TOOLS}" == "0" ]]; then
+ echo "Skipping building Foundation Macros for ${host}, because the host tools are not being built"
+ continue
+ fi
+
if [[ "${SKIP_CLEAN_FOUNDATION}" == "0" ]]
then
# The Swift project might have been changed, but CMake might
@@ -2558,11 +2563,6 @@ for host in "${ALL_HOSTS[@]}"; do
-DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}"
)
fi
- if [[ "${host}" == "android-"* ]]; then
- cmake_options+=(
- -DCMAKE_HAVE_LIBC_PTHREAD=True
- )
- 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"
libdispatch|libdispatch_static)
LIBDISPATCH_BUILD_DIR=$(build_directory ${host} ${product})
@@ -3009,6 +3009,11 @@ for host in "${ALL_HOSTS[@]}"; do
continue
fi

+ if [[ "${BUILD_SWIFT_TOOLS}" == "0" && "${product}" == "foundation_macros" ]]; then
+ echo "Skipping installing Foundation Macros for ${host}, because the host tools are not being built"
+ continue
+ fi
+
if [[ -z "${INSTALL_FOUNDATION}" ]] ; then
continue
fi
diff --git a/swift-corelibs-foundation/CMakeLists.txt b/swift-corelibs-foundation/CMakeLists.txt
Expand Down Expand Up @@ -68,3 +78,18 @@ index 016bf294..5c42986a 100644

if(LINKER_SUPPORTS_BUILD_ID)
target_link_options(Foundation PRIVATE "LINKER:--build-id=sha1")
diff --git a/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake b/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake
index cbdfc2a..bb4121d 100644
--- a/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake
+++ b/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake
@@ -37,6 +37,10 @@ function(_swift_foundation_install_target module)
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
if(CMAKE_Swift_COMPILER_TARGET)
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
+ else()
+ set(arg_list ${CMAKE_Swift_FLAGS})
+ separate_arguments(arg_list)
+ list(APPEND module_triple_command ${arg_list})
endif()
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple")

0 comments on commit c3914d8

Please sign in to comment.