-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
67 lines (61 loc) · 2.67 KB
/
build.zig
File metadata and controls
67 lines (61 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const opengl = b.option(bool, "opengl", "enables opengl") orelse false;
const wayland = b.option(bool, "wayland", "enables wayland") orelse false;
const vulkan = b.option(bool, "vulkan", "enables vulkan") orelse false;
const cRGFW = b.addTranslateC(.{
.link_libc = true,
.target = target,
.optimize = optimize,
.root_source_file = b.path("RGFW.h")
});
cRGFW.addIncludePath(b.path("."));
cRGFW.defineCMacro("RGFW_IMPLEMENTATION", "");
if (opengl) cRGFW.defineCMacro("RGFW_OPENGL", "");
if (wayland) cRGFW.defineCMacro("RGFW_WAYLAND", "");
if (vulkan) cRGFW.defineCMacro("RGFW_VULKAN", "");
const mod = cRGFW.addModule("RGFW");
switch (target.result.os.tag) {
.linux, .freebsd, .openbsd, .dragonfly => {
if (opengl) mod.linkSystemLibrary("GL", .{.needed = true});
if (vulkan) mod.linkSystemLibrary("vulkan", .{.needed = true});
if (wayland) {
if (opengl) {
mod.linkSystemLibrary("EGL", .{.needed = true});
mod.linkSystemLibrary("wayland-egl", .{.needed = true});
}
mod.addCSourceFiles(.{
.files = &.{
"xdg/xdg-shell.c",
"xdg/xdg-toplevel-icon-v1.c",
"xdg/xdg-output-unstable-v1.c",
"xdg/xdg-decoration-unstable-v1.c",
"xdg/relative-pointer-unstable-v1.c",
"xdg/pointer-constraints-unstable-v1.c",
}
});
mod.addIncludePath(b.path("xdg"));
mod.linkSystemLibrary("wayland-client", .{.needed = true});
mod.linkSystemLibrary("wayland-cursor", .{.needed = true});
mod.linkSystemLibrary("xkbcommon", .{.needed = true});
}
else {
mod.linkSystemLibrary("x11", .{.needed = true});
mod.linkSystemLibrary("xrandr", .{.needed = true});
}
},
.macos => {
mod.linkFramework("CoreVideo", .{.needed = true});
mod.linkFramework("Cocoa", .{.needed = true});
mod.linkFramework("IOKit", .{.needed = true});
if (opengl) mod.linkFramework("OpenGL", .{.needed = true});
},
.windows => {
mod.linkSystemLibrary("gdi32", .{.needed = true});
if (opengl) mod.linkSystemLibrary("opengl32", .{.needed = true});
},
else => {}
}
}