Skip to content

Commit 4758c1a

Browse files
authored
Fix build error from adding "android_builtin" import. (#51)
avoid adding `android_builtin` to `root_source_file` if it doesn't exist, this occurs in Zig 0.15.1 if you're only compiling C files using "addCSourceFiles"
1 parent f18f220 commit 4758c1a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/androidbuild/apk.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,11 @@ fn doInstallApk(apk: *Apk) std.mem.Allocator.Error!*Step.InstallFile {
444444
_ = apk_files.addCopyFile(artifact.getEmittedBin(), b.fmt("lib/{s}/libmain.so", .{so_dir}));
445445

446446
// Add module
447-
artifact.root_module.addImport("android_builtin", android_builtin);
447+
// - If a module has no `root_source_file` (e.g you're only compiling C files using `addCSourceFiles`)
448+
// then adding an import module will cause a build error (as of Zig 0.15.1).
449+
if (artifact.root_module.root_source_file != null) {
450+
artifact.root_module.addImport("android_builtin", android_builtin);
451+
}
448452

449453
var modules_it = artifact.root_module.import_table.iterator();
450454
while (modules_it.next()) |entry| {

0 commit comments

Comments
 (0)