aboutsummaryrefslogtreecommitdiff
path: root/scripts/run.sh
blob: 6d71521b1372d54bcd674349d4803dd57f52e146 (plain)
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
#!/usr/bin/env bash
set -euo pipefail

root="$(cd "$(dirname "$0")/.." && pwd)"
cd "$root"

if [ $# -lt 1 ]; then
	echo "usage: $(basename "$0") <file.hdass>" >&2
	exit 1
fi

file="$1"
name="$(basename "${file%.*}")"

docker compose up -d >/dev/null

docker compose exec -T -e SRC="$file" -e NAME="$name" hdass bash -c '
	set -e
	cd /hdass
	premake5 gmake >/dev/null
	make config=debug >/dev/null
	./bin/debug-linux/hdass "$SRC" -o "/tmp/$NAME.asm"
	nasm -f elf64 "/tmp/$NAME.asm" -o "/tmp/$NAME.o"
	ld -e main "/tmp/$NAME.o" -o "/tmp/$NAME"
	set +e
	"/tmp/$NAME"
	printf "\n[exit %s]\n" "$?"
' </dev/null