2018-10-21 02:05:12 +02:00
|
|
|
TERMUX_PKG_HOMEPAGE=https://www.rust-lang.org/
|
|
|
|
TERMUX_PKG_DESCRIPTION="Systems programming language focused on safety, speed and concurrency"
|
2019-01-21 13:53:58 +01:00
|
|
|
TERMUX_PKG_LICENSE="MIT"
|
2018-10-30 22:17:57 +01:00
|
|
|
TERMUX_PKG_MAINTAINER="Kevin Cotugno @kcotugno"
|
2020-06-11 04:16:15 +02:00
|
|
|
TERMUX_PKG_VERSION=1.45.0
|
2018-11-30 22:46:37 +01:00
|
|
|
TERMUX_PKG_SRCURL=https://static.rust-lang.org/dist/rustc-$TERMUX_PKG_VERSION-src.tar.xz
|
2020-06-11 04:16:15 +02:00
|
|
|
TERMUX_PKG_SHA256=c436034db42bc0ea7e7f32816ac6555b70d1f76c834407597966dfaf2ec839d6
|
2019-10-26 07:46:24 +02:00
|
|
|
TERMUX_PKG_DEPENDS="libc++, clang, openssl, lld, zlib, libllvm"
|
2020-07-27 10:25:16 +02:00
|
|
|
TERMUX_PKG_REVISION=2
|
2020-07-09 13:50:21 +02:00
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_configure() {
|
2018-10-21 02:05:12 +02:00
|
|
|
termux_setup_cmake
|
2018-11-30 22:46:37 +01:00
|
|
|
termux_setup_rust
|
2018-12-10 01:18:07 +01:00
|
|
|
|
2018-11-30 22:46:37 +01:00
|
|
|
# it breaks building rust tools without doing this because it tries to find
|
2018-12-10 01:18:07 +01:00
|
|
|
# ../lib from bin location:
|
2019-03-24 11:21:32 +01:00
|
|
|
# this is about to get ugly but i have to make sure a rustc in a proper bin lib
|
|
|
|
# configuration is used otherwise it fails a long time into the build...
|
2019-06-21 09:55:11 +02:00
|
|
|
# like 30 to 40 + minutes ... so lets get it right
|
2019-03-24 11:21:32 +01:00
|
|
|
|
2019-10-25 13:30:07 +02:00
|
|
|
# upstream only tests build ver one version behind $TERMUX_PKG_VERSION
|
2020-06-11 04:16:15 +02:00
|
|
|
local BOOTSTRAP_VERSION=1.44.1
|
2020-07-01 13:58:08 +02:00
|
|
|
rustup install $BOOTSTRAP_VERSION
|
|
|
|
rustup default $BOOTSTRAP_VERSION-x86_64-unknown-linux-gnu
|
|
|
|
export PATH=$HOME/.rustup/toolchains/$BOOTSTRAP_VERSION-x86_64-unknown-linux-gnu/bin:$PATH
|
2018-11-30 22:46:37 +01:00
|
|
|
local RUSTC=$(which rustc)
|
2018-12-10 01:18:07 +01:00
|
|
|
local CARGO=$(which cargo)
|
2018-10-21 02:05:12 +02:00
|
|
|
|
|
|
|
sed "s%\\@TERMUX_PREFIX\\@%$TERMUX_PREFIX%g" \
|
|
|
|
$TERMUX_PKG_BUILDER_DIR/config.toml \
|
|
|
|
| sed "s%\\@TERMUX_STANDALONE_TOOLCHAIN\\@%$TERMUX_STANDALONE_TOOLCHAIN%g" \
|
2018-11-30 22:46:37 +01:00
|
|
|
| sed "s%\\@triple\\@%$CARGO_TARGET_NAME%g" \
|
|
|
|
| sed "s%\\@RUSTC\\@%$RUSTC%g" \
|
2018-12-10 01:18:07 +01:00
|
|
|
| sed "s%\\@CARGO\\@%$CARGO%g" \
|
2018-10-21 02:05:12 +02:00
|
|
|
> config.toml
|
|
|
|
|
2019-02-12 09:41:30 +01:00
|
|
|
local env_host=$(printf $CARGO_TARGET_NAME | tr a-z A-Z | sed s/-/_/g)
|
2019-04-24 00:39:40 +02:00
|
|
|
export LD_LIBRARY_PATH=$TERMUX_PKG_BUILDDIR/build/x86_64-unknown-linux-gnu/stage2/lib
|
2018-10-30 16:19:19 +01:00
|
|
|
export ${env_host}_OPENSSL_DIR=$TERMUX_PREFIX
|
|
|
|
export X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu
|
|
|
|
export X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR=/usr/include
|
2019-03-21 05:42:58 +01:00
|
|
|
export PKG_CONFIG_ALLOW_CROSS=1
|
2019-01-01 02:37:08 +01:00
|
|
|
# for backtrace-sys
|
|
|
|
export CC_x86_64_unknown_linux_gnu=gcc
|
|
|
|
export CFLAGS_x86_64_unknown_linux_gnu="-O2"
|
2019-04-24 00:39:40 +02:00
|
|
|
unset CC CXX CPP LD CFLAGS CXXFLAGS CPPFLAGS LDFLAGS PKG_CONFIG AR RANLIB
|
2020-03-06 12:20:17 +01:00
|
|
|
# we can't use -L$PREFIX/lib since it breaks things but we need to link against libLLVM-9.so
|
2020-07-27 10:25:16 +02:00
|
|
|
ln -sf $PREFIX/lib/libLLVM-10.0.1.so $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/$TERMUX_PKG_API_LEVEL/
|
2020-03-06 12:20:17 +01:00
|
|
|
|
|
|
|
# rust checks libs in PREFIX/lib because both host and target are x86_64. It then can't find libc.so and libdl.so because rust program doesn't
|
|
|
|
# know where those are. Putting them temporarly in $PREFIX/lib prevents that failure
|
|
|
|
|
2019-10-21 03:52:24 +02:00
|
|
|
if [ $TERMUX_ARCH = "x86_64" ]; then
|
|
|
|
cp $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/x86_64-linux-android/$TERMUX_PKG_API_LEVEL/libc.so $TERMUX_PREFIX/lib/
|
|
|
|
cp $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/x86_64-linux-android/$TERMUX_PKG_API_LEVEL/libdl.so $TERMUX_PREFIX/lib/
|
2020-03-06 12:20:17 +01:00
|
|
|
mv $TERMUX_PREFIX/lib/libtinfo.so.6 $TERMUX_PREFIX/lib/libtinfo.so.6.tmp
|
2020-07-23 16:29:57 +02:00
|
|
|
export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu/:/data/data/com.termux/files/usr/lib:$TERMUX_PKG_BUILDDIR/build/x86_64-unknown-linux-gnu/stage2/lib
|
2019-10-21 03:52:24 +02:00
|
|
|
fi
|
2018-10-21 02:05:12 +02:00
|
|
|
}
|
|
|
|
|
2019-10-21 04:07:25 +02:00
|
|
|
termux_step_make() {
|
|
|
|
return 0;
|
|
|
|
}
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_make_install() {
|
2020-07-23 16:29:57 +02:00
|
|
|
if [ $TERMUX_ARCH = "x86_64" ]; then
|
|
|
|
mv $TERMUX_PREFIX ${TERMUX_PREFIX}a
|
|
|
|
$TERMUX_PKG_SRCDIR/x.py build cargo || $TERMUX_PKG_SRCDIR/x.py build rls || $TERMUX_PKG_SRCDIR/x.py build miri || $TERMUX_PKG_SRCDIR/x.py build cargo-miri || $TERMUX_PKG_SRCDIR/x.py build rustfmt || true
|
|
|
|
mv ${TERMUX_PREFIX}a ${TERMUX_PREFIX}
|
|
|
|
fi
|
2020-05-09 04:11:43 +02:00
|
|
|
$TERMUX_PKG_SRCDIR/x.py install --stage 2 --host $CARGO_TARGET_NAME --target $CARGO_TARGET_NAME --target wasm32-unknown-unknown || bash
|
|
|
|
$TERMUX_PKG_SRCDIR/x.py dist rustc-dev --host $CARGO_TARGET_NAME --target $CARGO_TARGET_NAME --target wasm32-unknown-unknown || bash
|
2019-12-19 23:12:16 +01:00
|
|
|
tar xvf build/dist/rustc-dev-$TERMUX_PKG_VERSION-$CARGO_TARGET_NAME.tar.gz
|
|
|
|
./rustc-dev-$TERMUX_PKG_VERSION-$CARGO_TARGET_NAME/install.sh --prefix=$TERMUX_PREFIX
|
|
|
|
|
2018-11-30 22:46:37 +01:00
|
|
|
cd "$TERMUX_PREFIX/lib"
|
2019-10-21 03:52:24 +02:00
|
|
|
rm -f libc.so libdl.so
|
2020-03-06 12:20:17 +01:00
|
|
|
if [ $TERMUX_ARCH = "x86_64" ]; then
|
|
|
|
mv $TERMUX_PREFIX/lib/libtinfo.so.6.tmp $TERMUX_PREFIX/lib/libtinfo.so.6
|
|
|
|
fi
|
|
|
|
|
2018-12-10 01:18:07 +01:00
|
|
|
ln -sf rustlib/$CARGO_TARGET_NAME/lib/*.so .
|
2018-11-30 22:46:37 +01:00
|
|
|
ln -sf $TERMUX_PREFIX/bin/lld $TERMUX_PREFIX/bin/rust-lld
|
2019-12-19 23:12:16 +01:00
|
|
|
|
2019-09-30 20:46:18 +02:00
|
|
|
cd "$TERMUX_PREFIX/lib/rustlib"
|
|
|
|
rm -rf components \
|
|
|
|
install.log \
|
|
|
|
uninstall.sh \
|
|
|
|
rust-installer-version \
|
|
|
|
manifest-* \
|
|
|
|
x86_64-unknown-linux-gnu
|
2020-07-27 10:25:16 +02:00
|
|
|
rm $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/$TERMUX_PKG_API_LEVEL/libLLVM-10.0.1.so
|
2020-03-06 12:20:17 +01:00
|
|
|
|
2018-10-21 02:05:12 +02:00
|
|
|
}
|
2020-03-06 12:20:17 +01:00
|
|
|
termux_step_post_massage() {
|
|
|
|
if [ $TERMUX_ARCH = "x86_64" ]; then
|
|
|
|
rm lib/libtinfo.so.6
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|