vrmm build files

This commit is contained in:
allexanderbergmns
2026-08-25 14:45:19 +02:00
parent 9b22be48a5
commit 387079d720
20 changed files with 646 additions and 1 deletions
+55
View File
@@ -0,0 +1,55 @@
// build.vrmm — a VuurRaaf Make Module: build instructions for the toolchain,
// written in VuurRaaf itself (like V's .vsh, but for this language).
//
// ./bin/vr make -f examples/build.vrmm build + run hello
// ./bin/vr make -f examples/build.vrmm multi compile/link/run a 2-file program
// ./bin/vr make -f examples/build.vrmm test run tests.vr
// ./bin/vr make -f examples/build.vrmm clean remove artifacts
// ./bin/vr make -f examples/build.vrmm deploy --prod deploy() with args()
//
// Paths are relative to the working directory; build_root() returns this
// module's own directory for scripts that want absolute paths.
fn main() {
// compile + link + run in one step
build_run("examples/hello.vr")
}
fn multi() {
// drive each toolchain stage explicitly
let root = build_root()
let lib = build_compile(build_join(root, "lib.vr"), build_join(root, "lib.vobj"))
let use = build_compile(build_join(root, "use_lib.vr"), build_join(root, "use_lib.vobj"))
let bin = build_link([lib, use], build_join(root, "use_lib.vbin"))
build_run(bin)
}
fn test() {
// run every test_* function; fails the build if any test fails
build_test("examples/tests.vr")
}
fn bench() {
// benchmark main() of fib.vr 2000 times
build_bench("examples/fib.vr", 2000)
}
fn deploy() {
// arguments after the target arrive via args()
let args = args()
if len(args) == 0 {
throw "deploy needs a flag: vr make deploy --prod"
}
println("deploying with args: " + join(args, " "))
let out = build_exec("echo 'deploy step ok'")
println(out)
}
fn clean() {
// remove this module's artifacts (build_rm returns 1 if it removed something)
let root = build_root()
for f in ["lib.vobj", "lib.vbin", "use_lib.vobj", "use_lib.vbin", "hello.vbin"] {
build_rm(build_join(root, f))
}
println("cleaned")
}
+9
View File
@@ -0,0 +1,9 @@
// debug: does the function work at all?
fn double(x) {
return x * 2
}
fn main() {
println(double(21))
}
+11
View File
@@ -0,0 +1,11 @@
// debug: generic function
fn first[T](arr) {
return arr[0]
}
fn main() {
let nums = [10, 20, 30]
let x = first(nums)
println(x)
}
+13
View File
@@ -0,0 +1,13 @@
// debug: trace function execution
fn first[T](arr) {
let x = arr[0]
println(x)
return x
}
fn main() {
let nums = [10, 20, 30]
let x = first(nums)
println("main got: ${x}")
}
+16
View File
@@ -0,0 +1,16 @@
// debug: trace everything
fn first[T](arr) {
println("inside first")
println(arr)
let x = arr[0]
println("x = ${x}")
return x
}
fn main() {
println("calling first")
let nums = [10, 20, 30]
let result = first(nums)
println("result = ${result}")
}
+12
View File
@@ -0,0 +1,12 @@
// debug: test arr[0] in function body
fn first(arr) {
println(arr[0])
return arr[0]
}
fn main() {
let nums = [10, 20, 30]
let result = first(nums)
println("result = ${result}")
}
+10
View File
@@ -0,0 +1,10 @@
// debug: basic arr[0]
fn get_first(arr) {
return arr[0]
}
fn main() {
let nums = [10, 20, 30]
println(get_first(nums))
}
+6
View File
@@ -0,0 +1,6 @@
// debug: inline arr[0]
fn main() {
let nums = [10, 20, 30]
println(nums[0])
}
+10
View File
@@ -0,0 +1,10 @@
// simple generic test
fn first[T](arr) {
return arr[0]
}
fn main() {
let nums = [10, 20, 30]
println(first[int](nums))
}
+10
View File
@@ -0,0 +1,10 @@
// simple generic test - no type args
fn first[T](arr) {
return arr[0]
}
fn main() {
let nums = [10, 20, 30]
println(first(nums))
}