-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·150 lines (129 loc) · 2.75 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
146
147
148
149
150
#!/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
jinja2 --format yaml config/options.tal.tpl \
-o config/options.tal config.yaml
jinja2 --format yaml src/repl/routines.tal.tpl \
-o src/repl/routines.tal config.yaml
jinja2 --format yaml src/debugger/routines/after-eval.tal.tpl \
-o src/debugger/routines/after-eval.tal config.yaml
jinja2 --format yaml src/debugger/routines/before-eval.tal.tpl \
-o src/debugger/routines/before-eval.tal config.yaml
jinja2 --format yaml src/repl/data.tal.tpl \
-o src/repl/data.tal config.yaml
jinja2 --format yaml src/talos/main.tal.tpl \
-o src/talos/main.tal config.yaml
jinja2 --format yaml src/talos/macros.tal.tpl \
-o src/talos/macros.tal config.yaml
# 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