src := "src/main.c3"
bin := "build/csh"

default:
    @just --list

tangle:
    emacs -Q --batch --eval "(require 'org)" --eval '(org-babel-tangle-file "README.org")'

run: tangle _prep
    c3c compile-run {{src}} -o {{bin}}

build: tangle _prep
    c3c compile {{src}} -O0 -g -o {{bin}}

release: tangle _prep
    c3c compile {{src}} -O5 -o {{bin}}

asan: tangle _prep
    c3c compile-run {{src}} -O0 -g --sanitize=address -o {{bin}}

tsan: tangle _prep
    c3c compile-run {{src}} -O0 -g --sanitize=thread -o {{bin}}

example name: tangle _prep
    c3c compile-run src/{{name}}.c3 -o build/{{name}}

valgrind: build
    valgrind --leak-check=full --error-exitcode=1 ./{{bin}}

clean:
    rm -rf build src

_prep:
    @mkdir -p build
