Skip to content

Commit 0a64d73

Browse files
authored
Merge branch 'main' into main
2 parents 7b5eb8e + 991b3c5 commit 0a64d73

4 files changed

Lines changed: 154 additions & 71 deletions

File tree

.github/workflows/ci.yml

Lines changed: 122 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,87 @@ concurrency:
1111
group: ${{ github.head_ref || github.run_id }}-${{ github.actor }}
1212
cancel-in-progress: true
1313

14+
env:
15+
CI_JAVA_VERSION: 17
16+
# 35.0.0 = Android 15
17+
CI_ANDROID_SDK: "tools platform-tools platforms;android-35 build-tools;35.0.0 ndk;29.0.13113456"
18+
CI_ZIG_PREVIOUS_STABLE_VERSION: "0.14.0"
19+
CI_ZIG_STABLE_VERSION: "0.15.1"
20+
1421
jobs:
15-
build:
16-
name: Build
22+
# NOTE(jae): 2026-02-01
23+
# Run a Zig format check before any other steps on latest Zig stable
24+
format:
25+
name: zig fmt --check
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v6
29+
30+
- name: Setup Zig
31+
uses: mlugg/setup-zig@v2
32+
33+
# Run AST check
34+
#
35+
# Specifically ignore ./src/android as the runtime has different Zig version for compile-time features
36+
# like @EnumLiteral
37+
- name: AST Check (src/androidbuild)
38+
run: |
39+
zig fmt --ast-check ./build.zig
40+
zig fmt --ast-check ./src/androidbuild
41+
42+
# Run format check
43+
- name: Zig Format Check
44+
run: zig fmt --check .
45+
46+
# https://stackoverflow.com/questions/73797254/environment-variables-in-github-actions
47+
setup:
48+
name: setup environment variables as outputs
49+
needs: [format]
50+
runs-on: ubuntu-latest
51+
steps:
52+
- run: echo "null"
53+
outputs:
54+
java-version: ${{ env.CI_JAVA_VERSION }}
55+
android-sdk: ${{ env.CI_ANDROID_SDK }}
56+
zig-stable-version: ${{ env.CI_ZIG_STABLE_VERSION }}
57+
zig-previous-stable-version: ${{ env.CI_ZIG_PREVIOUS_STABLE_VERSION }}
58+
59+
60+
build-stable:
61+
name: Build Zig Stable
62+
needs: [setup]
63+
runs-on: ${{matrix.os}}
1764
strategy:
65+
max-parallel: 1
1866
matrix:
1967
include:
2068
- os: "ubuntu-latest"
2169
- os: "windows-latest"
2270
- os: "macos-14" # arm64 as per table: https://github.com/actions/runner-images/blob/8a1eeaf6ac70c66f675a04078d1a7222edd42008/README.md#available-images
23-
24-
runs-on: ${{matrix.os}}
2571

2672
steps:
2773
- uses: actions/checkout@v6
2874

29-
- name: Set up JDK 17
75+
# Setup Java and Android SDK
76+
- name: Set up JDK ${{ needs.setup.outputs.java-version }}
3077
uses: actions/setup-java@v5
3178
with:
32-
java-version: '17'
33-
distribution: 'temurin'
79+
java-version: ${{ needs.setup.outputs.java-version }}
80+
distribution: "temurin"
3481

3582
- name: Setup Android SDK
3683
uses: android-actions/setup-android@v3
3784
with:
38-
# 35.0.0 = Android 15
39-
packages: 'tools platform-tools platforms;android-35 build-tools;35.0.0 ndk;29.0.13113456'
85+
packages: ${{ needs.setup.outputs.android-sdk }}
4086

41-
#
42-
# Stable Zig Builds
43-
#
44-
45-
- name: Setup Zig Stable (0.15.2)
87+
# Setup Zig version and run examples
88+
- name: Setup Zig
4689
# note(jae): 2024-09-15
4790
# Uses download mirror first as preferred by Zig Foundation
4891
# see: https://ziglang.org/news/migrate-to-self-hosting/
4992
uses: mlugg/setup-zig@v2
5093
with:
51-
version: "0.15.2"
94+
version: ${{ needs.setup.outputs.zig-stable-version }}
5295

5396
- name: Build Minimal Example (Zig Stable)
5497
run: zig build -Dandroid=true --verbose
@@ -99,32 +142,34 @@ jobs:
99142
# adb shell monkey --kill-process-after-error --monitor-native-crashes --pct-touch 100 -p com.zig.sdl2 --throttle 1000 -v 2
100143
# working-directory: examples/sdl2
101144

