I have the following code in my build.zig
:
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const options = b.addOptions();
options.addOption(bool, "some_config", 123);
const anyline_zig_mod = b.addModule("anyline", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
anyline_zig_mod.addOptions("build_config", options);
// I'm skipping code for brevity
// The code simply adds the module to an executable's imports
}
When I attempt to import the build_config
in src/root.zig
, I get the following compiler error:
error: no module named 'build_config' available within module 'root'
const build_config = @import("build_config");
I’ve used Step.Options
in other projects before, but for some reason, this one cannot be found. What am I missing?