-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·145 lines (124 loc) · 2.57 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env sh
OS_TYPE=$(uname)
ROM=rom/talos.rom
HOST=`uname -a`
echo "Host: $HOST"
# Start
# Save TTY settings.
STTY=`stty -g`
# Select emulator.
if [ -z "$EMU" ]; then
for arg in "$@"; do
case "$arg" in
"--uxn38-cli")
EMU="uxn38 -n"
;;
"--uxn38-gui")
EMU="uxn38 -I"
;;
"--uxn11")
EMU="uxn11"
;;
"--raven-cli")
EMU="raven-cli"
;;
"--raven-gui")
EMU="raven-gui"
;;
"--uxnemu")
EMU="uxnemu"
;;
"--uxncli")
EMU="uxncli"
;;
"--uxntui")
EMU="uxntui"
;;
esac
done
fi
if [ -z "$EMU" ]; then
EMU="uxntui"
fi
EMU_PATH=$(which "$EMU" 2>/dev/null)
if [ -z "$EMU_PATH" ]; then
echo "Error: '$EMU' not found in PATH."
exit 1
fi
# Pre-process
for arg in "$@"; do
case "$arg" in
"--debug")
echo "Debugging enabled."
DEBUG="DBG"
;;
esac
done
if [ -z "$DEBUG" ]; then
DEBUG="NO_DBG"
fi
# Sorry
cpp -P -w -D $DEBUG config/options.talp -o config/options.tal
cpp -P -w -D $DEBUG src/debugger/routines/after-eval.talp \
-o src/debugger/routines/after-eval.tal
cpp -P -w -D $DEBUG src/debugger/routines/before-eval.talp \
-o src/debugger/routines/before-eval.tal
cpp -P -w -D $DEBUG src/repl/data.talp -o src/repl/data.tal
cpp -P -w -D $DEBUG src/talos/main.talp -o src/talos/main.tal
cpp -P -w -D $DEBUG src/talos/macros.talp -o src/talos/macros.tal
# Build
mkdir -p rom
# Select assembler.
if [ -z "$ASM" ]; then
for arg in "$@"; do
case "$arg" in
"--drifblim")
ASM="uxncli ~/roms/drifblim.rom"
;;
"--uxnasm")
ASM="uxnasm"
;;
esac
done
fi
if [ -z "$ASM" ]; then
ASM="uxnasm"
fi
ASM_PATH=$(which "$ASM" 2>/dev/null)
if [ -z "$ASM_PATH" ]; then
echo "Error: '$ASM' not found in PATH."
exit 1
fi
echo "Using assembler: $ASM_PATH"
cd src
$ASM talos/includes.tal ../rom/talos.rom || exit 127
cd ..
# Install
for arg in "$@"; do
case "$arg" in
"--install")
echo "Installing ./{bin,rom} at ~/{.local/bin,roms}"
mkdir -p ~/roms
cp bin/* ~/.local/bin
cp rom/talos.rom ~/roms
;;
esac
done
# Run
if echo "$OS_TYPE" | grep -qi "mingw"; then
# Does not support -xcase
stty -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl \
-ixon -ixoff -icanon onlcr -echo -isig -iuclc -ixany -imaxbel min 1 time 0
else
stty -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl \
-ixon -ixoff -icanon onlcr -echo -isig -iuclc -ixany -imaxbel -xcase min 1 \
time 0
fi
echo "Using emulator: $EMU_PATH"
$EMU $ROM
EXIT=`echo $?`
echo "Exit code: $EXIT"
# Exit
# Restore TTY settings.
stty $STTY
exit $EXIT