Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
# 35.0.0 = Android 15
packages: 'tools platform-tools platforms;android-35 build-tools;35.0.0 ndk;29.0.13113456'

#
Expand All @@ -58,6 +59,10 @@ jobs:
zig build -Dandroid=true --verbose
zig build -Dandroid=true -Dcrash-on-exception --verbose
working-directory: examples/sdl2

- name: Build Raylib Example (Zig Stable)
run: zig build -Dandroid=true --verbose
working-directory: examples/raylib

# TODO(jae): 2025-03-30
# Need to figure out how to get 'adb shell monkey' to return an error code or be able to return an error code
Expand Down Expand Up @@ -111,6 +116,11 @@ jobs:
run: zig build -Dandroid=true --verbose
working-directory: examples/sdl2

# "Raylib requires zig version 0.15.1" error occurs
# - name: Build Raylib Example (Zig Previous Stable)
# run: zig build -Dandroid=true --verbose
# working-directory: examples/raylib

#
# Nightly Zig Builds
#
Expand All @@ -127,3 +137,7 @@ jobs:
- name: Build SDL2 Example (Zig Nightly)
run: zig build -Dandroid=true --verbose
working-directory: examples/sdl2

- name: Build Raylib Example (Zig Stable)
run: zig build -Dandroid=true --verbose
working-directory: examples/raylib
24 changes: 18 additions & 6 deletions examples/raylib/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {

const android_sdk = android.Sdk.create(b, .{});
const apk = android_sdk.createApk(.{
.api_level = .android10,
.api_level = .android15,
.build_tools_version = "35.0.1",
.ndk_version = "29.0.13113456",
});
Expand All @@ -37,13 +37,18 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
const lib = b.addLibrary(.{
.linkage = .dynamic,
.name = exe_name,
.root_module = lib_mod,
// note(jae): 2025-09-19
// Force use_llvm = true, to workaround issue in Zig 0.15.1 where an error occurs with
// - step: compile lib raylib Debug x86_64-linux-android failure
// panic: "TODO unhandled compression scheme"
.use_llvm = if (target.result.abi.isAndroid()) true else null,
});
lib.linkLibC();
b.installArtifact(lib);

const raylib_dep = if (android_apk) |apk|
Expand All @@ -52,23 +57,30 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
.android_api_version = @as([]const u8, b.fmt("{}", .{@intFromEnum(apk.api_level)})),
.android_ndk = @as([]const u8, apk.ndk.path),
// NOTE(jae): 2025-09-19
// Avoid compilation errors on Linux systems that don't have 'wayland-scanner'
// ie.
// $ zig build -Dandroid=true --verbose
// `wayland-scanner` may not be installed on the system.
// You can switch to X11 in your `build.zig` by changing `Options.linux_display_backend`
.linux_display_backend = .X11, // Avoid build issues on Linux systems
})
else
b.dependency("raylib_zig", .{
.target = target,
.optimize = optimize,
.shared = true,
.linkage = std.builtin.LinkMode.dynamic,
});

const raylib_artifact = raylib_dep.artifact("raylib");
lib.linkLibrary(raylib_artifact);
lib.root_module.linkLibrary(raylib_artifact);
const raylib_mod = raylib_dep.module("raylib");
lib.root_module.addImport("raylib", raylib_mod);

if (android_apk) |apk| {
const android_dep = b.dependency("android", .{
.optimize = optimize,
.target = target,
.optimize = optimize,
});
lib.root_module.addImport("android", android_dep.module("android"));
lib.root_module.linkSystemLibrary("android", .{});
Expand All @@ -78,7 +90,7 @@ pub fn build(b: *std.Build) void {
lib.root_module.addIncludePath(native_app_glue_dir);
apk.addArtifact(lib);
} else {
const exe = b.addExecutable(.{ .name = exe_name, .optimize = optimize, .root_module = lib_mod });
const exe = b.addExecutable(.{ .name = exe_name, .root_module = lib_mod });
b.installArtifact(exe);

const run_exe = b.addRunArtifact(exe);
Expand Down
4 changes: 2 additions & 2 deletions examples/raylib/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
.dependencies = .{
.android = .{ .path = "../.." },
.raylib_zig = .{
.url = "git+https://github.com/not-nik/raylib-zig#5013830647196ba938a3a25a36b8245606e9a9cd",
.hash = "raylib_zig-5.6.0-dev-KE8REM0tBQAHVn9Xjqlgu9l1qgfTmP8aJa1kLhD584bV",
.url = "git+https://github.com/raylib-zig/raylib-zig#d64fc43f38949231dc7d6f1c016db8fcae858b8c",
.hash = "raylib_zig-5.6.0-dev-KE8REDc2BQCri1t11guC1tZA-Luc7NuVeml_59LSELLe",
},
},
.paths = .{
Expand Down
Loading