Allow explicitly requesting all targets#82
Closed
ypsvlq wants to merge 1 commit intosilbinarywolf:mainfrom
Closed
Conversation
Owner
|
Thanks for the PR. Instead of breaking the existing simple function, I've opted to take the approach outlined in this PR here: #83 I wasn't aware of |
silbinarywolf
added a commit
that referenced
this pull request
Apr 11, 2026
Based on request here: #82 Example usage: ```zig // Example usage in Zig 0.16.0-dev.3061+9b1eaad13 pub fn build(b: *std.Build) void { const exe_name: []const u8 = "minimal"; const root_target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const all_android_targets = b.option(bool, "android", "Build for all Android targets (x86, x86_64, aarch64, arm, etc)") orelse false; const android_targets: []std.Build.ResolvedTarget = blk: { if (all_android_targets or root_target.result.abi.isAndroid()) { if (b.lazyImport(@this(), "android")) |android| { break :blk android.resolveTargets(b, .{ .default_target = root_target, .all_targets = all_android_targets, }); } } break :blk &[0]std.Build.ResolvedTarget{}; }; ``` I opted to look at how Zig separates build option creation for targets and took a similar route, for example Zig has `resolveTarget` for handling the logic without invoking `b.option` ```zig /// Exposes standard `zig build` options for choosing a target and additionally /// resolves the target query. pub fn standardTargetOptions(b: *Build, args: StandardTargetOptionsArgs) ResolvedTarget { const query = b.standardTargetOptionsQueryOnly(args); return b.resolveTargetQuery(query); } ```
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.
My project uses zig-android-sdk as a lazy dependency, so I want to write something like:
but currently this doesn't work as a build option with a given name can only be declared once.