lua-htmlparser/.travis/setup_lua.sh

110 lines
2.6 KiB
Bash
Raw Permalink Normal View History

#! /bin/bash
2019-06-09 19:02:32 +00:00
# vim: ft=sh sw=2 ts=2
2019-06-09 17:58:35 +00:00
# A script for setting up environment for travis-ci testing.
# Sets up Lua and Luarocks.
2019-06-09 17:03:56 +00:00
# LUA must be "lua5.x" or "luajit".
# luajit2.0 - master v2.0
# luajit2.1 - master v2.1
set -eufo pipefail
2019-06-09 17:03:56 +00:00
LUAJIT_VERSION="2.0.5"
2019-06-09 19:02:32 +00:00
LUAJIT_BASE="LuaJIT-${LUAJIT_VERSION}"
2019-06-09 19:02:32 +00:00
# shellcheck disable=SC1091
source .travis/platform.sh
2019-06-09 19:02:32 +00:00
LUA_HOME_DIR="${TRAVIS_BUILD_DIR}/install/lua"
2019-06-09 19:02:32 +00:00
LR_HOME_DIR="${TRAVIS_BUILD_DIR}/install/luarocks"
2019-06-09 19:02:32 +00:00
mkdir "${HOME}/.lua" -p
LUAJIT="no"
2019-06-09 19:20:22 +00:00
if [ "${LUA:0:6}" == "luajit" ]; then
2019-06-09 19:02:32 +00:00
LUAJIT="yes"
fi
2019-06-09 19:02:32 +00:00
mkdir -p "${LUA_HOME_DIR}"
2019-06-09 19:02:32 +00:00
if [ "${LUAJIT}" == "yes" ]; then
if [ "${LUA}" == "luajit" ]; then
2019-06-09 19:18:40 +00:00
curl -LSs "https://github.com/LuaJIT/LuaJIT/archive/v${LUAJIT_VERSION}.tar.gz" | tar xz
2019-06-09 19:02:32 +00:00
else
2019-06-09 21:22:40 +00:00
LJ_V="${LUA##luajit}"
[[ -z "${LJ_V}" ]] && LJ_V="2.0"
2019-06-09 19:43:06 +00:00
git clone https://github.com/LuaJIT/LuaJIT.git -b "v${LJ_V}" "${LUAJIT_BASE}"
2019-06-09 19:02:32 +00:00
fi
2019-06-09 19:02:32 +00:00
cd "${LUAJIT_BASE}"
2019-06-09 19:02:32 +00:00
if [ "${LUA}" == "luajit2.1" ]; then
2019-06-09 19:18:40 +00:00
# force the INSTALL_TNAME to be luajit
perl -i -pe 's/INSTALL_TNAME=.+/INSTALL_TNAME= luajit/' Makefile
2019-06-09 19:02:32 +00:00
fi
2019-06-09 19:02:32 +00:00
make && make install PREFIX="${LUA_HOME_DIR}"
2019-06-09 19:02:32 +00:00
ln -s "${LUA_HOME_DIR}/bin/luajit" "${HOME}/.lua/luajit"
ln -s "${LUA_HOME_DIR}/bin/luajit" "${HOME}/.lua/lua"
else
2019-06-09 19:02:32 +00:00
if [ "${LUA}" == "lua5.1" ]; then
2019-06-09 19:18:40 +00:00
suff="ftp/lua-5.1.5.tar.gz"
2019-06-09 19:02:32 +00:00
elif [ "${LUA}" == "lua5.2" ]; then
2019-06-09 19:18:40 +00:00
suff="ftp/lua-5.2.4.tar.gz"
2019-06-09 19:02:32 +00:00
elif [ "${LUA}" == "lua5.3" ]; then
2019-06-09 19:18:40 +00:00
suff="ftp/lua-5.3.5.tar.gz"
2019-06-09 19:02:32 +00:00
elif [ "${LUA}" == "lua5.4" ]; then
2019-06-09 19:18:40 +00:00
suff="work/lua-5.4.0-alpha-rc2.tar.gz"
2019-06-09 19:02:32 +00:00
fi
mkdir lua_build -p
curl -LSs "http://www.lua.org/${suff}" | tar xz -C lua_build --strip-components=1
cd lua_build
# Build Lua without backwards compatibility for testing
perl -i -pe 's/-DLUA_COMPAT_(ALL|5_[0-9])//' src/Makefile
make "${PLATFORM}"
make INSTALL_TOP="${LUA_HOME_DIR}" install
ln -s "${LUA_HOME_DIR}/bin/lua" "${HOME}/.lua/lua"
ln -s "${LUA_HOME_DIR}/bin/luac" "${HOME}/.lua/luac"
fi
2019-06-09 19:02:32 +00:00
cd "${TRAVIS_BUILD_DIR}"
lua -v
LUAROCKS_BASE=luarocks-$LUAROCKS
2019-06-09 19:02:32 +00:00
curl -LSs https://luarocks.github.io/luarocks/releases/"${LUAROCKS_BASE}".tar.gz | tar xz
2019-06-09 19:02:32 +00:00
cd "${LUAROCKS_BASE}"
2019-06-09 19:02:32 +00:00
if [ "${LUA}" == "luajit" ]; then
export LUA_INCDIR="${LUA_HOME_DIR}/include/luajit-2.0"
elif [ "${LUA}" == "luajit2.0" ]; then
export LUA_INCDIR="${LUA_HOME_DIR}/include/luajit-2.0"
elif [ "${LUA}" == "luajit2.1" ]; then
export LUA_INCDIR="${LUA_HOME_DIR}/include/luajit-2.1"
fi
2019-06-09 19:02:32 +00:00
./configure --with-lua="${LUA_HOME_DIR}" --prefix="${LR_HOME_DIR}"
make build && make install
2019-06-09 19:02:32 +00:00
ln -s "${LR_HOME_DIR}/bin/luarocks" "${HOME}/.lua/luarocks"
2019-06-09 19:02:32 +00:00
cd "${TRAVIS_BUILD_DIR}"
luarocks --version
2019-06-09 19:02:32 +00:00
rm -rf "${LUAROCKS_BASE}"
2019-06-09 19:02:32 +00:00
if [ "${LUAJIT}" == "yes" ]; then
rm -rf "${LUAJIT_BASE}"
2019-06-09 17:58:35 +00:00
else
2019-06-09 19:02:32 +00:00
rm -rf lua_build
fi