@@ -48,6 +48,7 @@ android_manifest: ?LazyPath,
4848artifacts : std .ArrayListUnmanaged (* Step .Compile ),
4949java_files : std .ArrayListUnmanaged (LazyPath ),
5050resources : std .ArrayListUnmanaged (Resource ),
51+ assets : std .ArrayListUnmanaged (Resource ),
5152
5253pub const Options = struct {
5354 /// ie. "35.0.0"
@@ -93,6 +94,7 @@ pub fn create(sdk: *Sdk, options: Options) *Apk {
9394 .artifacts = .empty ,
9495 .java_files = .empty ,
9596 .resources = .empty ,
97+ .assets = .empty
9698 };
9799 return apk ;
98100}
@@ -117,6 +119,15 @@ pub fn addResourceDirectory(apk: *Apk, dir: LazyPath) void {
117119 }) catch @panic ("OOM" );
118120}
119121
122+ pub fn addAssetDirectory (apk : * Apk , dir : LazyPath ) void {
123+ const b = apk .b ;
124+ apk .assets .append (b .allocator , Resource {
125+ .directory = .{
126+ .source = dir ,
127+ },
128+ }) catch @panic ("OOM" );
129+ }
130+
120131/// Add artifact to the Android build, this should be a shared library (*.so)
121132/// that targets x86, x86_64, aarch64, etc
122133pub fn addArtifact (apk : * Apk , compile : * std.Build.Step.Compile ) void {
@@ -345,14 +356,15 @@ fn doInstallApk(apk: *Apk) std.mem.Allocator.Error!*Step.InstallFile {
345356 aapt2link .addArg ("-o" );
346357 const resources_apk_file = aapt2link .addOutputFileArg ("resources.apk" );
347358
348- // TODO(jae): 2024-09-17
349- // Add support for asset directories
350- // Additional directory
351- // aapt.step.dependOn(&resource_write_files.step);
352- // for (app_config.asset_directories) |dir| {
353- // make_unsigned_apk.addArg("-A"); // additional directory in which to find raw asset files
354- // make_unsigned_apk.addArg(sdk.b.pathFromRoot(dir));
355- // }
359+ // Add assets
360+ for (apk .assets .items ) | asset | {
361+ switch (asset ) {
362+ .directory = > | asset_dir | {
363+ aapt2link .addArg ("-A" );
364+ aapt2link .addDirectoryArg (asset_dir .source );
365+ }
366+ }
367+ }
356368
357369 // Add resource files
358370 for (apk .resources .items ) | resource | {
0 commit comments