@@ -33,6 +33,8 @@ pub const Resource = union(enum) {
3333};
3434
3535b : * std.Build ,
36+ /// APK file output name, ie. "{name}.apk"
37+ name : []const u8 ,
3638sdk : * Sdk ,
3739/// Path to Native Development Kit, this includes various C-code headers, libraries, and more.
3840/// ie. $ANDROID_HOME/ndk/29.0.13113456
@@ -51,6 +53,8 @@ resources: std.ArrayListUnmanaged(Resource),
5153assets : std .ArrayListUnmanaged (Resource ),
5254
5355pub const Options = struct {
56+ /// APK file output name, ie. "{name}.apk"
57+ name : []const u8 ,
5458 /// ie. "35.0.0"
5559 build_tools_version : []const u8 ,
5660 /// ie. "27.0.12077973"
@@ -85,6 +89,7 @@ pub fn create(sdk: *Sdk, options: Options) *Apk {
8589 const apk : * Apk = b .allocator .create (Apk ) catch @panic ("OOM" );
8690 apk .* = .{
8791 .b = b ,
92+ .name = options .name ,
8893 .sdk = sdk ,
8994 .ndk = ndk ,
9095 .build_tools = build_tools ,
@@ -475,7 +480,7 @@ fn doInstallApk(apk: *Apk) Allocator.Error!*Step.InstallFile {
475480 .x86 = > "x86" ,
476481 else = > @panic (b .fmt ("unsupported or unhandled arch: {s}" , .{@tagName (target .result .cpu .arch )})),
477482 };
478- _ = apk_files .addCopyFile (artifact .getEmittedBin (), b .fmt ("lib/{s}/libmain .so" , .{so_dir }));
483+ _ = apk_files .addCopyFile (artifact .getEmittedBin (), b .fmt ("lib/{s}/lib{s} .so" , .{ so_dir , artifact . name }));
479484
480485 // Add module
481486 // - If a module has no `root_source_file` (e.g you're only compiling C files using `addCSourceFiles`)
@@ -717,8 +722,6 @@ fn doInstallApk(apk: *Apk) Allocator.Error!*Step.InstallFile {
717722 // lint.setEnvironmentVariable("JAVA_HOME", apk.tools.jdk_path);
718723 // lint.addFileArg(android_manifest_file);
719724
720- const apk_name = apk .artifacts .items [0 ].name ;
721-
722725 // Align contents of .apk (zip)
723726 const aligned_apk_file : LazyPath = blk : {
724727 var zipalign = b .addSystemCommand (&[_ ][]const u8 {
@@ -746,7 +749,7 @@ fn doInstallApk(apk: *Apk) Allocator.Error!*Step.InstallFile {
746749 zipalign .addFileArg (zip_file );
747750 zipalign .step .dependOn (update_zip );
748751
749- const apk_file = zipalign .addOutputFileArg (b .fmt ("aligned-{s}.apk" , .{apk_name }));
752+ const apk_file = zipalign .addOutputFileArg (b .fmt ("aligned-{s}.apk" , .{apk . name }));
750753 break :blk apk_file ;
751754 };
752755
@@ -767,7 +770,7 @@ fn doInstallApk(apk: *Apk) Allocator.Error!*Step.InstallFile {
767770 break :blk signed_output_apk_file ;
768771 };
769772
770- const install_apk = b .addInstallBinFile (signed_apk_file , b .fmt ("{s}.apk" , .{apk_name }));
773+ const install_apk = b .addInstallBinFile (signed_apk_file , b .fmt ("{s}.apk" , .{apk . name }));
771774 return install_apk ;
772775}
773776
0 commit comments