diff options
| author | Nikolas <[email protected]> | 2023-02-01 11:09:03 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-01 11:09:03 +0100 |
| commit | 89171a26083da40a3a78dc0f1dee466542ed7668 (patch) | |
| tree | 2028caa72ca1a86de467711dd81dbfabe0f45bb2 /examples/build.zig | |
| parent | c94c666d0493fa32a810863d579d34289d2bfc1b (diff) | |
| download | raylib-89171a26083da40a3a78dc0f1dee466542ed7668.tar.gz raylib-89171a26083da40a3a78dc0f1dee466542ed7668.zip | |
Add WASM support for Zig build (#2901)
* Add WASM support for Zig build
* Improve Web example building
* Remove emscript example building with Zig again
* Readd windows emscripten variables
Diffstat (limited to 'examples/build.zig')
| -rw-r--r-- | examples/build.zig | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/examples/build.zig b/examples/build.zig index cb211aef..eb040fd2 100644 --- a/examples/build.zig +++ b/examples/build.zig @@ -2,6 +2,10 @@ const std = @import("std"); const builtin = @import("builtin"); fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zig.CrossTarget) !*std.build.Step { + if (target.getOsTag() == .emscripten) { + @panic("Emscripten building via Zig unsupported"); + } + // Standard release options allow the person running `zig build` to select // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. const mode = b.standardReleaseOptions(); @@ -19,12 +23,7 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi if (std.mem.eql(u8, "core_loading_thread", name) and target.getOsTag() == .windows) continue; const exe = b.addExecutable(name, null); - exe.addCSourceFile(path, switch (target.getOsTag()) { - .windows => &[_][]const u8{}, - .linux => &[_][]const u8{}, - .macos => &[_][]const u8{"-DPLATFORM_DESKTOP"}, - else => @panic("Unsupported OS"), - }); + exe.addCSourceFile(path, &[_][]const u8{}); exe.setTarget(target); exe.setBuildMode(mode); exe.linkLibC(); @@ -32,6 +31,7 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi .windows => "../src/raylib.lib", .linux => "../src/libraylib.a", .macos => "../src/libraylib.a", + .emscripten => "../src/libraylib.a", else => @panic("Unsupported OS"), }); @@ -39,12 +39,14 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi exe.addIncludePath("../src/external"); exe.addIncludePath("../src/external/glfw/include"); - switch (exe.target.toTarget().os.tag) { + switch (target.getOsTag()) { .windows => { exe.linkSystemLibrary("winmm"); exe.linkSystemLibrary("gdi32"); exe.linkSystemLibrary("opengl32"); exe.addIncludePath("external/glfw/deps/mingw"); + + exe.defineCMacro("PLATFORM_DESKTOP", null); }, .linux => { exe.linkSystemLibrary("GL"); @@ -52,6 +54,8 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi exe.linkSystemLibrary("dl"); exe.linkSystemLibrary("m"); exe.linkSystemLibrary("X11"); + + exe.defineCMacro("PLATFORM_DESKTOP", null); }, .macos => { exe.linkFramework("Foundation"); @@ -60,6 +64,8 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi exe.linkFramework("CoreAudio"); exe.linkFramework("CoreVideo"); exe.linkFramework("IOKit"); + + exe.defineCMacro("PLATFORM_DESKTOP", null); }, else => { @panic("Unsupported OS"); |
