From ffc61e367f170b3fb2c60acc6ffd7e06a295aa32 Mon Sep 17 00:00:00 2001 From: Jae B Date: Tue, 18 Nov 2025 20:04:29 +1100 Subject: [PATCH 1/6] improve C++ include support so that openxr_loader will build for Android with Zig --- src/androidbuild/apk.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/androidbuild/apk.zig b/src/androidbuild/apk.zig index b60ef4f..8dfe248 100644 --- a/src/androidbuild/apk.zig +++ b/src/androidbuild/apk.zig @@ -770,7 +770,7 @@ fn updateLinkObjects(apk: *Apk, root_artifact: *Step.Compile, so_dir: []const u8 // Update libraries linked to this library apk.updateLinkObjects(artifact, so_dir, raw_top_level_apk_files); - // Apply workaround for Zig 0.14.0 + // Apply workaround for Zig 0.14.0 and Zig 0.15.X apk.applyLibLinkCppWorkaroundIssue19(artifact); }, else => continue, @@ -806,6 +806,11 @@ fn applyLibLinkCppWorkaroundIssue19(apk: *Apk, artifact: *Step.Compile) void { artifact.root_module.addLibraryPath(libcppabi_dir); + // NOTE(jae): 2025-11-18 + // Due to Android include files not being provided by Zig, we should provide them if the library is linking against C++ + // This resolves an issue where if you are trying to build the openxr_loader C++ code from source, it can't find standard library includes like or + artifact.addIncludePath(.{ .cwd_relative = b.fmt("{s}/usr/include/c++/v1", .{apk.ndk.sysroot_path}) }); + if (artifact.root_module.link_libcpp == true) { // NOTE(jae): 2025-04-06 // Don't explicitly linkLibCpp From 8a8da0a2661f63df067fb92488cf2aa400840843 Mon Sep 17 00:00:00 2001 From: Jae B Date: Wed, 19 Nov 2025 12:16:52 +1100 Subject: [PATCH 2/6] improve installation documentation --- README.md | 11 ++++++++--- build.zig.zon | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0c89aa1..039cdff 100644 --- a/README.md +++ b/README.md @@ -48,17 +48,22 @@ pub fn build(b: *std.Build) !void { ## Installation -Add the following to your build.zig.zon file and run `zig build`. +Option A. Install with package manager +```sh +zig fetch --save https://github.com/silbinarywolf/zig-android-sdk/archive/REPLACE_WITH_WANTED_COMMIT.tar.gz" +``` +Option B. Copy-paste the dependency into your project directly. This is recommended if you want to easily hack on it or tweak it. ```zig .{ + .name = .yourzigproject, .dependencies = .{ .android = .{ - .path = "https://github.com/silbinarywolf/zig-android-sdk/archive/REPLACE_WITH_WANTED_COMMIT.tar.gz", - // .hash = REPLACE_WITH_HASH_FROM_BUILD_ERROR + .path = "third-party/zig-android-sdk", }, }, } + ``` ## Examples diff --git a/build.zig.zon b/build.zig.zon index 8b19a3c..ccd6e4a 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .android, - .version = "0.1.0", + .version = "0.2.0", .dependencies = .{}, .paths = .{ "build.zig", From 0012176bd51e3726b60338461d1a88cc4509176d Mon Sep 17 00:00:00 2001 From: Jae B Date: Wed, 19 Nov 2025 12:20:11 +1100 Subject: [PATCH 3/6] fix trailing newline in example --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 039cdff..817c92e 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Option A. Install with package manager zig fetch --save https://github.com/silbinarywolf/zig-android-sdk/archive/REPLACE_WITH_WANTED_COMMIT.tar.gz" ``` -Option B. Copy-paste the dependency into your project directly. This is recommended if you want to easily hack on it or tweak it. +Option B. Copy-paste the dependency into your project directly and put in a `third-party` folder. This is recommended if you want to easily hack on it or tweak it. ```zig .{ .name = .yourzigproject, @@ -63,7 +63,6 @@ Option B. Copy-paste the dependency into your project directly. This is recommen }, }, } - ``` ## Examples From 0baa556f69be94680a1a9161193b1b69b3a800df Mon Sep 17 00:00:00 2001 From: Jae B Date: Thu, 20 Nov 2025 16:03:55 +1100 Subject: [PATCH 4/6] fix zig 0.16.x compat --- src/androidbuild/tools.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/androidbuild/tools.zig b/src/androidbuild/tools.zig index 1900476..68c06d8 100644 --- a/src/androidbuild/tools.zig +++ b/src/androidbuild/tools.zig @@ -313,7 +313,10 @@ pub fn createKeyStore(sdk: *const Sdk, options: CreateKey) KeyStore { // ignore stderr, it just gives you an output like: // "Generating 4,096 bit RSA key pair and self-signed certificate (SHA384withRSA) with a validity of 10,000 days // for: CN=example.com, OU=ID, O=Example, L=Doe, ST=Jane, C=GB" - _ = keytool.captureStdErr(); + _ = if (builtin.zig_version.major == 0 and builtin.zig_version.minor <= 15) + keytool.captureStdErr() + else + keytool.captureStdErr(.{}); return .{ .file = keystore_file, .password = options.password, From 906073f6be4c0b308786ffe2b15fa9fab7bd66d7 Mon Sep 17 00:00:00 2001 From: Jae B Date: Thu, 20 Nov 2025 17:54:44 +1100 Subject: [PATCH 5/6] fix zig 0.16.x compat 2 --- src/androidbuild/apk.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/androidbuild/apk.zig b/src/androidbuild/apk.zig index 8dfe248..167eba9 100644 --- a/src/androidbuild/apk.zig +++ b/src/androidbuild/apk.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const builtin = @import("builtin"); const androidbuild = @import("androidbuild.zig"); const Sdk = @import("tools.zig"); const BuiltinOptionsUpdate = @import("builtin_options_update.zig"); @@ -394,7 +395,11 @@ fn doInstallApk(apk: *Apk) std.mem.Allocator.Error!*Step.InstallFile { }); aapt2packagename.setName(runNameContext("aapt2 dump packagename")); aapt2packagename.addFileArg(resources_apk); - break :blk aapt2packagename.captureStdOut(); + const aapt2_package_name_file = if (builtin.zig_version.major == 0 and builtin.zig_version.minor <= 15) + aapt2packagename.captureStdOut() + else + keytool.captureStdOut(.{}); + break :blk aapt2_package_name_file; }; const android_builtin = blk: { From 6638256185256b6cc8ac8d545f54a1aa53de4edf Mon Sep 17 00:00:00 2001 From: Jae B Date: Fri, 21 Nov 2025 10:25:53 +1100 Subject: [PATCH 6/6] fix 3 --- src/androidbuild/apk.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/androidbuild/apk.zig b/src/androidbuild/apk.zig index 167eba9..c047126 100644 --- a/src/androidbuild/apk.zig +++ b/src/androidbuild/apk.zig @@ -398,7 +398,7 @@ fn doInstallApk(apk: *Apk) std.mem.Allocator.Error!*Step.InstallFile { const aapt2_package_name_file = if (builtin.zig_version.major == 0 and builtin.zig_version.minor <= 15) aapt2packagename.captureStdOut() else - keytool.captureStdOut(.{}); + aapt2packagename.captureStdOut(.{}); break :blk aapt2_package_name_file; };