-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.sh
48 lines (40 loc) · 1.07 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
#!/bin/sh
set -x
if [ "$BUILD_MODE" = "test" ] ; then
set -e
chmod ugo+x ./build/release/mbc
./build/release/mbc
exit 0
fi
die(){
echo "ERROR"
exit -1
}
export DOWNLOAD_GCC_TOOLCHAIN="http://musl.cc/arm-linux-musleabihf-cross.tgz"
export PATH="$PWD/build/arm-linux-musleabihf-cross/bin:$PATH"
if [ "$(ls build/arm-linux-musle*)" = "" ] ; then
echo "downloading $DOWNLOAD_GCC_TOOLCHAIN"
mkdir -p build ||die
cd build
curl "$DOWNLOAD_GCC_TOOLCHAIN" --output cc_toolchain.tar.gz ||die
tar -xzf cc_toolchain.tar.gz ||die
cd ..
fi
BFLAG=" -std=c99 -Wall -D_XOPEN_SOURCE=700 -static -O2 "
COMMIT=$(git rev-parse HEAD)
BFLAG=" $BFLAG -DMBC_BUILD_COMMIT=\"$COMMIT\" "
DATE=$(date --rfc-3339=seconds | tr ' ' '/')
BFLAG=" $BFLAG -DMBC_BUILD_DATE=\"$DATE\" "
echo "building..."
cd build
arm-linux-musleabihf-gcc $BFLAG -o mbc ../mbc.c ||die
arm-linux-musleabihf-strip mbc ||die
mkdir -p hook/expose ||die
cd hook/expose ||die
ln -s ../../mbc __unnamed__ ||die
cd -
tar -czf mbc.tar.gz mbc hook/expose/__unnamed__
mkdir release
cp mbc release/
cp mbc.tar.gz release/
cd ..