diff --git a/packages/swift/build.sh b/packages/swift/build.sh index 219f22702..a9eb02186 100644 --- a/packages/swift/build.sh +++ b/packages/swift/build.sh @@ -1,13 +1,12 @@ TERMUX_PKG_HOMEPAGE=https://www.swift.org/ TERMUX_PKG_DESCRIPTION="Swift is a high-performance system programming language" TERMUX_PKG_LICENSE="Apache-2.0, NCSA" -TERMUX_PKG_VERSION=5.2.1 -TERMUX_PKG_REVISION=2 +TERMUX_PKG_VERSION=5.2.2 SWIFT_RELEASE="RELEASE" -TERMUX_PKG_SHA256=3488e920ad989b1c6a8d25ef241d356a9951184fefcad19e230e3263b6e80f48 +TERMUX_PKG_SHA256=92b0d1225e61a521ea10fe25f2cc35a2ad50ac55d1690d710f675d4db0c13b35 TERMUX_PKG_SRCURL=https://github.com/apple/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz TERMUX_PKG_HOSTBUILD=true -TERMUX_PKG_DEPENDS="binutils-gold, libc++, ndk-sysroot, libandroid-glob, libandroid-spawn, libcurl, libicu, libsqlite, libuuid, libxml2, libdispatch, llbuild" +TERMUX_PKG_DEPENDS="binutils-gold, libc++, ndk-sysroot, libandroid-glob, libandroid-spawn, libcurl, libicu, libicu-static, libsqlite, libuuid, libxml2, libdispatch, llbuild" TERMUX_PKG_BUILD_DEPENDS="cmake, ninja, perl, pkg-config, python2, rsync" TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686, x86_64" TERMUX_PKG_NO_STATICSPLIT=true @@ -35,17 +34,17 @@ termux_step_post_extract_package() { termux_download \ https://swift.org/builds/swift-$TERMUX_PKG_VERSION-release/ubuntu1804/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu18.04.tar.gz \ $TERMUX_PKG_CACHEDIR/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu18.04.tar.gz \ - 3f7522163fc6999560ade1ac80ceac8d1f6eb9b050511cb81c53d41e9ac9a180 + c29afff6ebf3ca69a9b5a5621b9ffd7614626070eb982d4e7174a6d8352b6ce2 fi declare -A library_checksums - library_checksums[swift-cmark]=ac18a4a55739af8afb9009f4d8d7643a78fda47a329e1b1f8c782122db88b3b1 - library_checksums[llvm-project]=f21cfa75413ab290991f28a05a975b15af9289140e2f595aa981e630496907e7 - library_checksums[swift-corelibs-libdispatch]=7bab5d4d1e8e0aea0d7fec80b1dbf7f897389d19566e02ef5cd0e7026b968f10 - library_checksums[swift-corelibs-foundation]=5a223f6398d5cedb94019f61beca69eb35473ca2cc65bcbd60d93248342f417d - library_checksums[swift-corelibs-xctest]=d25df8b4caaef8e8339ecb2344fd5cbbe10b2e0f33d9861b1ec8fdebf7364645 - library_checksums[swift-llbuild]=8812862ef27079fb41f13ac3e741a1e488bd321d79c6a57d026ca1c1e25d90c7 - library_checksums[swift-package-manager]=73e12edffce218d1fdfd626c2000a9d9f5805a946175899600b50379e885770e + library_checksums[swift-cmark]=0992aa8065beb88c8471e30e414a243be3e270b02b66e4c242ba741169baafe4 + library_checksums[llvm-project]=2c30e793e4bc29dc396fab522bebda731bb25be0019b07f314e70139c94de552 + library_checksums[swift-corelibs-libdispatch]=cae4ffc25cc3e349f63292cace22d922d81ac7f82f29d9ceac8c9210d04e662d + library_checksums[swift-corelibs-foundation]=e27590541c326e1f7a254070f87f0871b6593a6b206a8ef9be5c9af22c3d2e15 + library_checksums[swift-corelibs-xctest]=5f93884c542552602d3a6bb2acd087aa5400bca68d9be79b4b1afd51fb8ca982 + library_checksums[swift-llbuild]=b54ec43c58bf2fddfcc4e83fe744567f05274feb024dd2a39dba6b1badb49fac + library_checksums[swift-package-manager]=6d259436b1c09512e285187eb8794bbf550bdb513e243bc46e4790df0b1b9be8 for library in "${!library_checksums[@]}"; do \ termux_download \ @@ -72,19 +71,31 @@ termux_step_post_extract_package() { # The Swift build scripts still depend on Python 2, so make sure it's used. ln -s $(which python2) $TERMUX_PKG_BUILDDIR/python - export PATH=$TERMUX_PKG_BUILDDIR:$PATH fi + export PATH=$TERMUX_PKG_BUILDDIR:$PATH } termux_step_host_build() { if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then - tar xf $TERMUX_PKG_CACHEDIR/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu18.04.tar.gz + if [ "$TERMUX_PKG_QUICK_REBUILD" = "false" ]; then + tar xf $TERMUX_PKG_CACHEDIR/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu18.04.tar.gz + fi local SWIFT_BINDIR="$TERMUX_PKG_HOSTBUILD_DIR/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu18.04/usr/bin" termux_setup_cmake termux_setup_ninja termux_setup_standalone_toolchain + local CLANG=$(command -v clang) + local CLANGXX=$(command -v clang++) + + # The Ubuntu CI may not have clang/clang++ in its path so explicitly set it + # to clang-9 instead. + if [ -z "$CLANG" ]; then + CLANG=$(command -v clang-9) + CLANGXX=$(command -v clang++-9) + fi + # Natively compile llvm-tblgen and some other files needed later, and cross-compile # the Swift stdlib. SWIFT_BUILD_ROOT=$TERMUX_PKG_BUILDDIR $TERMUX_PKG_SRCDIR/swift/utils/build-script \ @@ -95,7 +106,7 @@ termux_step_host_build() { --build-swift-static-sdk-overlay --stdlib-deployment-targets=android-$TERMUX_ARCH \ --swift-primary-variant-sdk=ANDROID --swift-primary-variant-arch=$TERMUX_ARCH \ --swift-install-components="stdlib;sdk-overlay" --install-swift \ - --host-cc=/usr/bin/clang-9 --host-cxx=/usr/bin/clang++-9 + --host-cc=$CLANG --host-cxx=$CLANGXX fi } diff --git a/packages/swift/swift-build-script.patch.beforehostbuild b/packages/swift/swift-build-script.patch.beforehostbuild index 403e0170d..dcba14327 100644 --- a/packages/swift/swift-build-script.patch.beforehostbuild +++ b/packages/swift/swift-build-script.patch.beforehostbuild @@ -1,3 +1,21 @@ +diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl +index b1d060328bc..218c9215260 100755 +--- a/swift/utils/build-script-impl ++++ b/swift/utils/build-script-impl +@@ -1782,6 +1782,13 @@ + -DSWIFT_ANDROID_DEPLOY_DEVICE_PATH:STRING="${ANDROID_DEPLOY_DEVICE_PATH}" + -DSWIFT_SDK_ANDROID_ARCHITECTURES:STRING="${ANDROID_ARCH}" + ) ++ if [[ "${host}" == "${LOCAL_HOST}" ]] ; then ++ cmake_options=( ++ "${cmake_options[@]}" ++ -DCMAKE_FIND_ROOT_PATH=@TERMUX_PREFIX@ ++ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER ++ ) ++ fi + fi + + if [[ "${DARWIN_OVERLAY_TARGET}" != "" ]]; then diff --git a/swift/utils/gen-static-stdlib-link-args b/swift/utils/gen-static-stdlib-link-args index 0fa009d67d3..abd98c2493f 100755 --- a/swift/utils/gen-static-stdlib-link-args diff --git a/packages/swift/swift-cmake.patch.beforehostbuild b/packages/swift/swift-cmake.patch.beforehostbuild index 6be374945..f2bd4c5c3 100644 --- a/packages/swift/swift-cmake.patch.beforehostbuild +++ b/packages/swift/swift-cmake.patch.beforehostbuild @@ -7,24 +7,10 @@ index 7490e1df821..9a5ec99cba0 100644 endif() -if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT) -+if((SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT) AND ${SWIFT_HOST_VARIANT_SDK} STREQUAL ANDROID AND ${CMAKE_SYSTEM_NAME} STREQUAL ANDROID) ++if((SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT) AND ${SWIFT_HOST_VARIANT_SDK} MATCHES "OSX|WINDOWS") if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) if(CMAKE_C_COMPILER_ID STREQUAL Clang AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 3.8 -@@ -1042,11 +1042,13 @@ if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT) - set(SOURCEKIT_RUNTIME_DIR lib) - endif() - add_dependencies(sourcekit-inproc BlocksRuntime dispatch) -+ if(SWIFT_HOST_VARIANT_SDK MATCHES "OSX|WINDOWS") - swift_install_in_component(FILES - $ - $ - DESTINATION ${SOURCEKIT_RUNTIME_DIR} - COMPONENT sourcekit-inproc) -+ endif() - if(SWIFT_HOST_VARIANT_SDK STREQUAL WINDOWS) - swift_install_in_component(FILES - $ diff --git a/swift/cmake/modules/AddSwift.cmake b/swift/cmake/modules/AddSwift.cmake index b40bd4d881e..8c51c6b6857 100644 --- a/swift/cmake/modules/AddSwift.cmake diff --git a/scripts/build/termux_step_handle_hostbuild.sh b/scripts/build/termux_step_handle_hostbuild.sh index 5638c41d8..ec2101526 100644 --- a/scripts/build/termux_step_handle_hostbuild.sh +++ b/scripts/build/termux_step_handle_hostbuild.sh @@ -11,8 +11,10 @@ termux_step_handle_hostbuild() { local TERMUX_HOSTBUILD_MARKER="$TERMUX_PKG_HOSTBUILD_DIR/TERMUX_BUILT_FOR_$TERMUX_PKG_VERSION" if [ ! -f "$TERMUX_HOSTBUILD_MARKER" ]; then - rm -Rf "$TERMUX_PKG_HOSTBUILD_DIR" - mkdir -p "$TERMUX_PKG_HOSTBUILD_DIR" + if [ "$TERMUX_PKG_QUICK_REBUILD" = "false" ]; then + rm -Rf "$TERMUX_PKG_HOSTBUILD_DIR" + mkdir -p "$TERMUX_PKG_HOSTBUILD_DIR" + fi cd "$TERMUX_PKG_HOSTBUILD_DIR" termux_step_host_build touch "$TERMUX_HOSTBUILD_MARKER"