Skip to content

Pass a fields string-list option through pkg_imports - #40

Merged
godofecht merged 1 commit into
mainfrom
feat/pkg-import-fields
Aug 5, 2026
Merged

Pass a fields string-list option through pkg_imports#40
godofecht merged 1 commit into
mainfrom
feat/pkg-import-fields

Conversation

@godofecht

Copy link
Copy Markdown
Owner

What

Adds a fields string-list to #PackageImport, passed to the dependency as .fields = @as([]const []const u8, ...) alongside target/optimize, and only when non-empty. Ordinary imports are untouched.

Why

Some package dependencies select which data tables to compile in via a fields build option. uucode is the motivating case: it exposes only the Unicode property tables a consumer names. libvaxis's vaxis module depends on uucode with exactly four fields (east_asian_width, grapheme_break, general_category, is_emoji_presentation). Before this, pkg_imports could pass target/optimize and a graphics backend, but not a string-list option, so that module could not be modeled. This mirrors the existing backend passthrough (added for zig-gamedev).

How it flows

  • schema.cue: fields: [...string] | *[] on #PackageImport.
  • gen_build_spec.sh: fields added to the generated PackageImport struct and emitter.
  • build.zig: dependencyForImport routes through a new dependencyWithFields helper when fields is non-empty.
  • build_spec_test.zig: asserts each fields entry is non-empty.

Verification

Built libvaxis's vaxis module (zigimg + uucode) on 0.16 with these fields. A probe exe exercising vaxis.gwidth.gwidth (which reads all four uucode fields) compiles and runs; a missing field would fail compilation. Existing spec tests pass on 0.14.1. CI covers 0.14.1 / 0.15.2 / 0.16.0.

🤖 Generated with Claude Code

Some package dependencies select which data tables to compile in via a
`fields` build option, e.g. uucode exposes only the Unicode property
tables a consumer names (east_asian_width, grapheme_break,
general_category, is_emoji_presentation). Azazel's pkg_imports could pass
target/optimize and a graphics backend, but not this option, so a module
depending on uucode could not be modeled.

Add a `fields` string-list to #PackageImport, emitted as
`.fields = @as([]const []const u8, ...)` on the dependency only when
non-empty. Ordinary imports are unaffected. Verified end to end by
building libvaxis's `vaxis` module (zigimg + uucode) on 0.16: a probe exe
that exercises all four uucode fields compiles and runs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@godofecht
godofecht merged commit 9e507c1 into main Aug 5, 2026
3 checks passed
@godofecht
godofecht deleted the feat/pkg-import-fields branch August 5, 2026 17:59
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