commit 5d29d3f6a393584d8a7a39796af580d2e6132b4d
parent 8e8772fb11b89e0cda3c553e053eeb3c8a41a5b9
Author: walther chen <walther.chen@gmail.com>
Date: Thu, 20 Mar 2025 14:01:24 +0700
Werkfile
Diffstat:
3 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,4 +1,5 @@
-*
-!*.c3
-!README.md
-!justfile
+target
+perf.svg
+perf.data*
+E_coli.txt
+input.txt
diff --git a/Werkfile b/Werkfile
@@ -0,0 +1,42 @@
+default target = "build"
+# doesn't currently work, use cli --jobs
+#default jobs = 1
+
+config profile = "debug"
+
+# Pick cflags based on the build profile
+let cflags = profile | match {
+ "debug" => ["-O0"]
+ "release" => ["-O3"]
+ "asan-address" => ["-O0", "--sanitize=address"]
+ "%" => ""
+}
+
+build "%.bin" {
+ from "%.c3"
+ from [
+ "util-frequency.c3",
+ "test.c3",
+ ]
+ run "c3c compile <in*:workspace> -o <out:out-dir>"
+}
+
+task build {
+ let bins = [
+ glob "ba*.c3" | map "{:.c3=.bin}",
+ ["approximate_pattern_count.bin"]
+ ] | flatten
+ #info "{bins*}"
+ build bins
+}
+
+build "testrun" {
+ from glob "*.c3"
+ run "c3c compile-test --suppress-run {cflags*} <in*> -o <out:out-dir>"
+}
+
+task test {
+ let test_exe = "testrun"
+ build test_exe
+ run "<test_exe>"
+}
diff --git a/justfile b/justfile
@@ -1,16 +1,8 @@
-@check:
- \fd --glob '*.c3' -x c3c compile -C util-*.c3 test.c3
+build:
+ werk build --jobs=1 -Dprofile=release
-@test:
- c3c compile-test .
-
-# redirects outputs to stderr
-@build problem *args="":
- c3c compile {{args}} {{problem}}.c3 util-*.c3 test.c3 1>&2
-
-# using compile-run prints a bunch of logs
run problem *args="":
- just build {{problem}} -O5 && time -pq ./{{problem}} {{args}} && rm ./{{problem}}
+ werk build --jobs=1 -Dprofile=release && time -pq ./target/{{problem}}.bin {{args}}
bench problem *args="":
just build {{problem}} -O5 && \