-
Notifications
You must be signed in to change notification settings - Fork 1
/
compile.sh
executable file
·56 lines (46 loc) · 1.58 KB
/
compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
#
# NOTE: The user *must* ensure our library versions gets picked up first, for the following reasons:
# - The SQLlite3 library is source packed after it broke compatibility in a release (up to date as of March 7th, 2013)
# - The Lua library is source packed simply to point to our in-tree LuaJIT
# - The go/types library is shamefully hacked because the author was unable to map FuncDecl to FuncType after a new release
set -e
## Helpers:
function make_lib() {
prev="$(pwd)"
cd "$1"
if [[ -e /proc/cpuinfo ]] ; then cores=$(grep -c ^processor /proc/cpuinfo)
else cores=4 ; fi # Guess
make -j$((cores+1))
if [[ "$2" != "" ]] ; then
cp "$2" "$prev/.libs/"
fi
cd "$prev"
}
## Environment set up:
export GOPATH=$GOPATH:"$(pwd)/goal":"$(pwd)/dependencies"
export LIBRARY_PATH=$LIBRARY_PATH:"$(pwd)/.libs"
## Library building:
mkdir -p ".libs"
# Install necessary lua files in .libs:
cp "./goal/goal.lua" "./.libs/"
cp ./goal/extra/*.lua "./.libs/"
cp -r "./dependencies/lua-repl/repl/" "./.libs/"
cp "./dependencies/lua-repl/repl.lua" "./.libs/repl.lua"
cp ./dependencies/*.lua "./.libs/"
# Install necessary library files in .libs:
make_lib "./dependencies/lua-yaml" "yaml.so"
make_lib "./dependencies/lua-linenoise" "linenoise.so"
make_lib "./dependencies/LuaJIT-2.0.2" "src/libluajit.a"
# Go dependencies:
for pkg in \
github.com/aarzilli/golua/lua \
github.com/mattn/go-sqlite3 \
github.com/stevedonovan/luar \
github.com/shavac/readline \
github.com/lib/pq
do
go install $pkg
done
## Compiling GoAL itself:
make_lib ./goal