summaryrefslogtreecommitdiffhomepage
path: root/src/build.zig
diff options
context:
space:
mode:
authorTommi Sinivuo <[email protected]>2021-09-25 20:24:48 +0300
committerGitHub <[email protected]>2021-09-25 19:24:48 +0200
commit206e1def6f888cbf69bdf0138f4e1a67a0377e4f (patch)
tree36c2a887f8154d374f171f4eca0bcdfa048d765c /src/build.zig
parentb7063ab879a5ae4975e323cdcf94e4ec2528b206 (diff)
downloadraylib-206e1def6f888cbf69bdf0138f4e1a67a0377e4f.tar.gz
raylib-206e1def6f888cbf69bdf0138f4e1a67a0377e4f.zip
Add Zig build file (#2014)
The build file builds Raylib as a static library for either Windows or Linux.
Diffstat (limited to 'src/build.zig')
-rw-r--r--src/build.zig58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/build.zig b/src/build.zig
new file mode 100644
index 00000000..2c304a52
--- /dev/null
+++ b/src/build.zig
@@ -0,0 +1,58 @@
+const std = @import("std");
+
+pub fn build(b: *std.build.Builder) void {
+ // Standard target options allows the person running `zig build` to choose
+ // what target to build for. Here we do not override the defaults, which
+ // means any target is allowed, and the default is native. Other options
+ // for restricting supported target set are available.
+ const target = b.standardTargetOptions(.{});
+
+ // Standard release options allow the person running `zig build` to select
+ // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
+ const mode = b.standardReleaseOptions();
+
+ const raylib_flags = &[_][]const u8{
+ "-std=gnu99",
+ "-DPLATFORM_DESKTOP",
+ "-DGL_SILENCE_DEPRECATION",
+ "-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/1891
+ };
+
+ const raylib = b.addStaticLibrary("raylib", "raylib.h");
+ raylib.setTarget(target);
+ raylib.setBuildMode(mode);
+ raylib.linkLibC();
+
+ raylib.addIncludeDir("external/glfw/include");
+
+ raylib.addCSourceFile("rcore.c", raylib_flags);
+ raylib.addCSourceFile("rmodels.c", raylib_flags);
+ raylib.addCSourceFile("raudio.c", raylib_flags);
+ raylib.addCSourceFile("rshapes.c", raylib_flags);
+ raylib.addCSourceFile("rtext.c", raylib_flags);
+ raylib.addCSourceFile("rtextures.c", raylib_flags);
+ raylib.addCSourceFile("utils.c", raylib_flags);
+ raylib.addCSourceFile("rglfw.c", raylib_flags);
+
+ switch (raylib.target.toTarget().os.tag) {
+ .windows => {
+ raylib.linkSystemLibrary("winmm");
+ raylib.linkSystemLibrary("gdi32");
+ raylib.linkSystemLibrary("opengl32");
+ raylib.addIncludeDir("external/glfw/deps/mingw");
+ },
+ .linux => {
+ raylib.linkSystemLibrary("GL");
+ raylib.linkSystemLibrary("rt");
+ raylib.linkSystemLibrary("dl");
+ raylib.linkSystemLibrary("m");
+ raylib.linkSystemLibrary("X11");
+ },
+ else => {
+ @panic("Unsupported OS");
+ },
+ }
+
+ raylib.setOutputDir("./");
+ raylib.install();
+}