-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·83 lines (73 loc) · 1.21 KB
/
make.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
#!/usr/local/bin/bash
echo "This will ./build and then 'make' the project.."
sleep 0.5
# Idioms
# public helper methods
DO_COMMAND() {
if [[ -n $1 ]]
then echo "$1"
eval "$1"
return 1
fi
return 0
}
exists(){
if [ "$2" != in ]; then
return
fi
eval '[ ${'$3'[$1]+abc} ]'
}
# Set Detaults
CORES=4
# Parse Args
is_arg_dependant_on_param() {
ARG="$1"
case $1 in
"-d" )
return 1
;;
"-j" )
return 0
;;
* )
return 1
;;
esac
}
declare -A params
args=("$@")
argc="$#"
for ((i = 0 ; i <= $argc ; i++));
do if [[ $i -lt $argc ]]
then
ARG=${args[$i]}
PARAM=""
if [[ $ARG == -* ]]; then
# Get the param if relevant
if is_arg_dependant_on_param $ARG
then
if [[ $((i + 1)) -lt $argc ]]
then PARAM=${args[(($i + 1))]}
((i++))
else
echo "Not enough params: Arg $ARG missing Param.."
fi
fi
# Else its an arg without a parameter
fi
params[$ARG]="$PARAM"
fi
done
# Check if cores arg was passed:
if [[ -n ${params[-j]} ]]
then CORES=${params[-j]};
fi
if exists "-d" in params;
then DO_COMMAND "rm -rf ./build"
fi
./build.sh
cd ./build
# Compile tings
CMD="make -j $CORES"
echo $CMD
eval $CMD