]> git.madduck.net Git - etc/awesome.git/blob - .travis/setup_lua.sh

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

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