-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatch_cc
executable file
·49 lines (43 loc) · 912 Bytes
/
watch_cc
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
#!/bin/bash
# Simple script that watches a certain file and auto assembles it whenever it
# has been written to, and optionally even sends the prg to the ultimate ii+
#
# Written Folkert van Verseveld
if [ $# -eq 0 ]; then
echo "usage: ${BASH_SOURCE} file [dest_ip]" 1>&2
exit 1
fi
emu=yes
src="$1"
if [ $# -eq 2 ]; then
emu=no
dest="$2"
fi
prg="${src%.*}.prg"
asm="${src%.*}.s"
obj="${src%.*}.o"
p=
while :; do
# wait for write event to any c-source file
inotifywait -qre modify "$src"
rm -f "$prg"
cc65 -t c64 "$src" && ca65 "$asm" && ld65 -o "$prg" -t c64 "$obj" c64.lib
if [ $? -ne 0 ]; then
echo --------
continue
fi
if [ ! -z $p ]; then
kill -9 $p
p=
fi
# determine how the prg is supposed to be run
if [ $emu == no ]; then
python "$(dirname ${BASH_SOURCE})"/sock.py p "$prg" "$dest"
continue
if [ $? -eq 0 ]; then
continue
fi
fi
x64 "$prg" >/dev/null &
p=$!
done