Skip to content

Commit db03d58

Browse files
committed
do the work
1 parent ea49343 commit db03d58

File tree

13 files changed

+143
-139
lines changed

13 files changed

+143
-139
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Setup Android SDK
3737
uses: android-actions/setup-android@v3
3838
with:
39-
packages: 'tools platform-tools platforms;android-35 build-tools;35.0.0 ndk;27.0.12077973'
39+
packages: 'tools platform-tools platforms;android-35 build-tools;35.0.0 ndk;29.0.13113456'
4040

4141
- name: Setup Zig 0.13.0
4242
# note(jae): 2024-09-15
@@ -53,22 +53,3 @@ jobs:
5353
- name: Build SDL2 Example (Zig 0.13.0)
5454
run: zig build -Dandroid=true --verbose
5555
working-directory: examples/sdl2
56-
57-
- name: Setup Zig Nightly
58-
uses: mlugg/setup-zig@v1
59-
with:
60-
version: "master"
61-
62-
- name: Build Minimal Example (Zig Nightly)
63-
run: zig build -Dandroid=true --verbose
64-
working-directory: examples/minimal
65-
66-
- name: Build SDL2 Example (Zig Nightly)
67-
# "zig build -Dandroid=true" fails for 0.14.0-dev.1632
68-
#
69-
# android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:322:42:
70-
# error: expression is not an integral constant expression
71-
#
72-
# See: https://github.com/silbinarywolf/zig-android-sdk/actions/runs/10979711793/job/30484520174?pr=5#step:10:30
73-
run: zig build -Dtarget=x86_64-linux-android --verbose
74-
working-directory: examples/sdl2

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ zig build -Dandroid=true
1818
```zig
1919
// This is an overly simplified example to give you the gist
2020
// of how this library works, see: examples/minimal/build.zig
21-
const android = @import("zig-android-sdk");
21+
const android = @import("android");
2222
2323
pub fn build(b: *std.Build) !void {
2424
const android_tools = android.Tools.create(b, ...);
@@ -52,7 +52,7 @@ Add the following to your build.zig.zon file and run `zig build`.
5252
```zig
5353
.{
5454
.dependencies = .{
55-
.@"zig-android-sdk" = .{
55+
.android = .{
5656
.path = "https://github.com/silbinarywolf/zig-android-sdk/archive/REPLACE_WITH_WANTED_COMMIT.tar.gz",
5757
// .hash = REPLACE_WITH_HASH_FROM_BUILD_ERROR
5858
},

build.zig.zon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
.{
2-
.name = "zig-android-sdk",
2+
.name = "android",
33
.version = "0.1.0",
44
.dependencies = .{},
55
.paths = .{
66
"build.zig",
77
"build.zig.zon",
88
"src",
99
},
10+
.minimum_zig_version = "0.13.0",
11+
.fingerprint = 0x92bcb62d42fb2cee,
1012
}

examples/minimal/build.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const std = @import("std");
22
const builtin = @import("builtin");
3-
const android = @import("zig-android-sdk");
3+
const android = @import("android");
44

55
pub fn build(b: *std.Build) void {
66
const exe_name: []const u8 = "minimal";
@@ -22,7 +22,7 @@ pub fn build(b: *std.Build) void {
2222
const android_tools = android.Tools.create(b, .{
2323
.api_level = .android15,
2424
.build_tools_version = "35.0.0",
25-
.ndk_version = "27.0.12077973",
25+
.ndk_version = "29.0.13113456",
2626
});
2727
const apk = android.APK.create(b, android_tools);
2828

@@ -52,9 +52,9 @@ pub fn build(b: *std.Build) void {
5252
// if building as library for Android, add this target
5353
// NOTE: Android has different CPU targets so you need to build a version of your
5454
// code for x86, x86_64, arm, arm64 and more
55-
if (target.result.isAndroid()) {
55+
if (target.result.abi == .android) {
5656
const apk: *android.APK = android_apk orelse @panic("Android APK should be initialized");
57-
const android_dep = b.dependency("zig-android-sdk", .{
57+
const android_dep = b.dependency("android", .{
5858
.optimize = optimize,
5959
.target = target,
6060
});

examples/minimal/build.zig.zon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.name = "minimal",
33
.version = "0.0.0",
44
.dependencies = .{
5-
.@"zig-android-sdk" = .{
5+
.android = .{
66
.path = "../..",
77
},
88
},
@@ -11,4 +11,5 @@
1111
"build.zig.zon",
1212
"src",
1313
},
14+
.fingerprint = 0x4037f28ad1eb4832,
1415
}

examples/minimal/src/minimal.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const androidbind = @import("android-bind.zig");
55
const log = std.log;
66

77
/// custom standard options for Android
8-
pub const std_options: std.Options = if (builtin.abi == .android)
8+
pub const std_options: std.Options = if (builtin.abi.isAndroid())
99
.{
1010
.logFn = android.logFn,
1111
}
1212
else
1313
.{};
1414

1515
/// custom panic handler for Android
16-
pub const panic = if (builtin.abi == .android)
16+
pub const panic = if (builtin.abi.isAndroid())
1717
android.panic
1818
else
1919
std.builtin.default_panic;

examples/sdl2/android/src/ZigSDLActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class ZigSDLActivity extends SDLActivity {
99
// @Override
1010
// protected String[] getLibraries() {
1111
// return new String[] {
12-
// "hidapi",
1312
// "SDL2",
1413
// // "SDL2_image",
1514
// // "SDL2_mixer",

examples/sdl2/build.zig

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const std = @import("std");
22
const builtin = @import("builtin");
3-
const android = @import("zig-android-sdk");
3+
const android = @import("android");
44

55
pub fn build(b: *std.Build) void {
66
const root_target = b.standardTargetOptions(.{});
@@ -21,7 +21,16 @@ pub fn build(b: *std.Build) void {
2121
const android_tools = android.Tools.create(b, .{
2222
.api_level = .android15,
2323
.build_tools_version = "35.0.0",
24-
.ndk_version = "27.0.12077973",
24+
.ndk_version = "29.0.13113456",
25+
// NOTE(jae): 2025-03-09
26+
// Previously this example used 'ndk' "27.0.12077973".
27+
//
28+
// However that has issues with the latest SDL2 version when including 'hardware_buffer.h'
29+
// for 32-bit builds.
30+
//
31+
// - AHARDWAREBUFFER_USAGE_FRONT_BUFFER = 1UL << 32
32+
// - ndk/27.0.12077973/toolchains/llvm/prebuilt/{OS}-x86_64/sysroot/usr/include/android/hardware_buffer.h:322:42:
33+
// - error: expression is not an integral constant expression
2534
});
2635
const apk = android.APK.create(b, android_tools);
2736

@@ -47,7 +56,7 @@ pub fn build(b: *std.Build) void {
4756

4857
for (targets) |target| {
4958
const exe_name: []const u8 = "sdl-zig-demo";
50-
var exe: *std.Build.Step.Compile = if (target.result.isAndroid()) b.addSharedLibrary(.{
59+
var exe: *std.Build.Step.Compile = if (target.result.abi == .android) b.addSharedLibrary(.{
5160
.name = exe_name,
5261
.root_source_file = b.path("src/sdl-zig-demo.zig"),
5362
.target = target,
@@ -65,7 +74,7 @@ pub fn build(b: *std.Build) void {
6574
.optimize = .ReleaseFast,
6675
.target = target,
6776
});
68-
if (target.result.os.tag == .linux and !target.result.isAndroid()) {
77+
if (target.result.os.tag == .linux and target.result.abi != .android) {
6978
// The SDL package doesn't work for Linux yet, so we rely on system
7079
// packages for now.
7180
exe.linkSystemLibrary("SDL2");
@@ -75,22 +84,16 @@ pub fn build(b: *std.Build) void {
7584
exe.linkLibrary(sdl_lib);
7685
}
7786

78-
// NOTE(jae): 2024-09-22
79-
// Load additional dynamic libraries that SDLActivity.java loads such as hidapi
80-
if (target.result.isAndroid()) {
81-
exe.linkLibrary(sdl_dep.artifact("hidapi"));
82-
}
83-
8487
const sdl_module = sdl_dep.module("sdl");
8588
exe.root_module.addImport("sdl", sdl_module);
8689
}
8790

8891
// if building as library for Android, add this target
8992
// NOTE: Android has different CPU targets so you need to build a version of your
9093
// code for x86, x86_64, arm, arm64 and more
91-
if (target.result.isAndroid()) {
94+
if (target.result.abi == .android) {
9295
const apk: *android.APK = android_apk orelse @panic("Android APK should be initialized");
93-
const android_dep = b.dependency("zig-android-sdk", .{
96+
const android_dep = b.dependency("android", .{
9497
.optimize = optimize,
9598
.target = target,
9699
});

examples/sdl2/build.zig.zon

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.{
2-
.name = "minimal",
2+
.name = "sdl2",
33
.version = "0.0.0",
44
.dependencies = .{
5-
.@"zig-android-sdk" = .{
5+
.android = .{
66
.path = "../..",
77
},
88
.sdl2 = .{
@@ -14,4 +14,5 @@
1414
"build.zig.zon",
1515
"src",
1616
},
17+
.fingerprint = 0x168fc6b9a7d0df48,
1718
}

0 commit comments

Comments
 (0)