In build.zig I can make some nice options:
const module = b.option([]const u8, "foo", "Path to foo") orelse "/path/to/foo";
const options = b.addOptions();
options.addOption([]const u8, "foo", foo);
lib_unit_tests.root_module.addOptions("config", options);
Given the above, if I execute tests via zig build test, then any options I supplied in build.zig can be read pretty easily in my code:
const config = @import("config");
// ... I can read config.foo here.
If I execute the same tests, but instead I use zig test main.zig, the compiler tells me I cannot find the "config" import. Is there a method to retrieve build options added in build.zig which works for both scenarios (zig build test and zig test foo.zig)? I thought about using environment variables instead, but on non-POSIX systems, I have to use std.process.getEnvVarOwned which I'd like to avoid. Should I be doing this a different way?