Skip to content

Inject typed literal build-option values into a module - #41

Merged
godofecht merged 1 commit into
mainfrom
feat/injected-option-values
Aug 5, 2026
Merged

godofecht merged 1 commit into
mainfrom
feat/injected-option-values

Conversation

@godofecht

@godofecht godofecht commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

What

Adds an option_values list to #Module: typed literal values (bool / string / u32 / opt_commit) injected into the module's build-options module, imported under build_options_import. opt_commit emits a ?[40]u8 git hash (null unless a 40-char value is given).

Why

A repo's build.zig often synthesizes an options module from generated values (git commit, release version, feature flags). tigerbeetle is the motivating case: src/config.zig does @import("vsr_options") and reads config_verify (bool), git_commit (?[40]u8), release and release_client_min ([]const u8). Azazel's existing build_options only surfaced CLI flags (#Option: bool/string/u32), so a module needing injected values could not compile without the repo's own build.zig. This also unblocks ghostty's terminal_options and mach's module flags.

How it flows

  • schema.cue: #OptionValue + option_values on #Module. Fields avoid CUE's predeclared bool/string identifiers.
  • gen_build_spec.sh: OptionValue struct + emitter.
  • build.zig: addBuildOptions also injects option_values (with an opt_commit -> ?[40]u8 branch) into the options module.
  • build_spec_test.zig: shape assertions (kind is one of four; opt_commit is null or 40 chars).

Verification

Built tigerbeetle's whole vsr library on 0.14 with an injected vsr_options module (libtb_vsr.a). config.zig reads all four fields via a comptime field loop, so a missing or mistyped field would fail to compile. Azazel's own build and the 23 spec tests pass on 0.14.1. CI covers 0.14.1 / 0.15.2 / 0.16.0.

A repo's build.zig often synthesizes an options module from generated
values (git commit, release version, feature flags) and imports it under
a fixed name. tigerbeetle is the motivating case: src/config.zig does
@import("vsr_options") and reads config_verify (bool), git_commit
(?[40]u8), release and release_client_min ([]const u8). Azazel's
build_options could only surface CLI flags (#Option: bool/string/u32),
so a module needing injected values could not compile without the repo's
own build.zig.

Add an option_values list to #Module: each entry is a typed literal
(bool / string / u32 / opt_commit, where opt_commit is a ?[40]u8 git
hash, null unless a 40-char value is given). They are added to the same
options module as build_options and imported under build_options_import.

Verified end to end by building tigerbeetle's whole vsr library on 0.14:
config.zig reads all four vsr_options fields via a comptime field loop,
so a missing or mistyped field would fail to compile.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@godofecht
godofecht merged commit 8bd638d into main Aug 5, 2026
3 checks passed
@godofecht
godofecht deleted the feat/injected-option-values branch August 5, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant