2017-04-09 06:15:06 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
2019-06-09 17:58:35 +00:00
|
|
|
# vim: ft=bash sw=2 ts=2
|
|
|
|
|
2017-04-09 06:15:06 +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".
|
2017-04-09 06:15:06 +00:00
|
|
|
# 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"
|
2017-04-09 06:15:06 +00:00
|
|
|
LUAJIT_BASE="LuaJIT-$LUAJIT_VERSION"
|
|
|
|
|
|
|
|
source .travis/platform.sh
|
|
|
|
|
|
|
|
LUA_HOME_DIR=$TRAVIS_BUILD_DIR/install/lua
|
|
|
|
|
|
|
|
LR_HOME_DIR=$TRAVIS_BUILD_DIR/install/luarocks
|
|
|
|
|
|
|
|
mkdir $HOME/.lua
|
|
|
|
|
|
|
|
LUAJIT="no"
|
|
|
|
|
|
|
|
if [ "$PLATFORM" == "macosx" ]; then
|
|
|
|
if [ "$LUA" == "luajit" ]; then
|
|
|
|
LUAJIT="yes";
|
|
|
|
fi
|
|
|
|
if [ "$LUA" == "luajit2.0" ]; then
|
|
|
|
LUAJIT="yes";
|
|
|
|
fi
|
|
|
|
if [ "$LUA" == "luajit2.1" ]; then
|
|
|
|
LUAJIT="yes";
|
|
|
|
fi;
|
|
|
|
elif [ "$(expr substr $LUA 1 6)" == "luajit" ]; then
|
|
|
|
LUAJIT="yes";
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "$LUA_HOME_DIR"
|
|
|
|
|
|
|
|
if [ "$LUAJIT" == "yes" ]; then
|
|
|
|
|
|
|
|
if [ "$LUA" == "luajit" ]; then
|
2019-06-09 17:43:12 +00:00
|
|
|
curl -LSs https://github.com/LuaJIT/LuaJIT/archive/v$LUAJIT_VERSION.tar.gz | tar xz;
|
2017-04-09 06:15:06 +00:00
|
|
|
else
|
|
|
|
git clone https://github.com/LuaJIT/LuaJIT.git $LUAJIT_BASE;
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $LUAJIT_BASE
|
|
|
|
|
|
|
|
if [ "$LUA" == "luajit2.1" ]; then
|
|
|
|
git checkout v2.1;
|
|
|
|
# force the INSTALL_TNAME to be luajit
|
|
|
|
perl -i -pe 's/INSTALL_TNAME=.+/INSTALL_TNAME= luajit/' Makefile
|
|
|
|
fi
|
|
|
|
|
|
|
|
make && make install PREFIX="$LUA_HOME_DIR"
|
|
|
|
|
|
|
|
ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/luajit
|
|
|
|
ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/lua;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if [ "$LUA" == "lua5.1" ]; then
|
2019-06-09 17:32:07 +00:00
|
|
|
suff="ftp/lua-5.1.5.tar.gz"
|
2017-04-09 06:15:06 +00:00
|
|
|
elif [ "$LUA" == "lua5.2" ]; then
|
2019-06-09 17:32:07 +00:00
|
|
|
suff="ftp/lua-5.2.4.tar.gz"
|
2017-04-09 06:15:06 +00:00
|
|
|
elif [ "$LUA" == "lua5.3" ]; then
|
2019-06-09 17:32:07 +00:00
|
|
|
suff="ftp/lua-5.3.5.tar.gz"
|
2019-06-09 17:03:56 +00:00
|
|
|
elif [ "$LUA" == "lua5.4" ]; then
|
2019-06-09 17:32:07 +00:00
|
|
|
suff="work/lua-5.4.0-alpha-rc2.tar.gz"
|
2017-04-09 06:15:06 +00:00
|
|
|
fi
|
2019-06-09 17:32:07 +00:00
|
|
|
|
|
|
|
mkdir lua_build
|
|
|
|
curl -LSs http://www.lua.org/"${suff}" | tar xz -C lua_build --strip-components=1
|
|
|
|
cd lua_build
|
2017-04-09 06:15:06 +00:00
|
|
|
|
|
|
|
# Build Lua without backwards compatibility for testing
|
2019-06-09 17:32:07 +00:00
|
|
|
perl -i -pe 's/-DLUA_COMPAT_(ALL|5_[0-9])//' src/Makefile
|
2017-04-09 06:15:06 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
cd $TRAVIS_BUILD_DIR
|
|
|
|
|
|
|
|
lua -v
|
|
|
|
|
|
|
|
LUAROCKS_BASE=luarocks-$LUAROCKS
|
|
|
|
|
2019-06-09 17:32:07 +00:00
|
|
|
curl -LSs https://luarocks.github.io/luarocks/releases/$LUAROCKS_BASE.tar.gz | tar xz
|
2017-04-09 06:15:06 +00:00
|
|
|
|
|
|
|
cd $LUAROCKS_BASE
|
|
|
|
|
|
|
|
if [ "$LUA" == "luajit" ]; then
|
2019-06-09 17:43:12 +00:00
|
|
|
export LUA_INCDIR="$LUA_HOME_DIR/include/luajit-2.0"
|
2017-04-09 06:15:06 +00:00
|
|
|
elif [ "$LUA" == "luajit2.0" ]; then
|
2019-06-09 17:43:12 +00:00
|
|
|
export LUA_INCDIR="$LUA_HOME_DIR/include/luajit-2.0"
|
2017-04-09 06:15:06 +00:00
|
|
|
elif [ "$LUA" == "luajit2.1" ]; then
|
2019-06-09 17:43:12 +00:00
|
|
|
export LUA_INCDIR="$LUA_HOME_DIR/include/luajit-2.1"
|
2017-04-09 06:15:06 +00:00
|
|
|
fi
|
|
|
|
|
2019-06-09 17:45:55 +00:00
|
|
|
./configure --with-lua="$LUA_HOME_DIR" --prefix="$LR_HOME_DIR"
|
2017-04-09 06:15:06 +00:00
|
|
|
make build && make install
|
|
|
|
|
|
|
|
ln -s $LR_HOME_DIR/bin/luarocks $HOME/.lua/luarocks
|
|
|
|
|
|
|
|
cd $TRAVIS_BUILD_DIR
|
|
|
|
|
|
|
|
luarocks --version
|
|
|
|
|
|
|
|
rm -rf $LUAROCKS_BASE
|
|
|
|
|
|
|
|
if [ "$LUAJIT" == "yes" ]; then
|
|
|
|
rm -rf $LUAJIT_BASE;
|
2019-06-09 17:58:35 +00:00
|
|
|
else
|
|
|
|
rm -rf lua_build;
|
2017-04-09 06:15:06 +00:00
|
|
|
fi
|