Threads and Scheduling
1#!/usr/bin/env sh
2set -e
3
4SRC=src
5BUILD=.build/
6CC=gcc
7
8build() {
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
21case $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
30esac
31
32case $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 ;;
42esac
43
44case $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 ;;
55esac