102-
#
103-
# Previous Stable Zig Build
104-
#
145+
build-nightly:
146+
name: Build Zig Nightly
147+
needs: [setup]
148+
runs-on: ${{matrix.os}}
149+
strategy:
150+
max-parallel: 1
151+
matrix:
152+
include:
153+
- os: "ubuntu-latest"
154+
- os: "windows-latest"
155+
- os: "macos-14" # arm64 as per table: https://github.com/actions/runner-images/blob/8a1eeaf6ac70c66f675a04078d1a7222edd42008/README.md#available-images
156+
157+
steps:
158+
- uses: actions/checkout@v6
105159

106-
- name: Setup Zig Previous Stable (0.14.0)
107-
uses: mlugg/setup-zig@v2
160+
# Setup Java and Android SDK
161+
- name: Set up JDK ${{ needs.setup.outputs.java-version }}
162+
uses: actions/setup-java@v5
108163
with:
109-
version: "0.14.0"
110-
111-
- name: Build Minimal Example (Zig Previous Stable)
112-
run: zig build -Dandroid=true --verbose
113-
working-directory: examples/minimal
114-
115-
- name: Build SDL2 Example (Zig Previous Stable)
116-
run: zig build -Dandroid=true --verbose
117-
working-directory: examples/sdl2
118-
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
164+
java-version: ${{ needs.setup.outputs.java-version }}
165+
distribution: "temurin"
123166

124-
#
125-
# Nightly Zig Builds
126-
#
167+
- name: Setup Android SDK
168+
uses: android-actions/setup-android@v3
169+
with:
170+
packages: ${{ needs.setup.outputs.android-sdk }}
127171

172+
# Setup Zig version and run examples
128173
- name: Setup Zig Nightly
129174
uses: mlugg/setup-zig@v2
130175
with:
@@ -144,3 +189,43 @@ jobs:
144189
# - name: Build Raylib Example (Zig Nightly)
145190
# run: zig build -Dandroid=true --verbose
146191
# working-directory: examples/raylib
192+
build-previous-stable:
193+
name: Build Zig Previous
194+
needs: [setup]
195+
runs-on: ${{matrix.os}}
196+
strategy:
197+
max-parallel: 1
198+
matrix:
199+
include:
200+
- os: "ubuntu-latest"
201+
- os: "windows-latest"
202+
- os: "macos-14" # arm64 as per table: https://github.com/actions/runner-images/blob/8a1eeaf6ac70c66f675a04078d1a7222edd42008/README.md#available-images
203+
204+
steps:
205+
- uses: actions/checkout@v6
206+
207+
# Setup Java and Android SDK
208+
- name: Set up JDK ${{ needs.setup.outputs.java-version }}
209+
uses: actions/setup-java@v5
210+
with:
211+
java-version: ${{ needs.setup.outputs.java-version }}
212+
distribution: "temurin"
213+
214+
- name: Setup Android SDK
215+
uses: android-actions/setup-android@v3
216+
with:
217+
packages: ${{ needs.setup.outputs.android-sdk }}
218+
219+
# Setup Zig version and run examples
220+
- name: Setup Zig
221+
uses: mlugg/setup-zig@v2
222+
with:
223+
version: ${{ needs.setup.outputs.zig-previous-stable-version }}
224+
225+
- name: Build Minimal Example
226+
run: zig build -Dandroid=true --verbose
227+
working-directory: examples/minimal
228+
229+
- name: Build SDL2 Example
230+
run: zig build -Dandroid=true --verbose
231+
working-directory: examples/sdl2

examples/raylib/build.zig

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const android = @import("android");
21
const std = @import("std");
2+
const android = @import("android");
3+
const LinkMode = std.builtin.LinkMode;
34

45
const exe_name = "raylib";
56

@@ -33,64 +34,49 @@ pub fn build(b: *std.Build) void {
3334
};
3435

