-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·174 lines (130 loc) · 2.75 KB
/
build.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/sh
LUA=moonjit
ONIG=onig-5.9.2
LREX=lrexlib-2.6.0
LPTY=lpty-1.2.1-1
set -e
SYSTEM=`uname`
if [ "$SYSTEM" = "Linux" ]
then
SYSTEM="linux"
elif [ "$SYSTEM" = "Darwin" ]
then
SYSTEM="osx"
export MACOSX_DEPLOYMENT_TARGET="10.7"
else
echo Unsupported system: $SYSTEM
exit -1
fi
BRATPATH=`pwd`
SRC=$BRATPATH/src/$SYSTEM
COMMON=$BRATPATH/src/common
LIB=$BRATPATH/lib
STDLIB=$BRATPATH/stdlib
export LUA_SRC_PATH=$BRATPATH/bin/lua/
export LUA_INC_PATH=$BRATPATH/bin/lua/include/moonjit-2.3
export BRAT_LIB_PATH=$LIB
export PATH=$LUA_SRC_PATH/bin:$PATH
cd $SRC
echo Building Lua
#Clear out existing LuaJIT
rm -rf $BRATPATH/bin/lua
#Build Lua
cd $COMMON/$LUA
export DEFAULT_CC=clang
git submodule init
git submodule update
make PREFIX=$BRATPATH/bin/lua
#Copy to bin/lua
make install PREFIX=$BRATPATH/bin/lua
mv -f $BRATPATH/bin/lua/bin/luajit $BRATPATH/bin/lua/bin/lua
#Dev versions of moonjit get this wrong
ln -s $BRATPATH/bin/lua/share/moonjit-2.3.0-dev/ $BRATPATH/bin/lua/share/moonjit-2.2.0
echo Building Oniguruma
cd $COMMON/$ONIG
./configure && make
if [ "$SYSTEM" = "osx" ]
then
#Copy to lib/
cp -f .libs/libonig.2.0.0.dylib $LIB/
#Do symbolic links
cd $LIB
ln -s -f libonig.2.0.0.dylib libonig.2.dylib
ln -s -f libonig.2.0.0.dylib libonig.dylib
elif [ "$SYSTEM" = "linux" ]
then
#Copy to lib/
cp -f .libs/libonig.so.2.0.0 $LIB
#Do symbolic links
cd $LIB
ln -s -f libonig.so.2.0.0 libonig.so.2
ln -s -f libonig.so.2.0.0 libonig.so
fi
echo Building lrexlib
cd $COMMON/$LREX
make
#Copy lrexlib to lib/
cp -f src/oniguruma/rex_onig.so.2.6 $LIB
#cp -f src/onigurum/librex_onig.a $LIB
cd $LIB
ln -s -f rex_onig.so.2.6 rex_onig.so
echo Building luafilesystem
cd $SRC/luafilesystem
make
cp -f src/lfs.so $LIB
echo Building md5
cd $SRC/md5
make
cp -f md5.so $LIB
echo Building linenoise
cd $COMMON/linenoise
if [ "$SYSTEM" = "linux" ]
then
gcc -fPIC -shared linenoise.c -o liblinenoise.so
mv -f liblinenoise.so $LIB/
elif [ "$SYSTEM" = "osx" ]
then
gcc -bundle -undefined dynamic_lookup linenoise.c -o liblinenoise.dylib
mv -f liblinenoise.dylib $LIB/
fi
echo Building lpty
cd $SRC/$LPTY
make
cp -f lpty.so $LIB
echo Cleaning up...
cd $COMMON/$LUA
make clean
cd $COMMON/$ONIG
make clean
rm -rf $SRC/$ONIG/.deps
cd $COMMON/$LREX
make clean
cd $SRC/luafilesystem
make clean
cd $SRC/md5
make clean
cd $SRC/$LPTY
make clean
cd $BRATPATH
set +e
echo Building Brat libraries with minibrat
for f in stdlib/parser/*.brat; do
echo - $f
./minibrat $f
done
for f in stdlib/*.brat; do
echo - $f
./minibrat $f
done
echo Building Brat libraries with fresh Brat
for f in stdlib/parser/*.brat; do
echo - $f
./brat -f $f
done
for f in stdlib/*.brat; do
echo - $f
./brat -f $f
done
set -e
echo Running Brat tests
./brat test/test.brat