Skip to content

Commit abeec4e

Browse files
fix Raylib example and add to CI (#53)
fix Raylib example and add to CI
1 parent 4758c1a commit abeec4e

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
- name: Setup Android SDK
3636
uses: android-actions/setup-android@v3
3737
with:
38+
# 35.0.0 = Android 15
3839
packages: 'tools platform-tools platforms;android-35 build-tools;35.0.0 ndk;29.0.13113456'
3940

4041
#
@@ -58,6 +59,10 @@ jobs:
5859
zig build -Dandroid=true --verbose
5960
zig build -Dandroid=true -Dcrash-on-exception --verbose
6061
working-directory: examples/sdl2
62+
63+
- name: Build Raylib Example (Zig Stable)
64+
run: zig build -Dandroid=true --verbose
65+
working-directory: examples/raylib
6166

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

119+
# "Raylib requires zig version 0.15.1" error occurs
120+
# - name: Build Raylib Example (Zig Previous Stable)
121+
# run: zig build -Dandroid=true --verbose
122+
# working-directory: examples/raylib
123+
114124
#
115125
# Nightly Zig Builds
116126
#
@@ -127,3 +137,7 @@ jobs:
127137
- name: Build SDL2 Example (Zig Nightly)
128138
run: zig build -Dandroid=true --verbose
129139
working-directory: examples/sdl2
140+
141+
- name: Build Raylib Example (Zig Stable)
142+
run: zig build -Dandroid=true --verbose
143+
working-directory: examples/raylib

examples/raylib/build.zig

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {
1919

2020
const android_sdk = android.Sdk.create(b, .{});
2121
const apk = android_sdk.createApk(.{
22-
.api_level = .android10,
22+
.api_level = .android15,
2323
.build_tools_version = "35.0.1",
2424
.ndk_version = "29.0.13113456",
2525
});
@@ -37,13 +37,18 @@ pub fn build(b: *std.Build) void {
3737
.root_source_file = b.path("src/main.zig"),
3838
.target = target,
3939
.optimize = optimize,
40+
.link_libc = true,
4041
});
4142
const lib = b.addLibrary(.{
4243
.linkage = .dynamic,
4344
.name = exe_name,
4445
.root_module = lib_mod,
46+
// note(jae): 2025-09-19
47+
// Force use_llvm = true, to workaround issue in Zig 0.15.1 where an error occurs with
48+
// - step: compile lib raylib Debug x86_64-linux-android failure
49+
// panic: "TODO unhandled compression scheme"
50+
.use_llvm = if (target.result.abi.isAndroid()) true else null,
4551
});
46-
lib.linkLibC();
4752
b.installArtifact(lib);
4853

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

6375
const raylib_artifact = raylib_dep.artifact("raylib");
64-
lib.linkLibrary(raylib_artifact);
76+
lib.root_module.linkLibrary(raylib_artifact);
6577
const raylib_mod = raylib_dep.module("raylib");
6678
lib.root_module.addImport("raylib", raylib_mod);
6779

6880
if (android_apk) |apk| {
6981
const android_dep = b.dependency("android", .{
70-
.optimize = optimize,
7182
.target = target,
83+
.optimize = optimize,
7284
});
7385
lib.root_module.addImport("android", android_dep.module("android"));
7486
lib.root_module.linkSystemLibrary("android", .{});
@@ -78,7 +90,7 @@ pub fn build(b: *std.Build) void {
7890
lib.root_module.addIncludePath(native_app_glue_dir);
7991
apk.addArtifact(lib);
8092
} else {
81-
const exe = b.addExecutable(.{ .name = exe_name, .optimize = optimize, .root_module = lib_mod });
93+
const exe = b.addExecutable(.{ .name = exe_name, .root_module = lib_mod });
8294
b.installArtifact(exe);
8395

8496
const run_exe = b.addRunArtifact(exe);

examples/raylib/build.zig.zon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
.dependencies = .{
77
.android = .{ .path = "../.." },
88
.raylib_zig = .{
9-
.url = "git+https://github.com/not-nik/raylib-zig#5013830647196ba938a3a25a36b8245606e9a9cd",
10-
.hash = "raylib_zig-5.6.0-dev-KE8REM0tBQAHVn9Xjqlgu9l1qgfTmP8aJa1kLhD584bV",
9+
.url = "git+https://github.com/raylib-zig/raylib-zig#d64fc43f38949231dc7d6f1c016db8fcae858b8c",
10+
.hash = "raylib_zig-5.6.0-dev-KE8REDc2BQCri1t11guC1tZA-Luc7NuVeml_59LSELLe",
1111
},
1212
},
1313
.paths = .{

0 commit comments

Comments
 (0)