From 7a03a73ee07cae3d7add503c57d653476c77ddff Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Mon, 3 Jul 2023 08:49:38 -0700 Subject: [PATCH] glfw: eliminate system-sdk for linux and windows use the package manager instead Signed-off-by: Stephen Gutekanst --- libs/glfw/build.zig | 39 +++++++++++++++++++++++++++++---------- libs/glfw/build.zig.zon | 12 ++++++++++++ libs/glfw/src/c.zig | 1 + 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/libs/glfw/build.zig b/libs/glfw/build.zig index 6b450174..e077c365 100644 --- a/libs/glfw/build.zig +++ b/libs/glfw/build.zig @@ -83,14 +83,7 @@ pub fn link(b: *Build, step: *std.build.CompileStep, options: Options) !void { step.linkLibrary(lib); addGLFWIncludes(step); linkGLFWDependencies(b, step, options); - if (step.target_info.target.os.tag != .windows) system_sdk.include(b, step, options.system_sdk); - if (step.target_info.target.os.tag == .windows) { - step.linkLibrary(b.dependency("direct3d_headers", .{ - .target = step.target, - .optimize = step.optimize, - }).artifact("direct3d-headers")); - @import("direct3d_headers").addLibraryPath(step); - } + if (step.target_info.target.os.tag == .macos) system_sdk.include(b, step, options.system_sdk); } fn buildLibrary(b: *Build, optimize: std.builtin.OptimizeMode, target: std.zig.CrossTarget, options: Options) !*std.build.CompileStep { @@ -117,7 +110,6 @@ fn buildLibrary(b: *Build, optimize: std.builtin.OptimizeMode, target: std.zig.C fn addGLFWIncludes(step: *std.build.CompileStep) void { step.addIncludePath(sdkPath("/upstream/glfw/include")); - step.addIncludePath(sdkPath("/upstream/vulkan_headers/include")); step.addIncludePath(sdkPath("/src")); } @@ -162,8 +154,35 @@ fn addGLFWSources(b: *Build, lib: *std.build.CompileStep, options: Options) std. } fn linkGLFWDependencies(b: *Build, step: *std.build.CompileStep, options: Options) void { + if (step.target_info.target.os.tag == .windows) { + step.linkLibrary(b.dependency("direct3d_headers", .{ + .target = step.target, + .optimize = step.optimize, + }).artifact("direct3d-headers")); + } + if (options.x11) { + step.linkLibrary(b.dependency("x11_headers", .{ + .target = step.target, + .optimize = step.optimize, + }).artifact("x11-headers")); + } + if (options.vulkan) { + step.linkLibrary(b.dependency("vulkan_headers", .{ + .target = step.target, + .optimize = step.optimize, + }).artifact("vulkan-headers")); + } + if (options.wayland) { + step.defineCMacro("WL_MARSHAL_FLAG_DESTROY", null); + step.linkLibrary(b.dependency("wayland_headers", .{ + .target = step.target, + .optimize = step.optimize, + }).artifact("wayland-headers")); + } + if (step.target_info.target.os.tag == .windows) @import("direct3d_headers").addLibraryPath(step); + step.linkLibC(); - if (step.target_info.target.os.tag != .windows) system_sdk.include(b, step, options.system_sdk); + if (step.target_info.target.os.tag == .macos) system_sdk.include(b, step, options.system_sdk); switch (step.target_info.target.os.tag) { .windows => { step.linkSystemLibraryName("gdi32"); diff --git a/libs/glfw/build.zig.zon b/libs/glfw/build.zig.zon index 3a84c492..96111124 100644 --- a/libs/glfw/build.zig.zon +++ b/libs/glfw/build.zig.zon @@ -6,5 +6,17 @@ .url = "https://github.com/hexops/direct3d-headers/archive/773dce3f079eecdccc7c71d1318a0741649d568b.tar.gz", .hash = "12200d2155216c5eb5f111282cd355b5433cad6a68fd040294e695149cba329f7c12", }, + .vulkan_headers = .{ + .url = "https://github.com/hexops/vulkan-headers/archive/e1b061ff624531e82a7daea5dbd56c07e08bf0be.tar.gz", + .hash = "12204967f9d07fda3af6a21d6ab71fb832da2186176c530a7a14aa96043537399e6b", + }, + .wayland_headers = .{ + .url = "https://github.com/hexops/wayland-headers/archive/7bf46f3d60edab2171643ff85770c392ef62704d.tar.gz", + .hash = "1220689912c40c0880b094f748199c490810d4fa4c58ce1ef9058ce97f46ee28496a", + }, + .x11_headers = .{ + .url = "https://github.com/hexops/x11-headers/archive/1db4df130531c6889df664541bc62161510b9189.tar.gz", + .hash = "12208b3ccaec785e9344472c08bada6137d60666f0d52fc8cf62aae4251056db7737", + }, }, } diff --git a/libs/glfw/src/c.zig b/libs/glfw/src/c.zig index 98063687..5d018ee5 100644 --- a/libs/glfw/src/c.zig +++ b/libs/glfw/src/c.zig @@ -1,4 +1,5 @@ pub const c = @cImport({ @cDefine("GLFW_INCLUDE_VULKAN", "1"); + @cDefine("GLFW_INCLUDE_NONE", "1"); @cInclude("GLFW/glfw3.h"); });