2019-02-26 21:33:42 +01:00
|
|
|
termux_setup_rust() {
|
|
|
|
if [ $TERMUX_ARCH = "arm" ]; then
|
|
|
|
CARGO_TARGET_NAME=armv7-linux-androideabi
|
|
|
|
else
|
|
|
|
CARGO_TARGET_NAME=$TERMUX_ARCH-linux-android
|
|
|
|
fi
|
|
|
|
|
2019-08-12 23:16:07 +02:00
|
|
|
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
|
2019-08-06 14:39:42 +02:00
|
|
|
if [ "$(dpkg-query -W -f '${db:Status-Status}\n' rust 2>/dev/null)" != "installed" ]; then
|
|
|
|
echo "Package 'rust' is not installed."
|
|
|
|
echo "You can install it with"
|
|
|
|
echo
|
|
|
|
echo " pkg install rust"
|
|
|
|
echo
|
|
|
|
echo "or build it from source with"
|
|
|
|
echo
|
|
|
|
echo " ./build-package.sh rust"
|
|
|
|
echo
|
|
|
|
echo "Note that package 'rust' is known to be problematic for building on device."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2019-02-26 21:33:42 +01:00
|
|
|
local ENV_NAME=CARGO_TARGET_${CARGO_TARGET_NAME^^}_LINKER
|
|
|
|
ENV_NAME=${ENV_NAME//-/_}
|
|
|
|
export $ENV_NAME=$CC
|
2020-04-28 08:58:40 +02:00
|
|
|
export TARGET_CFLAGS="$CFLAGS $CPPFLAGS"
|
2020-09-04 15:50:17 +02:00
|
|
|
# This was getting applied for the host build of Rust macros or whatever, so
|
|
|
|
# unset it.
|
|
|
|
unset CFLAGS
|
2019-02-26 21:33:42 +01:00
|
|
|
|
|
|
|
curl https://sh.rustup.rs -sSf > $TERMUX_PKG_TMPDIR/rustup.sh
|
2019-04-24 00:39:40 +02:00
|
|
|
|
2021-01-10 13:33:00 +01:00
|
|
|
if [ -z "${TERMUX_RUST_VERSION-}" ]; then
|
2021-01-10 12:16:43 +01:00
|
|
|
TERMUX_RUST_VERSION=$(bash -c ". $TERMUX_SCRIPTDIR/packages/rust/build.sh; echo \$TERMUX_PKG_VERSION")
|
2021-01-10 13:33:00 +01:00
|
|
|
fi
|
2019-04-24 00:39:40 +02:00
|
|
|
|
2021-01-10 12:16:43 +01:00
|
|
|
sh $TERMUX_PKG_TMPDIR/rustup.sh -y --default-toolchain $TERMUX_RUST_VERSION
|
2019-02-26 21:33:42 +01:00
|
|
|
export PATH=$HOME/.cargo/bin:$PATH
|
|
|
|
|
|
|
|
rustup target add $CARGO_TARGET_NAME
|
|
|
|
}
|