11const std = @import ("std" );
22const androidbuild = @import ("androidbuild.zig" );
3- const Tools = @import ("tools.zig" );
3+ const Sdk = @import ("tools.zig" );
44const BuiltinOptionsUpdate = @import ("builtin_options_update.zig" );
55
66const Ndk = @import ("Ndk.zig" );
77const BuildTools = @import ("BuildTools.zig" );
88const D8Glob = @import ("d8glob.zig" );
99
10- const KeyStore = Tools .KeyStore ;
10+ const KeyStore = Sdk .KeyStore ;
1111const ApiLevel = androidbuild .ApiLevel ;
1212const getAndroidTriple = androidbuild .getAndroidTriple ;
1313const runNameContext = androidbuild .runNameContext ;
@@ -32,7 +32,7 @@ pub const Resource = union(enum) {
3232};
3333
3434b : * std.Build ,
35- tools : * Tools ,
35+ sdk : * Sdk ,
3636/// Path to Native Development Kit, this includes various C-code headers, libraries, and more.
3737/// ie. $ANDROID_HOME/ndk/29.0.13113456
3838ndk : Ndk ,
@@ -57,17 +57,17 @@ pub const Options = struct {
5757 api_level : ApiLevel ,
5858};
5959
60- pub fn create (tools : * Tools , options : Options ) * Apk {
61- const b = tools .b ;
60+ pub fn create (sdk : * Sdk , options : Options ) * Apk {
61+ const b = sdk .b ;
6262
6363 var errors = std .ArrayList ([]const u8 ).init (b .allocator );
6464 defer errors .deinit ();
6565
66- const build_tools = BuildTools .init (b , tools .android_sdk_path , options .build_tools_version , & errors ) catch | err | switch (err ) {
66+ const build_tools = BuildTools .init (b , sdk .android_sdk_path , options .build_tools_version , & errors ) catch | err | switch (err ) {
6767 error .BuildToolFailed = > BuildTools .empty , // fallthruogh and print all errors below
6868 error .OutOfMemory = > @panic ("OOM" ),
6969 };
70- const ndk = Ndk .init (b , tools .android_sdk_path , options .ndk_version , & errors ) catch | err | switch (err ) {
70+ const ndk = Ndk .init (b , sdk .android_sdk_path , options .ndk_version , & errors ) catch | err | switch (err ) {
7171 error .NdkFailed = > Ndk .empty , // fallthrough and print all errors below
7272 error .OutOfMemory = > @panic ("OOM" ),
7373 };
@@ -79,7 +79,7 @@ pub fn create(tools: *Tools, options: Options) *Apk {
7979 const apk : * Apk = b .allocator .create (Apk ) catch @panic ("OOM" );
8080 apk .* = .{
8181 .b = b ,
82- .tools = tools ,
82+ .sdk = sdk ,
8383 .ndk = ndk ,
8484 .build_tools = build_tools ,
8585 .api_level = options .api_level ,
@@ -180,7 +180,7 @@ fn addLibraryPaths(apk: *Apk, module: *std.Build.Module) void {
180180 // ie. $ANDROID_HOME/ndk/{ndk_version}/sources/android/cpufeatures
181181 if (target .result .cpu .arch == .arm ) {
182182 module .addIncludePath (.{
183- .cwd_relative = b .fmt ("{s}/ndk/{s}/sources/android/cpufeatures" , .{ apk .tools .android_sdk_path , apk .ndk .version }),
183+ .cwd_relative = b .fmt ("{s}/ndk/{s}/sources/android/cpufeatures" , .{ apk .sdk .android_sdk_path , apk .ndk .version }),
184184 });
185185 }
186186
@@ -281,7 +281,7 @@ fn doInstallApk(apk: *Apk) std.mem.Allocator.Error!*Step.InstallFile {
281281
282282 // ie. "$ANDROID_HOME/Sdk/platforms/android-{api_level}/android.jar"
283283 const root_jar = b .pathResolve (&[_ ][]const u8 {
284- apk .tools .android_sdk_path ,
284+ apk .sdk .android_sdk_path ,
285285 "platforms" ,
286286 b .fmt ("android-{d}" , .{@intFromEnum (apk .api_level )}),
287287 "android.jar" ,
@@ -503,7 +503,7 @@ fn doInstallApk(apk: *Apk) std.mem.Allocator.Error!*Step.InstallFile {
503503 if (apk .java_files .items .len > 0 ) {
504504 // https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html
505505 const javac_cmd = b .addSystemCommand (&[_ ][]const u8 {
506- apk .tools .java_tools .javac ,
506+ apk .sdk .java_tools .javac ,
507507 // NOTE(jae): 2024-09-22
508508 // Force encoding to be "utf8", this fixes the following error occuring in Windows:
509509 // error: unmappable character (0x8F) for encoding windows-1252
@@ -557,7 +557,7 @@ fn doInstallApk(apk: *Apk) std.mem.Allocator.Error!*Step.InstallFile {
557557 // See: https://musteresel.github.io/posts/2019/07/build-android-app-bundle-on-command-line.html
558558 {
559559 const jar = b .addSystemCommand (&[_ ][]const u8 {
560- apk .tools .java_tools .jar ,
560+ apk .sdk .java_tools .jar ,
561561 });
562562 jar .setName (runNameContext ("jar (unzip resources.apk)" ));
563563 if (b .verbose ) {
@@ -601,7 +601,7 @@ fn doInstallApk(apk: *Apk) std.mem.Allocator.Error!*Step.InstallFile {
601601 // - {directory with all resource files like: AndroidManifest.xml, res/values/strings.xml}
602602 const zip_file : LazyPath = blk : {
603603 const jar = b .addSystemCommand (&[_ ][]const u8 {
604- apk .tools .java_tools .jar ,
604+ apk .sdk .java_tools .jar ,
605605 });
606606 jar .setName (runNameContext ("jar (zip compress apk)" ));
607607
@@ -628,7 +628,7 @@ fn doInstallApk(apk: *Apk) std.mem.Allocator.Error!*Step.InstallFile {
628628 // Update zip with files that are not compressed (ie. resources.arsc)
629629 const update_zip : * Step = blk : {
630630 const jar = b .addSystemCommand (&[_ ][]const u8 {
631- apk .tools .java_tools .jar ,
631+ apk .sdk .java_tools .jar ,
632632 });
633633 jar .setName (runNameContext ("jar (update zip with uncompressed files)" ));
634634
@@ -723,7 +723,7 @@ fn getSystemIncludePath(apk: *Apk, target: ResolvedTarget) []const u8 {
723723}
724724
725725fn setLibCFile (apk : * Apk , compile : * Step.Compile ) void {
726- const tools = apk .tools ;
726+ const tools = apk .sdk ;
727727 const android_libc_path = tools .createOrGetLibCFile (compile , apk .api_level , apk .ndk .sysroot_path , apk .ndk .version );
728728 android_libc_path .addStepDependencies (& compile .step );
729729 compile .setLibCFile (android_libc_path );
0 commit comments