Skip to content

Instantly share code, notes, and snippets.

@cattokomo
Last active March 15, 2024 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cattokomo/7f25b518e3ce22f7abe4d1bb11001628 to your computer and use it in GitHub Desktop.
Save cattokomo/7f25b518e3ce22f7abe4d1bb11001628 to your computer and use it in GitHub Desktop.
Install Luvit in Termux

Install Luvit in Termux

An easy way to (build and) install Luvit into Termux


Run this code below:

curl -LO https://gist.github.com/UrNightmaree/7f25b518e3ce22f7abe4d1bb11001628/raw/d467b2563aab906b45a66fa6c7bf172b23b1b5d7/install-luvit-for-termux.sh
# wget is also works if you don't want to use curl
bash install-luvit-for-termux.sh

Or use the unsafe method:

curl -Lo- https://gist.github.com/UrNightmaree/7f25b518e3ce22f7abe4d1bb11001628/raw/d467b2563aab906b45a66fa6c7bf172b23b1b5d7/install-luvit-for-termux.sh | bash

After that, there should be luvit, luvi and lit binary in your current path ($PWD or output of pwd). You just need to put it into $PATH (recommended add $HOME/.local/bin into $PATH and put the binaries into $HOME/.local/bin)

#!/usr/bin/env bash
# shellcheck disable=SC2059,SC2016
# replace default echo
_echo() { printf "$*\n"; }
cleanup() {
IS_SIGINT="${IS_SIGINT:-true}"
_echo "cleaning up..."
rm -fr {luvit,luvi,lit}-build
"$IS_SIGINT" && exit 1
}
_echo "installing build dependencies..."
trap cleanup SIGINT
pkg i clang make cmake binutils -y
for repo in https://github.com/luvit/{luvit,luvi,lit}; do
git clone "$repo" --recursive "${repo##*/}-build"
done
BUILD_DIR="${PWD:-$(pwd)}"
cd luvi-build || exit 1
# build luvi
_echo "building luvi..."
LUVI_BUILD_TYPE="${1:-regular}"
NPROC_FLAG="-j$(nproc)"
if [[ "$LUVI_BUILD_TYPE" = 'regular' || "$LUVI_BUILD_TYPE" = 'tiny' ]]; then
make "$LUVI_BUILD_TYPE" "$NPROC_FLAG" || exit 1
echo
fi
make luvi "$NPROC_FLAG" || exit 1
mv build/luvi "$BUILD_DIR"
cd "$BUILD_DIR" || exit 1
cd lit-build || exit 1
# build lit
_echo "building lit..."
"$BUILD_DIR"/luvi . -- make . ./lit "$BUILD_DIR"/luvi || exit 1
mv lit "$BUILD_DIR"
cd "$BUILD_DIR" || exit 1
cd luvit-build || exit 1
# build luvit
_echo "building luvit..."
"$BUILD_DIR"/lit make . ./luvit "$BUILD_DIR"/luvi || exit 1
mv luvit "$BUILD_DIR"
cd "$BUILD_DIR" || exit 1
# cleanup
IS_SIGINT='false' cleanup
_echo "installation successful!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment