termux-packages/packages/lua-language-server/build.sh

78 lines
2.2 KiB
Bash
Raw Normal View History

2021-08-10 17:08:17 +02:00
TERMUX_PKG_HOMEPAGE="https://github.com/sumneko/lua-language-server"
TERMUX_PKG_DESCRIPTION="Sumneko Lua Language Server coded in Lua"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="MrAdityaAlok <dev.aditya.alok@gmail.com>"
2021-11-08 10:53:05 +01:00
TERMUX_PKG_VERSION=2.4.7
2021-08-10 17:08:17 +02:00
TERMUX_PKG_SRCURL=https://github.com/sumneko/lua-language-server.git
2021-08-18 13:08:57 +02:00
TERMUX_PKG_GIT_BRANCH="${TERMUX_PKG_VERSION}"
2021-08-10 17:08:17 +02:00
TERMUX_PKG_BUILD_DEPENDS="libandroid-spawn"
TERMUX_PKG_HOSTBUILD=true
TERMUX_PKG_BUILD_IN_SRC=true
2021-08-10 17:08:17 +02:00
2021-10-25 19:44:45 +02:00
# no cpu_relax support present for these archs.
# https://github.com/actboy168/bee.lua/blob/32f65b92739fa236d87fc1b2e7617470d47f0355/bee/thread/spinlock.h#L14
TERMUX_PKG_BLACKLISTED_ARCHES="arm,i686"
_patch() {
if [ "${TERMUX_ON_DEVICE_BUILD}" = true ]; then
current_dir=$(pwd)
cd "${TERMUX_PKG_SRCDIR}"
patch --silent -p1 <"${TERMUX_PKG_BUILDER_DIR}"/android.patch.ondevice.beforehostbuild
cd "${current_dir}"
fi
}
2021-08-10 17:08:17 +02:00
termux_step_host_build() {
_patch
2021-08-10 17:08:17 +02:00
termux_setup_ninja
mkdir 3rd
cp -a "${TERMUX_PKG_SRCDIR}"/3rd/luamake 3rd/
cd 3rd/luamake
2021-08-10 17:08:17 +02:00
./compile/install.sh
}
termux_step_make() {
sed \
-e "s%\@FLAGS\@%${CFLAGS} ${CPPFLAGS}%g" \
-e "s%\@LDFLAGS\@%${LDFLAGS}%g" \
"${TERMUX_PKG_BUILDER_DIR}"/make.lua.diff | patch --silent -p1
"${TERMUX_PKG_HOSTBUILD_DIR}"/3rd/luamake/luamake \
-cc "${CC}" \
-hostos "android"
2021-08-10 17:08:17 +02:00
}
termux_step_make_install() {
local INSTALL_DIR="${TERMUX_PREFIX}/lib/${TERMUX_PKG_NAME}"
2021-08-10 17:08:17 +02:00
cat >"${TERMUX_PREFIX}/bin/${TERMUX_PKG_NAME}" <<-EOF
2021-08-10 17:08:17 +02:00
#!${TERMUX_PREFIX}/bin/bash
# After action of termux-elf-cleaner lua-language-server's binary(ELF) is unable to
# determine its version, so provide it manually.
if [ "\$1" = "--version" ]; then
echo "${TERMUX_PKG_NAME}: ${TERMUX_PKG_VERSION}"
else
TMPPATH=\$(mktemp -d "${TERMUX_PREFIX}/tmp/${TERMUX_PKG_NAME}.XXXX")
2021-08-10 17:08:17 +02:00
exec ${INSTALL_DIR}/bin/Android/${TERMUX_PKG_NAME} \\
--logpath="\${TMPPATH}/log" \\
--metapath="\${TMPPATH}/meta" \\
"\${@}"
fi
2021-08-10 17:08:17 +02:00
EOF
2021-08-10 17:08:17 +02:00
chmod 744 "${TERMUX_PREFIX}/bin/${TERMUX_PKG_NAME}"
2021-08-10 17:08:17 +02:00
install -Dm744 -t "${INSTALL_DIR}"/bin/Android ./bin/Android/"${TERMUX_PKG_NAME}"
install -Dm644 -t "${INSTALL_DIR}" ./{main,debugger}.lua
install -Dm644 -t "${INSTALL_DIR}"/bin/Android ./bin/Android/main.lua
cp -r ./script ./meta ./locale "${INSTALL_DIR}"
2021-08-10 17:08:17 +02:00
}