forked from MintzyG/ConwaysBitField
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile_run.sh
executable file
·64 lines (50 loc) · 1.38 KB
/
compile_run.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
#!/usr/bin/env bash
pushd ./modules || exit
./out.out
popd || exit
Threads=$(lscpu | grep -i CPU\(s\): | grep -o -E '[0-9]+')
echo $Threads
echo "Do you want a max size board? (y/Y | n/N)"
read -r Max
Max=${Max:-N}
echo "Are you going to run it through tty? (y/Y | n/N)"
read -r Tty
Tty=${Tty:-N}
echo "Do you want to use speedtest mode? (y/Y | n/N)"
read -r Speed
Speed=${Speed:-N}
if [[ "$Max" == "N" || "$Max" == "n" ]]; then
echo "How tall do you want the matrix from 1-16:"
read -r Height
Height=${Height:-16}
echo "How wide do you want the matrix from 1-16:"
read -r Width
Width=${Width:-16}
else
Lines=$(tput lines)
Columns=$(tput cols)
if [[ "$Tty" == "Y" || "$Tty" == "y" ]]; then
Height=$(((Lines -3)/4))
Width=$(((Columns -2)/8))
else
Height=$(((Lines -3)/2))
Width=$(((Columns -2)/4))
fi
fi
echo "Do you want a random board? (y/Y | n/N)"
read -r Rand
Rand=${Rand:-Y}
echo "What delay do you want 1ms - 1000ms:"
read -r Delay
Delay=${Delay:-100}
gcc_cmd="gcc main.c modules/ruleset.c -o game.out -DTHREADS=$Threads -DDELAY=$Delay -DWIDTH=$Width -DHEIGHT=$Height -Wall -Wextra -O3 -Imodules -fopenmp"
if [[ "$Rand" == "Y" || "$Rand" == "y" ]]; then
gcc_cmd+=" -DRAND"
fi
if [[ "$Tty" == "Y" || "$Tty" == "y" ]]; then
gcc_cmd+=" -DTTY"
fi
if [[ "$Speed" == "Y" || "$Speed" == "y" ]]; then
gcc_cmd+=" -DSPEEDTEST"
fi
eval "$gcc_cmd" && ./game.out