From 0284173d16cd25c141fdc15fcd8ab497de6a8303 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Tue, 23 Jan 2024 12:21:58 -0600 Subject: [PATCH] chore: update to baf012836e9b1cb9ae11f0c67e6149976081e022 --- build.zig | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/build.zig b/build.zig index 1ab9e19..08fd840 100644 --- a/build.zig +++ b/build.zig @@ -1,8 +1,5 @@ const std = @import("std"); -const zglfw = @import("zglfw"); -const zgpu = @import("zgpu"); - pub const Backend = enum { no_backend, glfw_wgpu, @@ -29,18 +26,18 @@ pub const Package = struct { options: Options, zgui: *std.Build.Module, zgui_options: *std.Build.Module, - zgui_c_cpp: *std.Build.CompileStep, + zgui_c_cpp: *std.Build.Step.Compile, - pub fn link(pkg: Package, exe: *std.Build.CompileStep) void { + pub fn link(pkg: Package, exe: *std.Build.Step.Compile) void { exe.linkLibrary(pkg.zgui_c_cpp); - exe.addModule("zgui", pkg.zgui); - exe.addModule("zgui_options", pkg.zgui_options); + exe.root_module.addImport("zgui", pkg.zgui); + exe.root_module.addImport("zgui_options", pkg.zgui_options); } }; pub fn package( b: *std.Build, - target: std.zig.CrossTarget, + target: std.Build.ResolvedTarget, optimize: std.builtin.Mode, args: struct { options: Options, @@ -53,8 +50,8 @@ pub fn package( const zgui_options = step.createModule(); const zgui = b.addModule("zgui", .{ - .source_file = .{ .path = thisDir() ++ "/src/gui.zig" }, - .dependencies = &.{ + .root_source_file = .{ .path = thisDir() ++ "/src/gui.zig" }, + .imports = &.{ .{ .name = "zgui_options", .module = zgui_options }, }, }); @@ -67,13 +64,13 @@ pub fn package( }); b.installArtifact(lib); - if (target.isWindows()) { + if (target.result.os.tag == .windows) { lib.defineCMacro("IMGUI_API", "__declspec(dllexport)"); lib.defineCMacro("IMPLOT_API", "__declspec(dllexport)"); lib.defineCMacro("ZGUI_API", "__declspec(dllexport)"); } - if (target.isDarwin()) { + if (target.result.os.tag == .macos) { lib.linker_allow_shlib_undefined = true; } @@ -87,7 +84,7 @@ pub fn package( zgui_c_cpp.addIncludePath(.{ .path = thisDir() ++ "/libs" }); zgui_c_cpp.addIncludePath(.{ .path = thisDir() ++ "/libs/imgui" }); - const abi = (std.zig.system.NativeTargetInfo.detect(target) catch unreachable).target.abi; + const abi = target.result.abi; zgui_c_cpp.linkLibC(); if (abi != .msvc) zgui_c_cpp.linkLibCpp(); @@ -128,8 +125,10 @@ pub fn package( switch (args.options.backend) { .glfw_wgpu => { - zgui_c_cpp.addIncludePath(.{ .path = zglfw.path ++ "/libs/glfw/include" }); - zgui_c_cpp.addIncludePath(.{ .path = zgpu.path ++ "/libs/dawn/include" }); + const zglfw = b.dependency("zglfw", .{}); + const zgpu = b.dependency("zgpu", .{}); + zgui_c_cpp.addIncludePath(.{ .path = zglfw.path("libs/glfw/include").getPath(b) }); + zgui_c_cpp.addIncludePath(.{ .path = zgpu.path("libs/dawn/include").getPath(b) }); zgui_c_cpp.addCSourceFiles(.{ .files = &.{ thisDir() ++ "/libs/imgui/backends/imgui_impl_glfw.cpp", @@ -139,8 +138,8 @@ pub fn package( }); }, .glfw_opengl3 => { - zgui_c_cpp.addIncludePath(.{ .path = zglfw.path ++ "/libs/glfw/include" }); - zgui_c_cpp.addIncludePath(.{ .path = zgpu.path ++ "/libs/dawn/include" }); + const zglfw = b.dependency("zglfw", .{}); + zgui_c_cpp.addIncludePath(.{ .path = zglfw.path("libs/glfw/include").getPath(b) }); zgui_c_cpp.addCSourceFiles(.{ .files = &.{ thisDir() ++ "/libs/imgui/backends/imgui_impl_glfw.cpp", @@ -157,8 +156,8 @@ pub fn package( }, .flags = cflags, }); - zgui_c_cpp.linkSystemLibraryName("d3dcompiler_47"); - zgui_c_cpp.linkSystemLibraryName("dwmapi"); + zgui_c_cpp.linkSystemLibrary("d3dcompiler_47"); + zgui_c_cpp.linkSystemLibrary("dwmapi"); }, .no_backend => {}, } @@ -203,7 +202,7 @@ pub fn build(b: *std.Build) void { pub fn runTests( b: *std.Build, optimize: std.builtin.OptimizeMode, - target: std.zig.CrossTarget, + target: std.Build.ResolvedTarget, ) *std.Build.Step { const gui_tests = b.addTest(.{ .name = "gui-tests",