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"
|
|
|
|
TERMUX_PKG_VERSION=5.3
|
2020-10-01 21:18:03 +02: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
|
2020-09-07 18:23:03 +02:00
|
|
|
TERMUX_PKG_SHA256=f9e5bd81441c4ec13dd9ea290e2d7b8fe9b30ef66ad68947481022ea5179f83a
|
2020-02-17 18:24:10 +01:00
|
|
|
TERMUX_PKG_HOSTBUILD=true
|
2020-07-10 08:05:58 +02:00
|
|
|
TERMUX_PKG_DEPENDS="binutils-gold, clang, libc++, ndk-sysroot, libandroid-glob, libandroid-spawn, libcurl, libicu, libicu-static, libsqlite, libuuid, libxml2, libdispatch, llbuild"
|
2020-02-17 18:24:10 +01:00
|
|
|
TERMUX_PKG_BUILD_DEPENDS="cmake, ninja, perl, pkg-config, python2, rsync"
|
2020-09-23 22:16:17 +02:00
|
|
|
TERMUX_PKG_BLACKLISTED_ARCHES="i686, x86_64"
|
2020-02-17 18:24:10 +01:00
|
|
|
TERMUX_PKG_NO_STATICSPLIT=true
|
|
|
|
|
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
|
2020-07-28 09:48:36 +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
|
|
|
|
|
2020-07-16 23:58:48 +02:00
|
|
|
termux_step_post_get_source() {
|
2020-02-17 18:24:10 +01:00
|
|
|
if [ "$TERMUX_PKG_QUICK_REBUILD" = "false" ]; then
|
|
|
|
# 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
|
2020-09-07 18:23:03 +02:00
|
|
|
library_checksums[swift-cmark]=a1982e4407bc70a07c86e2cacf0727215d5eae82cdae9eacad32298f3e798b5c
|
|
|
|
library_checksums[llvm-project]=ccf263a8e8b82ae3d904d69ac37b7e239bf0511071540216e75cb2144d812446
|
|
|
|
library_checksums[swift-corelibs-libdispatch]=6805b555aab65d740fccaa99570fd29b32efa6c310fd42524913e44509dc4969
|
|
|
|
library_checksums[swift-corelibs-foundation]=f42906de3d21db10d7847786fc423c7d3318c70f6a31bb36ee172aff4fb9cdaf
|
|
|
|
library_checksums[swift-corelibs-xctest]=f12c8d26e2280f2aba7a9c69c9371050f936282114b4e4a5474625fec0ca8312
|
|
|
|
library_checksums[swift-llbuild]=6fddae33feb77cc13c797069cb91ac091af54cb6b267267f0de2bb45ceef1b78
|
|
|
|
library_checksums[swift-package-manager]=bc91ed638457bbf87317c610657c57c94715c7cb70ba680d9c6a067ff0962e06
|
2020-02-17 18:24:10 +01:00
|
|
|
|
|
|
|
for library in "${!library_checksums[@]}"; do \
|
|
|
|
termux_download \
|
|
|
|
https://github.com/apple/$library/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz \
|
|
|
|
$TERMUX_PKG_CACHEDIR/$library-$TERMUX_PKG_VERSION.tar.gz \
|
|
|
|
${library_checksums[$library]}
|
|
|
|
tar xf $TERMUX_PKG_CACHEDIR/$library-$TERMUX_PKG_VERSION.tar.gz
|
2020-05-09 13:09:43 +02:00
|
|
|
mv $library-swift-${TERMUX_PKG_VERSION}-$SWIFT_RELEASE $library
|
2020-02-17 18:24:10 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
mv swift-cmark cmark
|
|
|
|
mv swift-llbuild llbuild
|
|
|
|
mv swift-package-manager swiftpm
|
|
|
|
|
2020-04-30 13:56:12 +02:00
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
|
|
|
termux_download \
|
2020-07-28 09:48:36 +02:00
|
|
|
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 \
|
2020-09-07 18:23:03 +02:00
|
|
|
acd424635c93cede10526d4de1e55bd429e30c14e85f75b5562397800ca5a685
|
2020-04-30 13:56:12 +02:00
|
|
|
fi
|
2020-02-17 18:24:10 +01:00
|
|
|
fi
|
2020-09-07 18:23:03 +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-02-17 18:24:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_host_build() {
|
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
|
|
|
termux_setup_cmake
|
|
|
|
termux_setup_ninja
|
|
|
|
termux_setup_standalone_toolchain
|
|
|
|
|
2020-09-07 18:23:03 +02:00
|
|
|
# Natively compile llvm-tblgen and some other files needed later.
|
2020-02-17 18:24:10 +01:00
|
|
|
SWIFT_BUILD_ROOT=$TERMUX_PKG_BUILDDIR $TERMUX_PKG_SRCDIR/swift/utils/build-script \
|
2020-09-07 18:23:03 +02:00
|
|
|
-R --no-assertions -j $TERMUX_MAKE_PROCESSES $SWIFT_PATH_FLAGS \
|
|
|
|
--skip-build-cmark --skip-build-llvm --skip-build-swift \
|
|
|
|
--host-cc=$TERMUX_STANDALONE_TOOLCHAIN/bin/clang \
|
|
|
|
--host-cxx=$TERMUX_STANDALONE_TOOLCHAIN/bin/clang++
|
|
|
|
|
|
|
|
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() {
|
2020-09-23 22:16:17 +02:00
|
|
|
export SWIFT_ARCH=$TERMUX_ARCH
|
|
|
|
test $SWIFT_ARCH == 'arm' && SWIFT_ARCH='armv7'
|
2020-02-17 18:24:10 +01:00
|
|
|
if [ "$TERMUX_PKG_QUICK_REBUILD" = "false" ]; then
|
|
|
|
cd llbuild
|
|
|
|
# A single patch needed from the existing llbuild package
|
|
|
|
patch -p1 < $TERMUX_PKG_BUILDER_DIR/../llbuild/lib-llvm-Support-CmakeLists.txt.patch
|
|
|
|
|
2020-04-30 13:56:12 +02:00
|
|
|
cd ../llvm-project
|
|
|
|
patch -p2 < $TERMUX_PKG_BUILDER_DIR/../libllvm/tools-clang-lib-Driver-ToolChain.cpp.patch
|
|
|
|
cd llvm
|
|
|
|
patch -p1 < $TERMUX_PKG_BUILDER_DIR/../libllvm/include-llvm-ADT-Triple.h.patch
|
2020-07-07 20:06:41 +02:00
|
|
|
cd ../..
|
2020-04-30 13:56:12 +02:00
|
|
|
|
2020-08-21 08:38:55 +02:00
|
|
|
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" \
|
2020-06-13 14:45:59 +02:00
|
|
|
$TERMUX_PKG_BUILDER_DIR/swiftpm-Utilities-bootstrap | \
|
2020-08-21 08:38:55 +02:00
|
|
|
sed "s%\@TERMUX_PKG_BUILDDIR\@%${TERMUX_PKG_BUILDDIR}%g" | \
|
2020-09-23 22:16:17 +02:00
|
|
|
sed "s%\@SWIFT_ARCH\@%${SWIFT_ARCH}%g" | patch -p1
|
2020-08-21 08:38:55 +02:00
|
|
|
|
2020-09-07 18:23:03 +02:00
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
|
|
|
sed "s%\@TERMUX_STANDALONE_TOOLCHAIN\@%${TERMUX_STANDALONE_TOOLCHAIN}%g" \
|
|
|
|
$TERMUX_PKG_BUILDER_DIR/swiftpm-android-flags.json | \
|
|
|
|
sed "s%\@CCTERMUX_HOST_PLATFORM\@%${CCTERMUX_HOST_PLATFORM}%g" | \
|
|
|
|
sed "s%\@TERMUX_HOST_PLATFORM\@%${TERMUX_HOST_PLATFORM}%g" | \
|
|
|
|
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" | \
|
2020-09-23 22:16:17 +02:00
|
|
|
sed "s%\@SWIFT_ARCH\@%${SWIFT_ARCH}%g" > $TERMUX_PKG_BUILDDIR/swiftpm-android-flags.json
|
2020-09-07 18:23:03 +02:00
|
|
|
fi
|
2020-02-17 18:24:10 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_make() {
|
2020-06-13 14:45:59 +02:00
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
2020-09-07 18:23:03 +02:00
|
|
|
export TERMUX_SWIFTPM_FLAGS="-target $CCTERMUX_HOST_PLATFORM \
|
|
|
|
-sdk $TERMUX_STANDALONE_TOOLCHAIN/sysroot \
|
2020-06-13 14:45:59 +02:00
|
|
|
-L$TERMUX_STANDALONE_TOOLCHAIN/lib/gcc/$TERMUX_HOST_PLATFORM/4.9.x \
|
|
|
|
-tools-directory $TERMUX_STANDALONE_TOOLCHAIN/$TERMUX_HOST_PLATFORM/bin \
|
2020-07-07 20:06:41 +02:00
|
|
|
-Xlinker -rpath -Xlinker $TERMUX_PREFIX/lib"
|
2020-09-07 18:23:03 +02:00
|
|
|
export TERMUX_SWIFT_FLAGS="$TERMUX_SWIFTPM_FLAGS -resource-dir \
|
2020-09-23 22:16:17 +02:00
|
|
|
$TERMUX_PKG_BUILDDIR/swift-android-$SWIFT_ARCH/lib/swift"
|
2020-07-28 09:48:36 +02:00
|
|
|
export HOST_SWIFTC="$SWIFT_BINDIR/swiftc"
|
2020-09-23 22:16:17 +02:00
|
|
|
SWIFT_BUILD_FLAGS="$SWIFT_BUILD_FLAGS --android --android-ndk $TERMUX_STANDALONE_TOOLCHAIN
|
|
|
|
--android-arch $SWIFT_ARCH --android-api-level $TERMUX_PKG_API_LEVEL
|
|
|
|
--android-icu-uc $TERMUX_PREFIX/lib/libicuuc.so
|
|
|
|
--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
|
|
|
|
--skip-local-build --skip-local-host-install --build-runtime-with-host-compiler
|
|
|
|
--cross-compile-hosts=android-$SWIFT_ARCH --cross-compile-deps-path=$TERMUX_PREFIX
|
|
|
|
--native-swift-tools-path=$SWIFT_BINDIR
|
|
|
|
--native-clang-tools-path=$TERMUX_STANDALONE_TOOLCHAIN/bin"
|
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 \
|
2020-09-07 18:23:03 +02:00
|
|
|
$SWIFT_BUILD_FLAGS --xctest -b -p --build-swift-static-stdlib --install-swift \
|
|
|
|
--swift-install-components=$SWIFT_COMPONENTS --llvm-install-components=IndexStore \
|
|
|
|
--install-libdispatch --install-foundation --install-xctest --install-llbuild \
|
|
|
|
--install-swiftpm
|
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
|
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
|
|
|
|
}
|