Skip to content

Commit

Permalink
Support Zig 0.14.0-dev.2534+12d64c456
Browse files Browse the repository at this point in the history
  • Loading branch information
castholm committed Dec 19, 2024
1 parent db0e7ac commit ec656e1
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ pub fn build(b: *std.Build) void {
const use_gles = b.option(bool, "gles", "Build with GLES; not supported on MacOS") orelse false;
const use_metal = b.option(bool, "metal", "Build with Metal; only supported on MacOS") orelse true;

const lib = std.Build.Step.Compile.create(b, .{
.name = "glfw",
.kind = .lib,
.linkage = if (shared) .dynamic else .static,
.root_module = .{
const lib: *std.Build.Step.Compile = switch (shared) {
inline else => |x| switch (x) {
false => std.Build.addStaticLibrary,
true => std.Build.addSharedLibrary,
}(b, .{
.name = "glfw",
.target = target,
.optimize = optimize,
},
});
}),
};
lib.addIncludePath(b.path("include"));
lib.linkLibC();

if (shared) lib.defineCMacro("_GLFW_BUILD_DLL", "1");
if (shared) lib.root_module.addCMacro("_GLFW_BUILD_DLL", "1");

lib.installHeadersDirectory(b.path("include/GLFW"), "GLFW", .{});
// GLFW headers depend on these headers, so they must be distributed too.
Expand Down Expand Up @@ -53,7 +54,7 @@ pub fn build(b: *std.Build) void {

if (target.result.isDarwin()) {
// MacOS: this must be defined for macOS 13.3 and older.
lib.defineCMacro("__kernel_ptr_semantics", "");
lib.root_module.addCMacro("__kernel_ptr_semantics", "");

if (b.lazyDependency("xcode_frameworks", .{
.target = target,
Expand Down Expand Up @@ -142,7 +143,7 @@ pub fn build(b: *std.Build) void {
}

if (use_wl) {
lib.defineCMacro("WL_MARSHAL_FLAG_DESTROY", "1");
lib.root_module.addCMacro("WL_MARSHAL_FLAG_DESTROY", "1");

sources.appendSlice(&linux_wl_sources) catch unreachable;
flags.append("-D_GLFW_WAYLAND") catch unreachable;
Expand Down

0 comments on commit ec656e1

Please sign in to comment.