Set APK name explicitly (#80) · silbinarywolf/zig-android-sdk@d6f20c3 · GitHub
Skip to content

Commit d6f20c3

Browse files
authored
Set APK name explicitly (#80)
- Prevents link issues caused by renaming a library but not changing its SONAME - Allows multiple artifacts to be added for the same architecture Fixes #39
1 parent a32c14d commit d6f20c3

5 files changed

Lines changed: 26 additions & 17 deletions

File tree

‎README.md‎

Lines changed: 10 additions & 6 deletions

‎examples/minimal/build.zig‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn build(b: *std.Build) void {
1919

2020
const android_sdk = android.Sdk.create(b, .{});
2121
const apk = android_sdk.createApk(.{
22+
.name = exe_name,
2223
.api_level = .android15,
2324
.build_tools_version = "35.0.1",
2425
.ndk_version = "29.0.13113456",
@@ -50,7 +51,7 @@ pub fn build(b: *std.Build) void {
5051
});
5152

5253
var exe: *std.Build.Step.Compile = if (target.result.abi.isAndroid()) b.addLibrary(.{
53-
.name = exe_name,
54+
.name = "main",
5455
.root_module = app_module,
5556
.linkage = .dynamic,
5657
}) else b.addExecutable(.{

‎examples/raylib/build.zig‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ const std = @import("std");
22
const android = @import("android");
33
const LinkMode = std.builtin.LinkMode;
44

5-
const exe_name = "raylib";
6-
75
pub fn build(b: *std.Build) void {
6+
const exe_name = "raylib";
87
const root_target = b.standardTargetOptions(.{});
98
const optimize = b.standardOptimizeOption(.{});
109
const android_targets = android.standardTargets(b, root_target);
@@ -20,6 +19,7 @@ pub fn build(b: *std.Build) void {
2019

2120
const android_sdk = android.Sdk.create(b, .{});
2221
const apk = android_sdk.createApk(.{
22+
.name = exe_name,
2323
.api_level = .android15,
2424
.build_tools_version = "35.0.1",
2525
.ndk_version = "29.0.13113456",
@@ -72,7 +72,7 @@ pub fn build(b: *std.Build) void {
7272

7373
apk.addArtifact(b.addLibrary(.{
7474
.linkage = .dynamic,
75-
.name = exe_name,
75+
.name = "main",
7676
.root_module = app,
7777
}));
7878
} else {

‎examples/sdl2/build.zig‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const builtin = @import("builtin");
33
const android = @import("android");
44

55
pub fn build(b: *std.Build) void {
6+
const exe_name: []const u8 = "sdl-zig-demo";
67
const root_target = b.standardTargetOptions(.{});
78
const optimize = b.standardOptimizeOption(.{});
89
const android_targets = android.standardTargets(b, root_target);
@@ -20,6 +21,7 @@ pub fn build(b: *std.Build) void {
2021

2122
const android_sdk = android.Sdk.create(b, .{});
2223
const apk = android_sdk.createApk(.{
24+
.name = exe_name,
2325
.api_level = .android15,
2426
.build_tools_version = "36.1.0",
2527
.ndk_version = "29.0.14206865",
@@ -68,7 +70,6 @@ pub fn build(b: *std.Build) void {
6870
};
6971

7072
for (targets) |target| {
71-
const exe_name: []const u8 = "sdl-zig-demo";
7273
const app_module = b.createModule(.{
7374
.target = target,
7475
.optimize = optimize,
@@ -115,7 +116,7 @@ pub fn build(b: *std.Build) void {
115116
app_module.addImport("android", android_dep.module("android"));
116117

117118
const exe_lib = b.addLibrary(.{
118-
.name = exe_name,
119+
.name = "main",
119120
.root_module = app_module,
120121
.linkage = .dynamic,
121122
});

‎src/androidbuild/Apk.zig‎

Lines changed: 8 additions & 5 deletions

0 commit comments

Comments
 (0)