https://ziglang.org/learn/build-system/#standard-configuration-options
Is the “config” file created on-fly?
https://ziglang.org/learn/build-system/#standard-configuration-options
Is the “config” file created on-fly?
Assuming you’re referring to the code under “Options for Conditional Compilation”, config
is a set of options supplied by the build script in the subsequent code snippet:
const version = b.option([]const u8, "version", "application version string") orelse "0.0.0";
const enable_foo = detectWhetherToEnableLibFoo();
const options = b.addOptions();
options.addOption([]const u8, "version", version);
options.addOption(bool, "have_libfoo", enable_foo);
exe.root_module.addOptions("config", options);
Yes, that is just my guess. I am just wondering is there any official doc explaining this?
There is this from Build.addOptions
:
Create a set of key-value pairs that can be converted into a Zig source file and then inserted into a Zig compilation’s module table for importing. In other words, this provides a way to expose build.zig values to Zig source code with @import. Related: Module.addOptions.
Thank for the reference. It is a little magical.
BTW, it looks there is a missing Package Management section in the build system doc.