forked from lazytiger/go-v8
-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·81 lines (66 loc) · 1.83 KB
/
install.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
#!/bin/bash
hash svn 2>/dev/null || { echo >&2 "You need to install Subversion client."; exit 1; }
# find download tool
download=''
if hash curl 2>/dev/null; then
download='curl -o'
elif hash wget 2>/dev/null; then
download='wget -O'
else
echo >&2 "You need to install 'curl' or 'wget'."
exit 1
fi
v8_version="3.23.0"
v8_path="v8-$v8_version"
# check v8 installation
need_v8='false'
if [ ! -d $v8_path ] || [ ! -d $v8_path/out/native/ ]; then
need_v8='true'
else
libv8_base="`find $v8_path/out/native/ -name 'libv8_base.*.a' | head -1`"
libv8_snapshot="`find $v8_path/out/native/ -name 'libv8_snapshot.a' | head -1`"
if [ libv8_base == '' ] || [ libv8_snapshot == '' ]; then
need_v8='true'
fi
fi
# download and build v8
if [ $need_v8 == 'true' ]; then
# download
if [ ! -f $v8_path.tar.gz ]; then
$download $v8_path.tar.gz https://codeload.github.com/v8/v8/tar.gz/$v8_version
fi
tar -xzvf $v8_path.tar.gz
# begin
cd $v8_path
# we don't need ICU library
svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp --revision 1685
# fix gcc 4.8 compile error
gcc48=`gcc -v 2>&1 | tail -1 | grep "gcc [^0-9 ]\+ 4.8"`
if [ ! "$gcc48" == "" ]; then
cp build/standalone.gypi build/standalone.gypi.bk
patch build/standalone.gypi ../gcc48.patch
fi
# build
make i18nsupport=off native
# end
cd ..
fi
# check again
libv8_base="`find $v8_path/out/native/ -name 'libv8_base.*.a' | head -1`"
libv8_snapshot="`find $v8_path/out/native/ -name 'libv8_snapshot.a' | head -1`"
if [ libv8_base == '' ] || [ libv8_snapshot == '' ]; then
echo >&2 "V8 build failed?"
exit
fi
# build
librt=''
if [ `go env | grep GOHOSTOS` == 'GOHOSTOS="linux"' ]; then
librt='-lrt'
fi
CGO_LDFLAGS="$libv8_base $libv8_snapshot $librt" \
CGO_CFLAGS="-I $v8_path/include" \
CGO_CXXFLAGS="-I $v8_path/include" \
go install -x
# test
./test.sh . .
echo "done"