Skip to content

Commit cda23fd

Browse files
committed
Lua Travis
1 parent 7fe8387 commit cda23fd

File tree

7 files changed

+163
-43
lines changed

7 files changed

+163
-43
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ env:
77
- LUA=lua5.2
88
- LUA=lua5.3
99
install:
10-
- source .travis/setup.sh
10+
- source .travis/setenv_lua.sh
1111
- luarocks make
1212
script:
1313
- lua tests/travis.lua

.travis/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Alexey Melnichuk
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

.travis/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Thank https://github.com/moteus/lua-travis-example

.travis/platform.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
if [ -z "${PLATFORM:-}" ]; then
2+
PLATFORM=$TRAVIS_OS_NAME;
3+
fi
4+
5+
if [ "$PLATFORM" == "osx" ]; then
6+
PLATFORM="macosx";
7+
fi
8+
9+
if [ -z "$PLATFORM" ]; then
10+
if [ "$(uname)" == "Linux" ]; then
11+
PLATFORM="linux";
12+
else
13+
PLATFORM="macosx";
14+
fi;
15+
fi

.travis/setenv_lua.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export PATH=${PATH}:$HOME/.lua:$HOME/.local/bin:${TRAVIS_BUILD_DIR}/install/luarocks/bin
2+
bash .travis/setup_lua.sh
3+
eval `$HOME/.lua/luarocks path`

.travis/setup.sh

Lines changed: 0 additions & 42 deletions
This file was deleted.

.travis/setup_lua.sh

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#! /bin/bash
2+
3+
# A script for setting up environment for travis-ci testing.
4+
# Sets up Lua and Luarocks.
5+
# LUA must be "lua5.1", "lua5.2" or "luajit".
6+
# luajit2.0 - master v2.0
7+
# luajit2.1 - master v2.1
8+
9+
set -eufo pipefail
10+
11+
LUAJIT_VERSION="2.0.4"
12+
LUAJIT_BASE="LuaJIT-$LUAJIT_VERSION"
13+
14+
source .travis/platform.sh
15+
16+
LUA_HOME_DIR=$TRAVIS_BUILD_DIR/install/lua
17+
18+
LR_HOME_DIR=$TRAVIS_BUILD_DIR/install/luarocks
19+
20+
mkdir $HOME/.lua
21+
22+
LUAJIT="no"
23+
24+
if [ "$PLATFORM" == "macosx" ]; then
25+
if [ "$LUA" == "luajit" ]; then
26+
LUAJIT="yes";
27+
fi
28+
if [ "$LUA" == "luajit2.0" ]; then
29+
LUAJIT="yes";
30+
fi
31+
if [ "$LUA" == "luajit2.1" ]; then
32+
LUAJIT="yes";
33+
fi;
34+
elif [ "$(expr substr $LUA 1 6)" == "luajit" ]; then
35+
LUAJIT="yes";
36+
fi
37+
38+
mkdir -p "$LUA_HOME_DIR"
39+
40+
if [ "$LUAJIT" == "yes" ]; then
41+
42+
if [ "$LUA" == "luajit" ]; then
43+
curl --location https://github.com/LuaJIT/LuaJIT/archive/v$LUAJIT_VERSION.tar.gz | tar xz;
44+
else
45+
git clone https://github.com/LuaJIT/LuaJIT.git $LUAJIT_BASE;
46+
fi
47+
48+
cd $LUAJIT_BASE
49+
50+
if [ "$LUA" == "luajit2.1" ]; then
51+
git checkout v2.1;
52+
# force the INSTALL_TNAME to be luajit
53+
perl -i -pe 's/INSTALL_TNAME=.+/INSTALL_TNAME= luajit/' Makefile
54+
fi
55+
56+
make && make install PREFIX="$LUA_HOME_DIR"
57+
58+
ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/luajit
59+
ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/lua;
60+
61+
else
62+
63+
if [ "$LUA" == "lua5.1" ]; then
64+
curl http://www.lua.org/ftp/lua-5.1.5.tar.gz | tar xz
65+
cd lua-5.1.5;
66+
elif [ "$LUA" == "lua5.2" ]; then
67+
curl http://www.lua.org/ftp/lua-5.2.4.tar.gz | tar xz
68+
cd lua-5.2.4;
69+
elif [ "$LUA" == "lua5.3" ]; then
70+
curl http://www.lua.org/ftp/lua-5.3.3.tar.gz | tar xz
71+
cd lua-5.3.3;
72+
fi
73+
74+
# Build Lua without backwards compatibility for testing
75+
perl -i -pe 's/-DLUA_COMPAT_(ALL|5_2)//' src/Makefile
76+
make $PLATFORM
77+
make INSTALL_TOP="$LUA_HOME_DIR" install;
78+
79+
ln -s $LUA_HOME_DIR/bin/lua $HOME/.lua/lua
80+
ln -s $LUA_HOME_DIR/bin/luac $HOME/.lua/luac;
81+
82+
fi
83+
84+
cd $TRAVIS_BUILD_DIR
85+
86+
lua -v
87+
88+
LUAROCKS_BASE=luarocks-$LUAROCKS
89+
90+
curl --location http://luarocks.org/releases/$LUAROCKS_BASE.tar.gz | tar xz
91+
92+
cd $LUAROCKS_BASE
93+
94+
if [ "$LUA" == "luajit" ]; then
95+
./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR";
96+
elif [ "$LUA" == "luajit2.0" ]; then
97+
./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR";
98+
elif [ "$LUA" == "luajit2.1" ]; then
99+
./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.1" --prefix="$LR_HOME_DIR";
100+
else
101+
./configure --with-lua="$LUA_HOME_DIR" --prefix="$LR_HOME_DIR"
102+
fi
103+
104+
make build && make install
105+
106+
ln -s $LR_HOME_DIR/bin/luarocks $HOME/.lua/luarocks
107+
108+
cd $TRAVIS_BUILD_DIR
109+
110+
luarocks --version
111+
112+
rm -rf $LUAROCKS_BASE
113+
114+
if [ "$LUAJIT" == "yes" ]; then
115+
rm -rf $LUAJIT_BASE;
116+
elif [ "$LUA" == "lua5.1" ]; then
117+
rm -rf lua-5.1.5;
118+
elif [ "$LUA" == "lua5.2" ]; then
119+
rm -rf lua-5.2.4;
120+
elif [ "$LUA" == "lua5.3" ]; then
121+
rm -rf lua-5.3.3;
122+
fi

0 commit comments

Comments
 (0)