2020-06-13 14:45:59 +02:00
|
|
|
TERMUX_PKG_HOMEPAGE=https://swift.org/
|
2020-02-17 18:24:10 +01:00
|
|
|
TERMUX_PKG_DESCRIPTION="Swift is a high-performance system programming language"
|
|
|
|
TERMUX_PKG_LICENSE="Apache-2.0, NCSA"
|
2020-09-07 18:23:03 +02:00
|
|
|
TERMUX_PKG_MAINTAINER="@buttaface"
|
2021-10-27 08:47:02 +02:00
|
|
|
TERMUX_PKG_VERSION=5.5.1
|
2021-11-05 19:13:00 +01:00
|
|
|
TERMUX_PKG_REVISION=2
|
2020-02-17 18:24:10 +01:00
|
|
|
SWIFT_RELEASE="RELEASE"
|
|
|
|
TERMUX_PKG_SRCURL=https://github.com/apple/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz
|
2021-10-27 08:47:02 +02:00
|
|
|
TERMUX_PKG_SHA256=b4092b2584919f718a55ad0ed460fbc48e84ec979a9397ce0adce307aba41ac9
|
2020-02-17 18:24:10 +01:00
|
|
|
TERMUX_PKG_HOSTBUILD=true
|
2021-10-24 11:08:33 +02:00
|
|
|
TERMUX_PKG_DEPENDS="lld, clang, libc++, ndk-sysroot, libandroid-glob, libandroid-spawn, libcurl, libicu, libicu-static, libsqlite, libuuid, libxml2, libdispatch, llbuild"
|
2021-05-25 21:31:42 +02:00
|
|
|
TERMUX_PKG_BUILD_DEPENDS="cmake, ninja, perl, pkg-config, rsync"
|
2020-11-11 07:56:38 +01:00
|
|
|
TERMUX_PKG_BLACKLISTED_ARCHES="i686"
|
2020-02-17 18:24:10 +01:00
|
|
|
TERMUX_PKG_NO_STATICSPLIT=true
|
2021-08-22 12:53:24 +02:00
|
|
|
# Build of swift uses cmake, but the standard
|
|
|
|
# termux_step_configure_cmake function is not used. Instead we set
|
|
|
|
# TERMUX_PKG_FORCE_CMAKE to make the build system aware that cmake is
|
|
|
|
# needed.
|
|
|
|
TERMUX_PKG_FORCE_CMAKE=true
|
|
|
|
TERMUX_CMAKE_BUILD=Ninja
|
2020-02-17 18:24:10 +01:00
|
|
|
|
2020-09-07 18:23:03 +02:00
|
|
|
SWIFT_COMPONENTS="autolink-driver;compiler;clang-resource-dir-symlink;swift-remote-mirror;parser-lib;license;sourcekit-inproc;stdlib;sdk-overlay"
|
2020-02-17 18:24:10 +01:00
|
|
|
SWIFT_TOOLCHAIN_FLAGS="-R --no-assertions --llvm-targets-to-build='X86;ARM;AArch64' -j $TERMUX_MAKE_PROCESSES"
|
|
|
|
SWIFT_PATH_FLAGS="--build-subdir=. --install-destdir=/ --install-prefix=$TERMUX_PREFIX"
|
2020-09-07 18:23:03 +02:00
|
|
|
SWIFT_BUILD_FLAGS="$SWIFT_TOOLCHAIN_FLAGS $SWIFT_PATH_FLAGS"
|
2020-02-17 18:24:10 +01:00
|
|
|
|
2020-09-07 18:23:03 +02:00
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
2021-08-22 12:44:14 +02:00
|
|
|
SWIFT_BIN="swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu20.04"
|
|
|
|
SWIFT_BINDIR="$TERMUX_PKG_HOSTBUILD_DIR/$SWIFT_BIN/usr/bin"
|
2020-02-17 18:24:10 +01:00
|
|
|
fi
|
2021-08-22 12:44:14 +02:00
|
|
|
SWIFT_ARCH=$TERMUX_ARCH
|
|
|
|
test $SWIFT_ARCH == 'arm' && SWIFT_ARCH='armv7'
|
2020-02-17 18:24:10 +01:00
|
|
|
|
2020-07-16 23:58:48 +02:00
|
|
|
termux_step_post_get_source() {
|
2021-08-21 18:08:57 +02:00
|
|
|
# The Swift build-script requires a particular organization of source
|
|
|
|
# directories, which the following sets up.
|
|
|
|
mkdir .temp
|
|
|
|
mv [a-zA-Z]* .temp/
|
|
|
|
mv .temp swift
|
|
|
|
|
|
|
|
declare -A library_checksums
|
2021-10-27 08:47:02 +02:00
|
|
|
library_checksums[swift-cmark]=36c9de0d5a7f71455542c780b8a0a4bd703e6f0d1456a5a1a9caf22e3cb4182a
|
|
|
|
library_checksums[llvm-project]=095763d76000b95910ce19837d45b932a48f8ab4a002a8b27e986b1a29e8432f
|
|
|
|
library_checksums[swift-corelibs-libdispatch]=de280f470850d98887eeb0f2b4dc3524d0f2f8eb93af5618d4f1e5312d4cbbdf
|
|
|
|
library_checksums[swift-corelibs-foundation]=ab99fbcf0e8ede00482c614cfd0c4c42a27ae94744ca3ce0d9b03a52a3f8d4d0
|
|
|
|
library_checksums[swift-corelibs-xctest]=11ee237c61dcd1fb20b30c35a552e5c0044d069cbaad9fb9bddd175efec4f984
|
|
|
|
library_checksums[swift-llbuild]=39998792dea9d36ec1b98d07e9e6100a9853e9a3f845b319de81cf1aaae6a8dd
|
2021-07-04 19:15:47 +02:00
|
|
|
library_checksums[swift-argument-parser]=9dfcb236f599e309e49af145610957648f8a59d9527b4202bc5bdda0068556d7
|
2021-08-21 18:08:57 +02:00
|
|
|
library_checksums[Yams]=8bbb28ef994f60afe54668093d652e4d40831c79885fa92b1c2cd0e17e26735a
|
2021-07-04 19:15:47 +02:00
|
|
|
library_checksums[swift-crypto]=86d6c22c9f89394fd579e967b0d5d0b6ce33cdbf52ba70f82fa313baf70c759f
|
2021-10-27 08:47:02 +02:00
|
|
|
library_checksums[swift-driver]=f8ea378f1d9466fbd0206796dabb03e178390f3fd6584e582038ae75fd75fece
|
|
|
|
library_checksums[swift-tools-support-core]=a2f21a2814286ee23766ae55eebe5a4797ad04fd674ef37a9411a9bd40782222
|
|
|
|
library_checksums[swift-package-manager]=73331ad0d27f1e40a0d50d45337f986e0303dd0c872a0991db916126bd3949fe
|
|
|
|
library_checksums[indexstore-db]=a678003f61b2795ee76d89fd4f008a77fab4522d275764db413ecce8b0aa66e2
|
|
|
|
library_checksums[sourcekit-lsp]=9c5f3358e854cf42af1a03567e02d04476bb5b47c3b914512f29ecc46117e445
|
2021-08-21 18:08:57 +02:00
|
|
|
|
|
|
|
for library in "${!library_checksums[@]}"; do \
|
|
|
|
if [ "$library" = "swift-argument-parser" ]; then
|
|
|
|
GH_ORG="apple"
|
2021-07-04 19:15:47 +02:00
|
|
|
SRC_VERSION="0.4.3"
|
|
|
|
TAR_NAME=$SRC_VERSION
|
|
|
|
elif [ "$library" = "swift-crypto" ]; then
|
|
|
|
GH_ORG="apple"
|
|
|
|
SRC_VERSION="1.1.5"
|
2021-08-21 18:08:57 +02:00
|
|
|
TAR_NAME=$SRC_VERSION
|
|
|
|
elif [ "$library" = "Yams" ]; then
|
|
|
|
GH_ORG="jpsim"
|
|
|
|
SRC_VERSION="4.0.2"
|
|
|
|
TAR_NAME=$SRC_VERSION
|
|
|
|
else
|
|
|
|
GH_ORG="apple"
|
|
|
|
SRC_VERSION=$SWIFT_RELEASE
|
|
|
|
TAR_NAME=swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE
|
2020-04-30 13:56:12 +02:00
|
|
|
fi
|
2021-08-21 18:08:57 +02:00
|
|
|
|
|
|
|
termux_download \
|
|
|
|
https://github.com/$GH_ORG/$library/archive/$TAR_NAME.tar.gz \
|
|
|
|
$TERMUX_PKG_CACHEDIR/$library-$SRC_VERSION.tar.gz \
|
|
|
|
${library_checksums[$library]}
|
|
|
|
tar xf $TERMUX_PKG_CACHEDIR/$library-$SRC_VERSION.tar.gz
|
|
|
|
mv $library-$TAR_NAME $library
|
|
|
|
done
|
|
|
|
|
|
|
|
mv swift-cmark cmark
|
|
|
|
mv swift-llbuild llbuild
|
|
|
|
mv Yams yams
|
|
|
|
mv swift-package-manager swiftpm
|
|
|
|
|
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
|
|
|
termux_download \
|
|
|
|
https://swift.org/builds/swift-$TERMUX_PKG_VERSION-release/ubuntu2004/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE/$SWIFT_BIN.tar.gz \
|
|
|
|
$TERMUX_PKG_CACHEDIR/$SWIFT_BIN.tar.gz \
|
2021-10-27 08:47:02 +02:00
|
|
|
2b78e9eaf7e3ca980de3228fa5b611d3f9cf116b26d8cdad81ed3435b8d8027a
|
2020-02-17 18:24:10 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_host_build() {
|
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
|
|
|
termux_setup_cmake
|
|
|
|
termux_setup_ninja
|
|
|
|
|
2021-10-27 12:08:29 +02:00
|
|
|
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-10 instead.
|
|
|
|
if [ -z "$CLANG" ]; then
|
|
|
|
CLANG=$(command -v clang-10)
|
|
|
|
CLANGXX=$(command -v clang++-10)
|
|
|
|
fi
|
|
|
|
|
2020-09-07 18:23:03 +02:00
|
|
|
# Natively compile llvm-tblgen and some other files needed later.
|
2021-08-22 12:44:14 +02:00
|
|
|
SWIFT_BUILD_ROOT=$TERMUX_PKG_HOSTBUILD_DIR $TERMUX_PKG_SRCDIR/swift/utils/build-script \
|
2021-06-29 10:14:04 +02:00
|
|
|
-R --no-assertions -j $TERMUX_MAKE_PROCESSES $SWIFT_PATH_FLAGS \
|
2021-10-27 12:08:29 +02:00
|
|
|
--skip-build-cmark --skip-build-llvm --skip-build-swift --build-toolchain-only \
|
|
|
|
--host-cc=$CLANG --host-cxx=$CLANGXX
|
2020-09-07 18:23:03 +02:00
|
|
|
|
|
|
|
tar xf $TERMUX_PKG_CACHEDIR/$SWIFT_BIN.tar.gz -C $TERMUX_PKG_HOSTBUILD_DIR
|
2020-02-17 18:24:10 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_pre_configure() {
|
2021-08-21 18:08:57 +02:00
|
|
|
cd llbuild
|
|
|
|
# A single patch needed from the existing llbuild package
|
|
|
|
patch -p1 < $TERMUX_PKG_BUILDER_DIR/../llbuild/lib-llvm-Support-CmakeLists.txt.patch
|
|
|
|
|
|
|
|
cd ../llvm-project
|
|
|
|
patch -p1 < $TERMUX_PKG_BUILDER_DIR/../libllvm/clang-lib-Driver-ToolChain.cpp.patch
|
2021-10-24 11:08:33 +02:00
|
|
|
patch -p1 < $TERMUX_PKG_BUILDER_DIR/clang-lib-Driver-ToolChains-Linux.cpp.diff
|
|
|
|
cd ../swift-corelibs-libdispatch
|
|
|
|
patch -p1 < $TERMUX_PKG_BUILDER_DIR/../libdispatch/src-shims-atomic.h.patch
|
2021-08-21 18:08:57 +02:00
|
|
|
cd ..
|
|
|
|
|
2021-09-27 13:46:31 +02:00
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
|
|
|
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" \
|
|
|
|
$TERMUX_PKG_BUILDER_DIR/swiftpm-driver-lsp-termux-flags | \
|
|
|
|
sed "s%\@CCTERMUX_HOST_PLATFORM\@%${CCTERMUX_HOST_PLATFORM}%g" | patch -p1
|
|
|
|
fi
|
2020-02-17 18:24:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_make() {
|
2021-08-22 12:44:14 +02:00
|
|
|
# The Swift compiler searches for the clang headers so symlink against them.
|
|
|
|
export TERMUX_CLANG_VERSION=$(grep ^TERMUX_PKG_VERSION= $TERMUX_PKG_BUILDER_DIR/../libllvm/build.sh | cut -f2 -d=)
|
|
|
|
|
2020-06-13 14:45:59 +02:00
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
2021-08-22 12:44:14 +02:00
|
|
|
ln -sf $TERMUX_PKG_HOSTBUILD_DIR/llvm-linux-x86_64 $TERMUX_PKG_BUILDDIR/llvm-linux-x86_64
|
2020-11-06 17:02:29 +01:00
|
|
|
SWIFT_BUILD_FLAGS="$SWIFT_BUILD_FLAGS --android
|
|
|
|
--android-ndk $TERMUX_STANDALONE_TOOLCHAIN --android-arch $SWIFT_ARCH
|
2021-01-14 16:12:45 +01:00
|
|
|
--android-icu-uc $TERMUX_PREFIX/lib/libicuuc.so
|
2020-09-23 22:16:17 +02:00
|
|
|
--android-icu-uc-include $TERMUX_PREFIX/include/
|
|
|
|
--android-icu-i18n $TERMUX_PREFIX/lib/libicui18n.so
|
|
|
|
--android-icu-i18n-include $TERMUX_PREFIX/include/
|
|
|
|
--android-icu-data $TERMUX_PREFIX/lib/libicudata.so --build-toolchain-only
|
2020-11-06 17:02:29 +01:00
|
|
|
--skip-local-build --skip-local-host-install
|
2021-07-04 19:15:47 +02:00
|
|
|
--cross-compile-hosts=android-$SWIFT_ARCH
|
|
|
|
--cross-compile-deps-path=$(dirname $TERMUX_PREFIX)
|
2021-06-29 10:14:04 +02:00
|
|
|
--native-swift-tools-path=$SWIFT_BINDIR
|
2021-09-29 15:27:59 +02:00
|
|
|
--native-clang-tools-path=$SWIFT_BINDIR"
|
2020-06-13 14:45:59 +02:00
|
|
|
fi
|
|
|
|
|
2020-04-30 13:56:12 +02:00
|
|
|
SWIFT_BUILD_ROOT=$TERMUX_PKG_BUILDDIR $TERMUX_PKG_SRCDIR/swift/utils/build-script \
|
2021-07-04 19:15:47 +02:00
|
|
|
$SWIFT_BUILD_FLAGS --xctest -b -p --swift-driver --sourcekit-lsp \
|
|
|
|
--android-api-level $TERMUX_PKG_API_LEVEL \
|
2021-01-14 16:12:45 +01:00
|
|
|
--build-swift-static-stdlib --swift-install-components=$SWIFT_COMPONENTS \
|
|
|
|
--llvm-install-components=IndexStore --install-llvm --install-swift \
|
2020-09-07 18:23:03 +02:00
|
|
|
--install-libdispatch --install-foundation --install-xctest --install-llbuild \
|
2021-07-04 19:15:47 +02:00
|
|
|
--install-swiftpm --install-swift-driver --install-sourcekit-lsp
|
2020-02-17 18:24:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_make_install() {
|
2020-06-13 14:45:59 +02:00
|
|
|
rm $TERMUX_PREFIX/lib/swift/pm/llbuild/libllbuild.so
|
2020-07-28 09:48:36 +02:00
|
|
|
rm $TERMUX_PREFIX/lib/swift/android/lib{dispatch,BlocksRuntime}.so
|
2020-06-13 14:45:59 +02:00
|
|
|
|
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
2021-07-04 19:15:47 +02:00
|
|
|
rm $TERMUX_PREFIX/swiftpm-android-$SWIFT_ARCH.json
|
2020-09-07 18:23:03 +02:00
|
|
|
mv $TERMUX_PREFIX/glibc-native.modulemap \
|
2020-09-23 22:16:17 +02:00
|
|
|
$TERMUX_PREFIX/lib/swift/android/$SWIFT_ARCH/glibc.modulemap
|
2020-02-17 18:24:10 +01:00
|
|
|
fi
|
|
|
|
}
|