From 7cc8f654ee9de774024bef3e593c39dc016332d4 Mon Sep 17 00:00:00 2001 From: andros21 Date: Tue, 17 May 2022 09:12:04 +0000 Subject: [PATCH] devel(makefile): helping development (#36) * devel(makefile): helping development see `makefile` header for more information * fix(makefile): improve `stop` target compatibility now should work for `make>=4.2.1` --- makefile | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 makefile diff --git a/makefile b/makefile new file mode 100644 index 00000000..8b07167c --- /dev/null +++ b/makefile @@ -0,0 +1,42 @@ +# makefile +# -------- +# makefile for development, rules: +# + `animation` - create simple gif animation, useful to create +# rustracer usage examples (`ffmpeg` needed) +# + `docs` - preview `rustracer` documentation locally +# + `ccov` - preview `rustracer` code-coverage html report locally + +animation: examples/demo + +examples/demo: + @printf "[info] create demo gif animation ... " + @mkdir -p $@/frames + @for a in `seq 0 359`; do \ + rustracer demo --width 320 --height 240 --angle-deg $$a $@/frames/frame-`printf '%03d' $$a`.png; done; + @ffmpeg -loglevel panic -f image2 -framerate 25 -i $@/frames/frame-%03d.png $@/demo.gif + @printf "done\n" + +docs: docs.pid +ccov: ccov.pid + +docs.pid: + @for f in `ls -1 target/doc/rustracer`; do ln -sf rustracer/$$f target/doc/$$f; done; + @printf "starting http.server ... " + @{ python3 -m http.server -b 127.0.0.1 -d target/doc/ 8080 >/dev/null 2>&1 \ + & echo $$! >$@; } + @printf "done\n" + @printf "docs url: http://localhost:8080/\n" + +ccov.pid: + @printf "starting http.server ... " + @{ python3 -m http.server -b 127.0.0.1 -d target/llvm-cov/html 8081 >/dev/null 2>&1 \ + & echo $$! >$@; } + @printf "done\n" + @printf "ccov url: http://localhost:8081/\n" + +stop: *.pid + @printf "stopping http.server ... " + @pkill -F docs.pid 2>/dev/null || exit 0 + @pkill -F ccov.pid 2>/dev/null || exit 0 + @rm $^ + @printf "done\n"