Skip to content

Commit 243ab6a

Browse files
committed
changes as requested
EGL should be linked at the library level now, and only for the appropriate targets. Also some conditional compilation as suggested.
1 parent 9cbe2be commit 243ab6a

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

examples/raylib/build.zig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ pub fn build(b: *std.Build) void {
6868
const raylib_mod = raylib_dep.module("raylib");
6969
lib.root_module.addImport("raylib", raylib_mod);
7070

71-
lib.root_module.linkSystemLibrary("EGL", .{ .preferred_link_mode = .dynamic });
72-
lib.root_module.linkSystemLibrary("GLESv2", .{ .preferred_link_mode = .dynamic });
73-
7471
if (target.result.abi.isAndroid()) {
7572
const apk: *android.APK = android_apk orelse @panic("Android APK should be initialized");
7673
const android_dep = b.dependency("android", .{

examples/raylib/build.zig.zon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
.minimum_zig_version = "0.14.0",
55
.fingerprint = 0x13035e5cf42e313f,
66
.dependencies = .{
7-
.raylib_zig = .{
8-
.url = "git+https://github.com/lumenkeyes/raylib-zig#59263ae0f96f54fa96ba4cb1f77cd3b06cc8fa94",
9-
.hash = "raylib_zig-5.6.0-dev-KE8REG8yBQDVpWX-ireikKit_2m0_E6DkdWGCssSXKHa",
7+
.raylib_zig = .{
8+
.url = "git+https://github.com/lumenkeyes/raylib-zig#b00d4c2b973665e3a88c2565b6cd63c56d0173c2",
9+
.hash = "raylib_zig-5.6.0-dev-KE8REPwqBQC35iWa2sFblBUNWkTlEi1gjit9dtyOLu_b"
1010
},
1111
.android = .{ .path = "../.." },
1212
},

examples/raylib/src/main.zig

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
const std = @import("std");
2+
const builtin = @import("builtin");
3+
const android = @import("android");
24
const rl = @import("raylib");
35

46
//Other than exporting this function and changing the calling convention, you
57
//can write your code fairly normally.
68
//
79
//The main function is not allowed to return zig errors, so you will have to
810
//use "catch @panic()" or create other error handling functionality.
9-
export fn main() callconv(.C) void {
11+
pub fn main() void {
1012
const screenWidth = 800;
1113
const screenHeight = 450;
1214
rl.initWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
@@ -21,3 +23,29 @@ export fn main() callconv(.C) void {
2123
rl.drawText("Congrats! You created your first window!", 190, 200, 20, .light_gray);
2224
}
2325
}
26+
27+
/// custom panic handler for Android
28+
pub const panic = if (builtin.abi.isAndroid())
29+
android.panic
30+
else
31+
std.debug.FullPanic(std.debug.defaultPanic);
32+
33+
/// custom standard options for Android
34+
pub const std_options: std.Options = if (builtin.abi.isAndroid())
35+
.{
36+
.logFn = android.logFn,
37+
}
38+
else
39+
.{};
40+
41+
comptime {
42+
if (builtin.abi.isAndroid()) {
43+
// Setup exported C-function as defined in AndroidManifest.xml
44+
// ie. <meta-data android:name="android.app.lib_name" android:value="main"/>
45+
@export(&androidMain, .{ .name = "main" });
46+
}
47+
}
48+
49+
fn androidMain() callconv(.c) c_int {
50+
return std.start.callMain();
51+
}

0 commit comments

Comments
 (0)