Pass a fields string-list option through pkg_imports - #40
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
fieldsstring-list to#PackageImport, passed to the dependency as.fields = @as([]const []const u8, ...)alongsidetarget/optimize, and only when non-empty. Ordinary imports are untouched.Why
Some package dependencies select which data tables to compile in via a
fieldsbuild option. uucode is the motivating case: it exposes only the Unicode property tables a consumer names. libvaxis'svaxismodule depends on uucode with exactly four fields (east_asian_width,grapheme_break,general_category,is_emoji_presentation). Before this,pkg_importscould passtarget/optimizeand a graphicsbackend, but not a string-list option, so that module could not be modeled. This mirrors the existingbackendpassthrough (added for zig-gamedev).How it flows
schema.cue:fields: [...string] | *[]on#PackageImport.gen_build_spec.sh:fieldsadded to the generatedPackageImportstruct and emitter.build.zig:dependencyForImportroutes through a newdependencyWithFieldshelper whenfieldsis non-empty.build_spec_test.zig: asserts eachfieldsentry is non-empty.Verification
Built libvaxis's
vaxismodule (zigimg + uucode) on 0.16 with these fields. A probe exe exercisingvaxis.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