+55
build.sh
+55
build.sh
···
1
+
#!/usr/bin/env sh
2
+
set -e
3
+
4
+
SRC=src
5
+
BUILD=.build/
6
+
CC=gcc
7
+
8
+
build() {
9
+
FILE=$1
10
+
ADDRESS=$2
11
+
PORT=$3
12
+
13
+
OUT=.build/${FILE}
14
+
IN=src/${FILE}
15
+
16
+
mkdir -p .build
17
+
gcc -std=gnu99 -O3 -Wno-builtin-declaration-mismatch ${SRC}/lib/*.c ${IN} -o ${OUT}
18
+
./${OUT} ${ADDRESS} ${PORT}
19
+
}
20
+
21
+
case $2 in
22
+
[0-9]*.[0-9]*.[0-9]*.[0-9]*)
23
+
ADDRESS=$2
24
+
;;
25
+
[0-9]*)
26
+
PORT=$2
27
+
;;
28
+
*)
29
+
ADDRESS=127.0.0.1
30
+
esac
31
+
32
+
case $3 in
33
+
[0-9]*.[0-9]*.[0-9]*.[0-9]*)
34
+
ADDRESS=$3
35
+
;;
36
+
[0-9]*)
37
+
PORT=$3
38
+
;;
39
+
*)
40
+
PORT=42069
41
+
;;
42
+
esac
43
+
44
+
case $1 in
45
+
edevice.py)
46
+
build edevice.c ${ADDRESS} ${PORT}
47
+
;;
48
+
cluster.py)
49
+
build cluster.c ${ADDRESS} ${PORT}
50
+
;;
51
+
*)
52
+
echo "You must provide a file."
53
+
exit 1
54
+
;;
55
+
esac