3536
for (targets) |target| {
36-
const lib_mod = b.createModule(.{
37+
const app = b.createModule(.{
3738
.root_source_file = b.path("src/main.zig"),
3839
.target = target,
3940
.optimize = optimize,
4041
.link_libc = true,
4142
});
42-
const lib = b.addLibrary(.{
43-
.linkage = .dynamic,
44-
.name = exe_name,
45-
.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,
51-
});
52-
b.installArtifact(lib);
5343

5444
const raylib_dep = if (android_apk) |apk|
5545
b.dependency("raylib_zig", .{
5646
.target = target,
5747
.optimize = optimize,
5848
.android_api_version = @as([]const u8, b.fmt("{}", .{@intFromEnum(apk.api_level)})),
5949
.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
6750
})
6851
else
6952
b.dependency("raylib_zig", .{
7053
.target = target,
7154
.optimize = optimize,
72-
.linkage = std.builtin.LinkMode.dynamic,
55+
.linkage = LinkMode.dynamic,
7356
});
7457

75-
const raylib_artifact = raylib_dep.artifact("raylib");
76-
lib.root_module.linkLibrary(raylib_artifact);
77-
const raylib_mod = raylib_dep.module("raylib");
78-
lib.root_module.addImport("raylib", raylib_mod);
58+
app.linkLibrary(raylib_dep.artifact("raylib"));
59+
app.addImport("raylib", raylib_dep.module("raylib"));
7960

8061
if (android_apk) |apk| {
8162
const android_dep = b.dependency("android", .{
8263
.target = target,
8364
.optimize = optimize,
8465
});
85-
lib.root_module.addImport("android", android_dep.module("android"));
86-
lib.root_module.linkSystemLibrary("android", .{});
66+
app.addImport("android", android_dep.module("android"));
67+
app.linkSystemLibrary("android", .{});
8768

8869
const native_app_glue_dir: std.Build.LazyPath = .{ .cwd_relative = b.fmt("{s}/sources/android/native_app_glue", .{apk.ndk.path}) };
89-
lib.root_module.addCSourceFile(.{ .file = native_app_glue_dir.path(b, "android_native_app_glue.c") });
90-
lib.root_module.addIncludePath(native_app_glue_dir);
91-
apk.addArtifact(lib);
70+
app.addCSourceFile(.{ .file = native_app_glue_dir.path(b, "android_native_app_glue.c") });
71+
app.addIncludePath(native_app_glue_dir);
72+
73+
apk.addArtifact(b.addLibrary(.{
74+
.linkage = .dynamic,
75+
.name = exe_name,
76+
.root_module = app,
77+
}));
9278
} else {
93-
const exe = b.addExecutable(.{ .name = exe_name, .root_module = lib_mod });
79+
const exe = b.addExecutable(.{ .name = exe_name, .root_module = app });
9480
b.installArtifact(exe);
9581

9682
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/raylib-zig/raylib-zig#d64fc43f38949231dc7d6f1c016db8fcae858b8c",
10-
.hash = "raylib_zig-5.6.0-dev-KE8REDc2BQCri1t11guC1tZA-Luc7NuVeml_59LSELLe",
9+
.url = "git+https://github.com/raylib-zig/raylib-zig#cd71c85d571027ac8033357f83b124ee051825b3",
10+
.hash = "raylib_zig-5.6.0-dev-KE8REENOBQC-m5nK7M2b5aKSIubJPbPLUYcRhT7aT3RN",
1111
},
1212
},
1313
.paths = .{

src/androidbuild/apk.zig

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn create(sdk: *Sdk, options: Options) *Apk {
9494
.artifacts = .empty,
9595
.java_files = .empty,
9696
.resources = .empty,
97-
.assets = .empty
97+
.assets = .empty,
9898
};
9999
return apk;
100100
}
@@ -473,6 +473,18 @@ fn doInstallApk(apk: *Apk) std.mem.Allocator.Error!*Step.InstallFile {
473473
@panic(b.fmt("artifact[{d}] has no 'target' set", .{artifact_index}));
474474
};
475475

476+
// NOTE(jae): 2026-02-01
477+
// If not explicitly set in users build, default to using LLVM and LLD for Android builds
478+
// as that's the same toolchain that the Android SDK uses.
479+
//
480+
// This also can resolve issues with Zigs linker not yet supporting certain compression schemes/etc
481+
if (artifact.use_llvm == null) {
482+
artifact.use_llvm = true;
483+
}
484+
if (artifact.use_lld == null) {
485+
artifact.use_lld = true;
486+
}
487+
476488
// https://developer.android.com/ndk/guides/abis#native-code-in-app-packages
477489
const so_dir: []const u8 = switch (target.result.cpu.arch) {
478490
.aarch64 => "arm64-v8a",

0 commit comments

Comments
 (0)