glfw: build Linux sources

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-07-10 11:25:04 -07:00
parent e19751d91a
commit c5c278232a

View file

@ -33,7 +33,7 @@ pub const Options = struct {
gles: bool = false, gles: bool = false,
// Only respected on Linux. // Only respected on Linux.
linux_window_manager: LinuxWindowManager = .X11, linux_window_manager: LinuxWindowManager = .X11,
}; };
pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void { pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {
@ -102,22 +102,56 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
}, },
else => { else => {
// Assume Linux-like // Assume Linux-like
// TODO(slimsag): implement var general_sources = std.ArrayList([]const u8).init(&arena.allocator);
for ([_][]const u8{
// General Linux-like sources
"upstream/glfw/src/posix_time.c",
"upstream/glfw/src/posix_thread.c",
"upstream/glfw/src/linux_joystick.c",
// upstream/glfw/src/posix_time.c // General sources
// upstream/glfw/src/posix_thread.c "upstream/glfw/src/monitor.c",
"upstream/glfw/src/init.c",
"upstream/glfw/src/vulkan.c",
"upstream/glfw/src/input.c",
"upstream/glfw/src/osmesa_context.c",
"upstream/glfw/src/egl_context.c",
"upstream/glfw/src/context.c",
"upstream/glfw/src/window.c",
}) |path| {
var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable;
general_sources.append(abs_path) catch unreachable;
}
lib.addCSourceFiles(general_sources.items, &.{});
// upstream/glfw/src/wl_monitor.c switch (options.linux_window_manager) {
// upstream/glfw/src/wl_window.c .X11 => {
// upstream/glfw/src/wl_init.c var x11_sources = std.ArrayList([]const u8).init(&arena.allocator);
for ([_][]const u8{
// upstream/glfw/src/x11_init.c "upstream/glfw/src/x11_init.c",
// upstream/glfw/src/x11_window.c "upstream/glfw/src/x11_window.c",
// upstream/glfw/src/x11_monitor.c "upstream/glfw/src/x11_monitor.c",
// upstream/glfw/src/xkb_unicode.c "upstream/glfw/src/xkb_unicode.c",
"upstream/glfw/src/glx_context.c",
// upstream/glfw/src/linux_joystick.c }) |path| {
// upstream/glfw/src/glx_context.c var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable;
x11_sources.append(abs_path) catch unreachable;
}
lib.addCSourceFiles(x11_sources.items, &.{});
},
.Wayland => {
var wayland_sources = std.ArrayList([]const u8).init(&arena.allocator);
for ([_][]const u8{
"upstream/glfw/src/wl_monitor.c",
"upstream/glfw/src/wl_window.c",
"upstream/glfw/src/wl_init.c",
}) |path| {
var abs_path = std.fs.path.join(&arena.allocator, &.{ thisDir(), path }) catch unreachable;
wayland_sources.append(abs_path) catch unreachable;
}
lib.addCSourceFiles(wayland_sources.items, &.{});
},
}
}, },
} }
linkGLFW(b, lib, options); linkGLFW(b, lib, options);