-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepare.sh
executable file
·142 lines (111 loc) · 3.05 KB
/
prepare.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
#!/bin/bash
function silent_pushd() {
pushd "$1" > /dev/null
}
function silent_popd() {
popd > /dev/null
}
function assert_success() {
if [[ $? != 0 ]]; then
echo "Terminating."
exit 1
fi
}
function usage() {
echo "usage: $0 [--cef-path PATH] [--rapidjons-install]"
}
export _cef_path=""
export _rapidjson_in_include=false
OPTS=$(getopt -o "h" -l "help,cef-path:,rapidjson-install" -- "$@")
if [[ $? != 0 ]]; then
echo "Failed to parse options"
exit 2
fi
eval set -- "$OPTS"
export _cef_path=
export _rapidjson_in_include=false
while true; do
case "$1" in
-h|--help)
usage
exit
shift
;;
--cef-path)
_cef_path=$2
shift 2
;;
--rapidjson-install)
_rapidjson_in_include=true
if [[ ! -d "/usr/include/rapidjson" ]]; then
echo "--rapidjson-installed is defined but cannot find directory in /usr/include!"
exit 1
fi
shift
;;
--) shift; break ;;
*)
echo "Error"
exit 2
;;
esac
done
echo "[*] Creating directories..."
mkdir -p "$PWD/bin/"
assert_success
mkdir -p "$PWD/thirdparty/cef"
assert_success
if [[ $_cef_path == "" ]]; then
echo "[*] Downloading and building CEF api..."
if [[ ! -f "$PWD/thirdparty/cef_binary.tar.bz2" ]]; then
wget --quiet --show-progress -O "$PWD/thirdparty/cef_binary.tar.bz2" $(printf "http://opensource.spotify.com/cefbuilds/%s" $(curl -s http://opensource.spotify.com/cefbuilds/index.html | grep -oP --regex="cef_binary_3.*?_linux64_minimal.tar.bz2" | head -1))
assert_success
fi
if [[ ! -d "$PWD/thirdparty/cef/include/" ]]; then
echo "[*] Uncompressing..."
tar -vxjf "$PWD/thirdparty/cef_binary.tar.bz2" -C "$PWD/thirdparty/cef/"
archivedir="$PWD/thirdparty/cef/"$(ls -1 "$PWD/thirdparty/cef/" | head -1)"/"
mv "$archivedir"* "$PWD/thirdparty/cef/"
assert_success
rmdir "$archivedir"
assert_success
fi
silent_pushd "$PWD/thirdparty/cef"
assert_success
cmake . -DCMAKE_BUILD_TYPE="Release"
assert_success
make -j$(nproc --all) libcef_dll_wrapper
silent_popd
fi
if [[ $_rapidjson_in_include == false ]]; then
echo "[*] Downloading rapidjson..."
silent_pushd "$PWD/thirdparty/"
if [[ ! -d rapidjson ]]; then
git clone https://github.com/Tencent/rapidjson.git rapidjson
assert_success
fi
silent_popd
fi
if [[ $_cef_path == "" ]] || [[ $_rapidjson_in_include == false ]]; then
echo "[*] Creating include directory..."
if [[ $_cef_path == "" ]]; then
cp -r "$PWD/thirdparty/cef/include/" "$PWD/thirdparty/"
fi
if [[ $_rapidjson_in_include == false ]]; then
cp -r "$PWD/thirdparty/rapidjson/include/" "$PWD/thirdparty/"
fi
fi
echo "[*] Copying CEF resources and libs..."
if [[ $_cef_path == "" ]]; then
cp -fr "$PWD/thirdparty/cef/Release/"* "$PWD/bin/"
cp -fr "$PWD/thirdparty/cef/Resources/"* "$PWD/bin/"
else
cp -frs "$_cef_path/Release/"* "$PWD/bin/"
cp -frs "$_cef_path/Resources/"* "$PWD/bin/"
fi
find "$PWD/bin/" -type f -name "*.so" -exec strip {} +
strip "$PWD/bin/chrome-sandbox"
echo "[*] Creating makefile..."
./scripts/create_makefile.sh "$@"
echo "[*] We are done!"
echo -e "[*] Use \e[1m\e[94mmake -j$(nproc --all)\e[39m\e[0m to compile"