diff --git a/README.md b/README.md index 0c89aa1..817c92e 100644 --- a/README.md +++ b/README.md @@ -48,14 +48,18 @@ 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 and put in a `third-party` folder. 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", }, }, } 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", diff --git a/src/androidbuild/apk.zig b/src/androidbuild/apk.zig index b60ef4f..c047126 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 + aapt2packagename.captureStdOut(.{}); + break :blk aapt2_package_name_file; }; const android_builtin = blk: { @@ -770,7 +775,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 +811,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 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,