A few days ago, while writing the sbt configuration, I came up with an idea what if I used odin to build just like sbt uses scale to build.
I decided to experiment a bit and created a very simple build system using Odin as the configuration files. The simplest possible case would look like this:
build.odin file:
package example
@(export)
root :: proc() -> string { return "src/" }
@(export)
name :: proc() -> string { return "example" }
The whole idea is based on .so files. When bax runs, it uses the Odin compiler to compile your configuration into a dll or .so file and then loads that file into the runtime. A more interesting case showing the intention was this file:
#+feature dynamic-literals
package bax
import "core:fmt"
OK :: 0
ERR :: 1
@(export)
root :: proc() -> string { return "src/" }
@(export)
modules :: proc() -> []string {
mods := make([dynamic]string)
append(&mods, "external/iseven")
return mods[:]
}
@(export)
min_version :: proc() -> string { return "1.0.0" }
@(export)
name :: proc() -> string { return "bax" }
@(export)
definitions :: proc() -> map[string]string {
defs := map[string]string {
"VERSION" = "1.0.0",
"NAME" = "bax"
}
return defs
}
@(export)
before_build :: proc() -> int {
fmt.println("Before the build hook")
return OK
}
@(export)
after_build :: proc() -> int {
fmt.println("After build hook")
return OK
}
@(export)
before_run :: proc() -> int {
fmt.println("Before the run hook")
return OK
}
@(export)
after_run :: proc() -> int {
fmt.println("After run hook")
return OK
}
@(export)
before_test :: proc() -> int {
fmt.println("Before test hook")
return OK
}
@(export)
after_test :: proc() -> int {
fmt.println("After test hook")
return OK
}
In this case, I’m using a few target hooks and adding external modules. Interestingly, if we combine this with git submodule, we get a simple package manager, allowing us to download 200 packages to check if the number is divisible by two ![]()
The whole solution works (at least I think so), but I wouldn’t call it production-ready. If anyone’s curious, here’s the link: