commit 02f2769
Devine Lu Linvega
·
2023-04-10 17:16:17 +0000 UTC
parent 416f37c
Cleaned up build script
2 files changed,
+31,
-28
M
build.sh
M
build.sh
+6,
-20
1@@ -2,8 +2,9 @@
2
3 RELEASE_FLAGS="-Os -DNDEBUG -g0 -s"
4 DEBUG_FLAGS="-std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined"
5-EMU_INC="src/uxn.c src/devices/system.c src/devices/console.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11"
6-CLI_INC="src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli"
7+CORE_DEVICES="src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c"
8+EMU_INC="${CORE_DEVICES} src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/uxn11.c -o bin/uxn11 -lX11"
9+CLI_INC="${CORE_DEVICES} src/uxncli.c -o bin/uxncli"
10
11 # find X11 libs on various systems
12 if [ -e /usr/X11R6 ]; then
13@@ -12,31 +13,20 @@ if [ -e /usr/X11R6 ]; then
14 DEBUG_FLAGS="-L/usr/X11R6/lib/ -I/usr/X11R6/include/ $DEBUG_FLAGS"
15 fi
16
17-
18 if [ "${1}" = '--format' ];
19 then
20- echo "Formatting.."
21 clang-format -i src/uxn11.c
22 clang-format -i src/uxnasm.c
23 clang-format -i src/uxncli.c
24 clang-format -i src/devices/*
25 fi
26
27-echo "Cleaning.."
28 rm -f bin/*
29 mkdir -p bin
30
31-echo "Building.."
32-cc -DNDEBUG -Os -g0 -s src/uxnasm.c -o bin/uxnasm
33-if [ "${1}" = '--install' ];
34-then
35- echo "Installing.."
36- gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${EMU_INC}
37- gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${CLI_INC}
38- cp bin/uxnasm ~/bin
39- cp bin/uxncli ~/bin
40- cp bin/uxn11 ~/bin
41-elif [ "${1}" = '--release' ];
42+cc ${RELEASE_FLAGS} src/uxnasm.c -o bin/uxnasm
43+
44+if [ "${1}" = '--release' ];
45 then
46 gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${EMU_INC}
47 gcc ${C_FLAGS} ${LD_FLAGS} ${RELEASE_FLAGS} ${CLI_INC}
48@@ -45,10 +35,6 @@ else
49 gcc ${C_FLAGS} ${LD_FLAGS} ${DEBUG_FLAGS} ${CLI_INC}
50 fi
51
52-echo "Assembling.."
53 bin/uxnasm etc/polycat.tal bin/polycat.rom
54-
55-echo "Running.."
56 bin/uxn11 bin/polycat.rom
57
58-echo "Done."
+25,
-8
1@@ -39,7 +39,7 @@ typedef struct {
2 Uint16 llen, mlen, rlen;
3 Label labels[0x400];
4 Macro macros[0x100];
5- Reference refs[0x400];
6+ Reference refs[0x800];
7 char scope[0x40];
8 } Program;
9
10@@ -179,7 +179,7 @@ makereference(char *scope, char *label, char rune, Uint16 addr)
11 {
12 char subw[0x40], parent[0x40];
13 Reference *r;
14- if(p.rlen == 0x1000)
15+ if(p.rlen >= 0x800)
16 return error("References limit exceeded", label);
17 r = &p.refs[p.rlen++];
18 if(label[0] == '&') {
19@@ -253,6 +253,7 @@ parse(char *w, FILE *f)
20 {
21 int i;
22 char word[0x40], subw[0x40], c;
23+ Label *l;
24 Macro *m;
25 if(slen(w) >= 63)
26 return error("Invalid token", w);
27@@ -278,14 +279,30 @@ parse(char *w, FILE *f)
28 return error("Invalid macro", w);
29 break;
30 case '|': /* pad-absolute */
31- if(!sihx(w + 1))
32- return error("Invalid padding", w);
33- p.ptr = shex(w + 1);
34+ if(sihx(w + 1))
35+ p.ptr = shex(w + 1);
36+ else if(w[1] == '&') {
37+ if(!sublabel(subw, p.scope, w + 2) || !(l = findlabel(subw)))
38+ return error("Invalid sublabel", w);
39+ p.ptr = l->addr;
40+ } else {
41+ if(!(l = findlabel(w + 1)))
42+ return error("Invalid label", w);
43+ p.ptr = l->addr;
44+ }
45 break;
46 case '$': /* pad-relative */
47- if(!sihx(w + 1))
48- return error("Invalid padding", w);
49- p.ptr += shex(w + 1);
50+ if(sihx(w + 1))
51+ p.ptr += shex(w + 1);
52+ else if(w[1] == '&') {
53+ if(!sublabel(subw, p.scope, w + 2) || !(l = findlabel(subw)))
54+ return error("Invalid sublabel", w);
55+ p.ptr += l->addr;
56+ } else {
57+ if(!(l = findlabel(w + 1)))
58+ return error("Invalid label", w);
59+ p.ptr += l->addr;
60+ }
61 break;
62 case '@': /* label */
63 if(!makelabel(w + 1))