forked from OffchainLabs/nitro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-brotli.sh
executable file
·108 lines (97 loc) · 2.58 KB
/
build-brotli.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
#!/bin/bash
set -e
mydir=`dirname $0`
cd "$mydir"
BUILD_WASM=false
BUILD_LOCAL=false
BUILD_SOFTFLOAT=false
USE_DOCKER=false
TARGET_DIR=target/
SOURCE_DIR=brotli
usage(){
echo "brotli builder for arbitrum"
echo
echo "usage: $0 [options]"
echo
echo "use one or more of:"
echo " -w build wasm (uses emscripten)"
echo " -l build local"
echo " -f build soft-float"
echo
echo "to avoid dependencies you might want:"
echo " -d build inside docker container"
echo
echo "Other options:"
echo " -s source dir default: $SOURCE_DIR"
echo " -t target dir default: $TARGET_DIR"
echo " -h help"
echo
echo "all relative paths are relative to script location"
}
while getopts "s:t:c:wldhf" option; do
case $option in
h)
usage
exit
;;
w)
BUILD_WASM=true
;;
l)
BUILD_LOCAL=true
;;
f)
BUILD_SOFTFLOAT=true
;;
d)
USE_DOCKER=true
;;
t)
TARGET_DIR="$OPTARG"
;;
s)
SOURCE_DIR="$OPTARG"
;;
esac
done
if ! $BUILD_WASM && ! $BUILD_LOCAL && ! $BUILD_SOFT; then
usage
exit
fi
if [ ! -d "$TARGET_DIR" ]; then
mkdir -p "${TARGET_DIR}lib"
ln -s "lib" "${TARGET_DIR}lib64" # Fedora build
fi
TARGET_DIR_ABS=`cd -P "$TARGET_DIR"; pwd`
if $USE_DOCKER; then
if $BUILD_WASM; then
DOCKER_BUILDKIT=1 docker build --target brotli-wasm-export -o type=local,dest="$TARGET_DIR_ABS" .
fi
if $BUILD_LOCAL; then
DOCKER_BUILDKIT=1 docker build --target brotli-library-export -o type=local,dest="$TARGET_DIR_ABS" .
fi
if $BUILD_SOFTFLOAT; then
DOCKER_BUILDKIT=1 docker build --target wasm-libs-export -o type=local,dest="$TARGET_DIR_ABS" .
fi
exit 0
fi
cd "$SOURCE_DIR"
if $BUILD_WASM; then
mkdir -p buildfiles/build-wasm
mkdir -p buildfiles/install-wasm
TEMP_INSTALL_DIR_ABS=`cd -P buildfiles/install-wasm; pwd`
cd buildfiles/build-wasm
cmake ../../ -DCMAKE_C_COMPILER=emcc -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fPIC -DCMAKE_INSTALL_PREFIX="$TEMP_INSTALL_DIR_ABS" -DCMAKE_AR=`which emar` -DCMAKE_RANLIB=`which touch`
make -j
make install
cp -rv "$TEMP_INSTALL_DIR_ABS/lib" "$TARGET_DIR_ABS/lib-wasm"
cd ..
fi
if $BUILD_LOCAL; then
mkdir -p buildfiles/build-local
cd buildfiles/build-local
cmake ../../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$TARGET_DIR_ABS"
make -j
make install
cd ..
fi