fd: Add package (hello second rust package!)

Also extract out rust setup from ripgrep.
This commit is contained in:
Fredrik Fornwall 2018-09-03 23:57:26 +02:00
parent 9e3c6c4a0d
commit 474a295669
3 changed files with 41 additions and 22 deletions

View File

@ -95,6 +95,25 @@ termux_setup_golang() {
( cd "$TERMUX_COMMON_CACHEDIR"; tar xf "$TERMUX_BUILDGO_TAR"; mv go "$TERMUX_BUILDGO_FOLDER"; rm "$TERMUX_BUILDGO_TAR" )
}
# Utility function for rust-using packages to setup a rust toolchain.
termux_setup_rust() {
if [ $TERMUX_ARCH = "arm" ]; then
CARGO_TARGET_NAME=armv7-linux-androideabi
else
CARGO_TARGET_NAME=$TERMUX_ARCH-linux-android
fi
local ENV_NAME=CARGO_TARGET_${CARGO_TARGET_NAME^^}_LINKER
ENV_NAME=${ENV_NAME//-/_}
export $ENV_NAME=$CC
curl https://sh.rustup.rs -sSf > $TERMUX_PKG_TMPDIR/rustup.sh
sh $TERMUX_PKG_TMPDIR/rustup.sh -y
export PATH=$HOME/.cargo/bin:$PATH
rustup target add $CARGO_TARGET_NAME
}
# Utility function to setup a current ninja build system.
termux_setup_ninja() {
local NINJA_VERSION=1.8.2
@ -1016,6 +1035,13 @@ termux_step_make_install() {
else
make -j 1 ${TERMUX_PKG_EXTRA_MAKE_ARGS} ${TERMUX_PKG_MAKE_INSTALL_TARGET}
fi
elif test -f Cargo.toml; then
termux_setup_rust
cargo build --release --target $CARGO_TARGET_NAME
# Once https://github.com/rust-lang/cargo/commit/0774e97da3894f07ed5b6f7db175027a9bc4718b
# is available on master we can use cargo install:
# cargo install --root $TERMUX_PREFIX
# rm $TERMUX_PREFIX/.crates.toml
fi
}

13
packages/fd/build.sh Normal file
View File

@ -0,0 +1,13 @@
TERMUX_PKG_HOMEPAGE=https://github.com/sharkdp/fd
TERMUX_PKG_DESCRIPTION="Simple, fast and user-friendly alternative to find"
TERMUX_PKG_VERSION=7.1.0
TERMUX_PKG_SHA256=9385a55738947f69fd165781598de6c980398c6214a4927fce13a4f7f1e63d4d
TERMUX_PKG_SRCURL=https://github.com/sharkdp/fd/archive/v$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_BUILD_IN_SRC=yes
termux_step_post_make_install() {
cp target/$CARGO_TARGET_NAME/release/fd $TERMUX_PREFIX/bin/fd
mkdir -p $TERMUX_PREFIX/share/man/man1
cp $TERMUX_PKG_SRCDIR/doc/fd.1 $TERMUX_PREFIX/share/man/man1/fd.1
}

View File

@ -5,29 +5,9 @@ TERMUX_PKG_SHA256=871a24ad29a4c5b6d82f6049156db2662e6a9820cca6f361547b8ab8bc1be7
TERMUX_PKG_SRCURL=https://github.com/BurntSushi/ripgrep/archive/$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_BUILD_IN_SRC=yes
termux_step_make() {
# TODO: The below setup should be split up to allow more rust
# packages to be built.
local CARGO_TARGET_NAME=$TERMUX_ARCH-linux-android
if [ $TERMUX_ARCH = "arm" ]; then
CARGO_TARGET_NAME=armv7-linux-androideabi
fi
mkdir .cargo
cat <<-EOF > .cargo/config
[target.$CARGO_TARGET_NAME]
linker = "clang"
EOF
curl https://sh.rustup.rs -sSf > $TERMUX_PKG_TMPDIR/rustup.sh
sh $TERMUX_PKG_TMPDIR/rustup.sh -y
export PATH=$HOME/.cargo/bin:$PATH
rustup target add $CARGO_TARGET_NAME
cargo build --release --target=$CARGO_TARGET_NAME
termux_step_post_make_install() {
cp target/$CARGO_TARGET_NAME/release/rg $TERMUX_PREFIX/bin/rg
mkdir -p $TERMUX_PREFIX/share/man/man1/
cp `find . -name rg.1` $TERMUX_PREFIX/share/man/man1/
}