Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/minimal/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub fn build(b: *std.Build) void {
const exe_name: []const u8 = "minimal";
const root_target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const android_targets = android.standardTargets(b, root_target);
const android_targets = android.standardTargets(b, root_target, null);

var root_target_single = [_]std.Build.ResolvedTarget{root_target};
const targets: []std.Build.ResolvedTarget = if (android_targets.len == 0)
Expand Down
2 changes: 1 addition & 1 deletion examples/raylib/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const exe_name = "raylib";
pub fn build(b: *std.Build) void {
const root_target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const android_targets = android.standardTargets(b, root_target);
const android_targets = android.standardTargets(b, root_target, null);

var root_target_single = [_]std.Build.ResolvedTarget{root_target};
const targets: []std.Build.ResolvedTarget = if (android_targets.len == 0)
Expand Down
2 changes: 1 addition & 1 deletion examples/sdl2/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const android = @import("android");
pub fn build(b: *std.Build) void {
const root_target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const android_targets = android.standardTargets(b, root_target);
const android_targets = android.standardTargets(b, root_target, null);

const crash_on_exception = b.option(bool, "crash-on-exception", "if true then we'll use the activity from androidCrashTest folder") orelse false;

Expand Down
15 changes: 7 additions & 8 deletions src/androidbuild/androidbuild.zig
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ pub fn getAndroidTriple(target: ResolvedTarget) error{InvalidAndroidTarget}![]co
};
}

/// Will return a slice of Android targets
/// - If -Dandroid=true, return all Android targets (x86, x86_64, aarch64, etc)
/// - If -Dtarget=aarch64-linux-android, return a slice with the one specified Android target
///
/// If none of the above, then return a zero length slice.
pub fn standardTargets(b: *std.Build, target: ResolvedTarget) []ResolvedTarget {
const all_targets = b.option(bool, "android", "if true, build for all Android targets (x86, x86_64, aarch64, etc)") orelse false;
if (all_targets) {
/// Return a slice of Android targets
/// - If `all_targets` is true, returns all Android targets (x86, x86_64, aarch64, etc)
/// - If `all_targets` is null and `-Dandroid=true`, returns all Android targets
/// - If `target` uses the Android ABI, returns a slice with the specified target
/// - Otherwise, returns a zero length slice
pub fn standardTargets(b: *std.Build, target: ResolvedTarget, all_targets: ?bool) []ResolvedTarget {
if (all_targets orelse b.option(bool, "android", "if true, build for all Android targets (x86, x86_64, aarch64, etc)") orelse false) {
return getAllAndroidTargets(b);
}
if (!target.result.abi.isAndroid()) {
Expand Down
Loading