glfw: tidy up Options struct
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
ef4e335ccd
commit
a5eadec686
1 changed files with 23 additions and 8 deletions
31
build.zig
31
build.zig
|
@ -14,15 +14,26 @@ pub fn build(b: *Builder) void {
|
||||||
test_step.dependOn(&main_tests.step);
|
test_step.dependOn(&main_tests.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn thisDir() []const u8 {
|
pub const LinuxWindowManager = enum {
|
||||||
return std.fs.path.dirname(@src().file) orelse ".";
|
X11,
|
||||||
}
|
Wayland,
|
||||||
|
};
|
||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
Vulkan: bool = true,
|
// Not supported on macOS.
|
||||||
Metal: bool = true,
|
vulkan: bool = true,
|
||||||
OpenGL: bool = false,
|
|
||||||
GLES: bool = false,
|
// Only respected on macOS.
|
||||||
|
metal: bool = true,
|
||||||
|
|
||||||
|
// Deprecated on macOS.
|
||||||
|
opengl: bool = false,
|
||||||
|
|
||||||
|
// Not supported on macOS.
|
||||||
|
gles: bool = false,
|
||||||
|
|
||||||
|
// Only respected on Linux.
|
||||||
|
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 {
|
||||||
|
@ -116,6 +127,10 @@ pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
|
||||||
linkGLFW(b, step, options);
|
linkGLFW(b, step, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn thisDir() []const u8 {
|
||||||
|
return std.fs.path.dirname(@src().file) orelse ".";
|
||||||
|
}
|
||||||
|
|
||||||
fn linkGLFW(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {
|
fn linkGLFW(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {
|
||||||
var include_dir = std.fs.path.join(b.allocator, &.{ thisDir(), "upstream/glfw/include" }) catch unreachable;
|
var include_dir = std.fs.path.join(b.allocator, &.{ thisDir(), "upstream/glfw/include" }) catch unreachable;
|
||||||
defer b.allocator.free(include_dir);
|
defer b.allocator.free(include_dir);
|
||||||
|
@ -141,7 +156,7 @@ fn linkGLFW(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void
|
||||||
step.linkFramework("Cocoa");
|
step.linkFramework("Cocoa");
|
||||||
step.linkFramework("IOKit");
|
step.linkFramework("IOKit");
|
||||||
step.linkFramework("CoreFoundation");
|
step.linkFramework("CoreFoundation");
|
||||||
if (options.OpenGL) {
|
if (options.opengl) {
|
||||||
step.linkFramework("OpenGL");
|
step.linkFramework("OpenGL");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue