Since I was just stumbling over this again: the build system API to manage comp-time options seems weirdly old-fashioned, did I just not look in the right place, or hasn’t this just not been updated yet?
E.g. currently I need to do:
// create Zig main module
const mod_main = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "sokol", .module = dep_sokol.module("sokol") },
},
});
// create comptime options module and attach to main module
const mod_options = b.addOptions();
mod_options.addOption(bool, "docking", opt_docking);
mod_main.addOptions("build_options", mod_options);
What I’d rather would like to do:
const mod_main = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "sokol", .module = dep_sokol.module("sokol") },
.{
.name = "build_options",
.module = b.createOptions(&.{
.{ .type = bool, .name = "docking", .value = opt_docking },
.{ .type = bool, .name = "another_option", .value = false },
}),
},
},
});
…e.g. a Build.createOptions() should return a *Module and take a slice of options, and removing the special Module.addOptions() functions in favour of providing the options module as a regular import.
Anybody knows if there’s already a ticket for this?