From ce63cdfefb38117544d3d65a99a139e057b6c381 Mon Sep 17 00:00:00 2001 From: jack Date: Sun, 5 Jan 2025 13:17:05 +0800 Subject: [PATCH] adapt build system to zig master --- build.zig | 97 ++++++++++++--------------------- build.zig.zon | 2 +- src/vendor/chipmunk/build.zig | 14 ++--- src/vendor/imgui/build.zig | 34 +++++------- src/vendor/nfd/build.zig | 56 +++++++++---------- src/vendor/physfs/build.zig | 30 ++++------ src/vendor/sdl/build.zig | 16 ++---- src/vendor/stb/build.zig | 12 +--- src/vendor/svg/build.zig | 12 +--- src/vendor/system_sdk/build.zig | 26 ++++----- src/vendor/zaudio/build.zig | 38 ++++++------- src/vendor/zmath/build.zig | 8 +-- src/vendor/zmesh/build.zig | 22 +++----- src/vendor/znoise/build.zig | 14 ++--- 14 files changed, 142 insertions(+), 239 deletions(-) diff --git a/build.zig b/build.zig index cc731ce0..a3108322 100644 --- a/build.zig +++ b/build.zig @@ -107,101 +107,76 @@ pub const BuildOptions = struct { pub fn createDesktopApp( b: *Build, name: []const u8, - root_file: []const u8, + game_root: []const u8, target: ResolvedTarget, optimize: std.builtin.Mode, opt: BuildOptions, ) *Build.Step.Compile { assert(target.result.os.tag == .windows or target.result.os.tag == .linux or target.result.os.tag == .macos); - - // Initialize jok - const jok = initJok(b, target, optimize, opt); - - // Initialize sdl2 sdk + const jokmod = getJokModule(b, target, optimize, opt); const sdk = CrossSDL.init(b); - // Create executable + // Create root module const builder = getJokBuilder(b, opt); - const exe = builder.addExecutable(.{ - .name = name, + const root = b.createModule(.{ .root_source_file = builder.path("src/entrypoints/app.zig"), .target = target, .optimize = optimize, }); - exe.root_module.addImport("jok", jok.module); - exe.root_module.addImport("game", builder.createModule(.{ - .root_source_file = b.path(root_file), + const game = builder.createModule(.{ + .root_source_file = b.path(game_root), .imports = &.{ - .{ .name = "jok", .module = jok.module }, + .{ .name = "jok", .module = jokmod }, }, - })); - exe.linkLibrary(jok.lib); + }); + root.addImport("jok", jokmod); + root.addImport("game", game); + + // Create executable + const exe = builder.addExecutable(.{ + .name = name, + .root_module = root, + }); sdk.link(exe, .dynamic); return exe; } -// Create jok module and library -fn initJok( +// Create jok Module +fn getJokModule( b: *Build, target: ResolvedTarget, optimize: std.builtin.Mode, opt: BuildOptions, -) struct { - module: *Build.Module, - lib: *Build.Step.Compile, -} { - // Create module +) *Build.Module { const builder = getJokBuilder(b, opt); const bos = builder.addOptions(); bos.addOption(bool, "no_audio", opt.no_audio); bos.addOption(bool, "use_cp", opt.use_cp); bos.addOption(bool, "use_nfd", opt.use_nfd); - const module = builder.createModule(.{ + const mod = builder.createModule(.{ .root_source_file = builder.path("src/jok.zig"), + .target = target, + .optimize = optimize, .imports = &.{ .{ .name = "build_options", .module = bos.createModule() }, }, }); - // Create library - const lib = builder.addStaticLibrary(.{ - .name = "jok", - .root_source_file = builder.path("src/jok.zig"), - .target = target, - .optimize = optimize, - }); - injectVendorLibraries(builder, lib, target, optimize, opt); - - return .{ .module = module, .lib = lib }; -} - -// Compile vendor libraries into artifact -fn injectVendorLibraries( - b: *Build, - bin: *Build.Step.Compile, - target: ResolvedTarget, - optimize: std.builtin.Mode, - opt: BuildOptions, -) void { - @import("src/vendor/system_sdk/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/system_sdk")); - @import("src/vendor/imgui/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/imgui")); - @import("src/vendor/physfs/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/physfs")); - @import("src/vendor/sdl/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/sdl")); - @import("src/vendor/stb/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/stb")); - @import("src/vendor/svg/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/svg")); - @import("src/vendor/zmath/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/zmath")); - @import("src/vendor/zmesh/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/zmesh")); - @import("src/vendor/znoise/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/znoise")); - if (!opt.no_audio) { - @import("src/vendor/zaudio/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/zaudio")); - } - if (opt.use_cp) { - @import("src/vendor/chipmunk/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/chipmunk")); - } - if (opt.use_nfd) { - @import("src/vendor/nfd/build.zig").inject(b, bin, target, optimize, b.path("src/vendor/nfd")); - } + @import("src/vendor/system_sdk/build.zig").inject(mod, builder.path("src/vendor/system_sdk")); + @import("src/vendor/imgui/build.zig").inject(mod, builder.path("src/vendor/imgui")); + @import("src/vendor/physfs/build.zig").inject(mod, builder.path("src/vendor/physfs")); + @import("src/vendor/sdl/build.zig").inject(mod, builder.path("src/vendor/sdl")); + @import("src/vendor/stb/build.zig").inject(mod, builder.path("src/vendor/stb")); + @import("src/vendor/svg/build.zig").inject(mod, builder.path("src/vendor/svg")); + @import("src/vendor/zmath/build.zig").inject(mod, builder.path("src/vendor/zmath")); + @import("src/vendor/zmesh/build.zig").inject(mod, builder.path("src/vendor/zmesh")); + @import("src/vendor/znoise/build.zig").inject(mod, builder.path("src/vendor/znoise")); + if (!opt.no_audio) @import("src/vendor/zaudio/build.zig").inject(mod, builder.path("src/vendor/zaudio")); + if (opt.use_cp) @import("src/vendor/chipmunk/build.zig").inject(mod, builder.path("src/vendor/chipmunk")); + if (opt.use_nfd) @import("src/vendor/nfd/build.zig").inject(mod, builder.path("src/vendor/nfd")); + + return mod; } // Get jok's own builder from project's diff --git a/build.zig.zon b/build.zig.zon index 680bebc0..983303d3 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = "jok", - .version = "0.30.1", + .version = "0.31.0", .paths = .{ "README.md", "build.zig", diff --git a/src/vendor/chipmunk/build.zig b/src/vendor/chipmunk/build.zig index 9601edf7..649bdc51 100644 --- a/src/vendor/chipmunk/build.zig +++ b/src/vendor/chipmunk/build.zig @@ -1,14 +1,8 @@ const std = @import("std"); -pub fn inject( - b: *std.Build, - bin: *std.Build.Step.Compile, - _: std.Build.ResolvedTarget, - optimize: std.builtin.Mode, - dir: std.Build.LazyPath, -) void { - bin.addIncludePath(dir.path(b, "c/include")); - bin.addCSourceFiles(.{ +pub fn inject(mod: *std.Build.Module, dir: std.Build.LazyPath) void { + mod.addIncludePath(dir.path(mod.owner, "c/include")); + mod.addCSourceFiles(.{ .root = dir, .files = &.{ "c/src/chipmunk.c", @@ -45,7 +39,7 @@ pub fn inject( "c/src/cpSweep1D.c", }, .flags = &.{ - if (optimize == .Debug) "" else "-DNDEBUG", + if (mod.optimize.? == .Debug) "" else "-DNDEBUG", "-DCP_USE_DOUBLES=0", "-Wno-return-type-c-linkage", "-fno-sanitize=undefined", diff --git a/src/vendor/imgui/build.zig b/src/vendor/imgui/build.zig index 21cc32d0..1b040f87 100644 --- a/src/vendor/imgui/build.zig +++ b/src/vendor/imgui/build.zig @@ -1,35 +1,29 @@ const std = @import("std"); -pub fn inject( - b: *std.Build, - bin: *std.Build.Step.Compile, - target: std.Build.ResolvedTarget, - _: std.builtin.Mode, - dir: std.Build.LazyPath, -) void { +pub fn inject(mod: *std.Build.Module, dir: std.Build.LazyPath) void { const cflags = &.{ "-fno-sanitize=undefined", "-Wno-elaborated-enum-base", "-Wno-error=date-time", }; - const emscripten = target.result.os.tag == .emscripten; + const emscripten = mod.resolved_target.?.result.os.tag == .emscripten; if (emscripten) { - bin.root_module.addCMacro("__EMSCRIPTEN__", "1"); - bin.root_module.addCMacro("__EMSCRIPTEN_major__", "3"); - bin.root_module.addCMacro("__EMSCRIPTEN_minor__", "1"); - bin.root_module.stack_protector = false; + mod.addCMacro("__EMSCRIPTEN__", "1"); + mod.addCMacro("__EMSCRIPTEN_major__", "3"); + mod.addCMacro("__EMSCRIPTEN_minor__", "1"); + mod.stack_protector = false; } else { - bin.linkLibC(); - if (target.result.abi != .msvc) bin.linkLibCpp(); + mod.link_libc = true; + if (mod.resolved_target.?.result.abi != .msvc) mod.link_libcpp = true; } - bin.addIncludePath(dir.path(b, "c/imgui")); - bin.addIncludePath(dir.path(b, "c/implot")); - bin.addIncludePath(dir.path(b, "c/imguizmo")); - bin.addIncludePath(dir.path(b, "c/node_editor")); - bin.addIncludePath(dir.path(b, "c/impl")); - bin.addCSourceFiles(.{ + mod.addIncludePath(dir.path(mod.owner, "c/imgui")); + mod.addIncludePath(dir.path(mod.owner, "c/implot")); + mod.addIncludePath(dir.path(mod.owner, "c/imguizmo")); + mod.addIncludePath(dir.path(mod.owner, "c/node_editor")); + mod.addIncludePath(dir.path(mod.owner, "c/impl")); + mod.addCSourceFiles(.{ .root = dir, .files = &.{ "c/imgui/imgui.cpp", diff --git a/src/vendor/nfd/build.zig b/src/vendor/nfd/build.zig index 71221497..23d66142 100644 --- a/src/vendor/nfd/build.zig +++ b/src/vendor/nfd/build.zig @@ -1,49 +1,43 @@ const std = @import("std"); -pub fn inject( - b: *std.Build, - bin: *std.Build.Step.Compile, - target: std.Build.ResolvedTarget, - _: std.builtin.Mode, - dir: std.Build.LazyPath, -) void { +pub fn inject(mod: *std.Build.Module, dir: std.Build.LazyPath) void { const cflags = &.{ "-Wno-return-type-c-linkage", "-fno-sanitize=undefined", }; - if (bin.rootModuleTarget().os.tag == .windows) { - bin.linkSystemLibrary("shell32"); - bin.linkSystemLibrary("ole32"); - bin.linkSystemLibrary("uuid"); // needed by MinGW - } else if (target.result.os.tag == .macos) { - bin.linkFramework("AppKit"); - } else if (bin.rootModuleTarget().os.tag == .linux) { - bin.linkSystemLibrary("atk-1.0"); - bin.linkSystemLibrary("gdk-3"); - bin.linkSystemLibrary("gtk-3"); - bin.linkSystemLibrary("glib-2.0"); - bin.linkSystemLibrary("gobject-2.0"); + if (mod.resolved_target.?.result.os.tag == .windows) { + mod.linkSystemLibrary("shell32", .{}); + mod.linkSystemLibrary("ole32", .{}); + mod.linkSystemLibrary("uuid", .{}); // needed by MinGW + } else if (mod.resolved_target.?.result.os.tag == .macos) { + mod.linkFramework("AppKit", .{}); + } else if (mod.resolved_target.?.result.os.tag == .linux) { + mod.linkSystemLibrary("atk-1.0", .{}); + mod.linkSystemLibrary("gdk-3", .{}); + mod.linkSystemLibrary("gtk-3", .{}); + mod.linkSystemLibrary("glib-2.0", .{}); + mod.linkSystemLibrary("gobject-2.0", .{}); } else unreachable; - bin.addIncludePath(dir.path(b, "c/include")); - bin.addCSourceFile(.{ - .file = dir.path(b, "c/nfd_common.c"), + mod.addIncludePath(dir.path(mod.owner, "c/include")); + mod.addCSourceFile(.{ + .file = dir.path(mod.owner, "c/nfd_common.c"), .flags = cflags, }); - if (target.result.os.tag == .windows) { - bin.addCSourceFile(.{ - .file = dir.path(b, "c/nfd_win.cpp"), + if (mod.resolved_target.?.result.os.tag == .windows) { + mod.addCSourceFile(.{ + .file = dir.path(mod.owner, "c/nfd_win.cpp"), .flags = cflags, }); - } else if (target.result.os.tag == .macos) { - bin.addCSourceFile(.{ - .file = dir.path(b, "c/nfd_cocoa.m"), + } else if (mod.resolved_target.?.result.os.tag == .macos) { + mod.addCSourceFile(.{ + .file = dir.path(mod.owner, "c/nfd_cocoa.m"), .flags = cflags, }); - } else if (target.result.os.tag == .linux) { - bin.addCSourceFile(.{ - .file = dir.path(b, "c/nfd_gtk.c"), + } else if (mod.resolved_target.?.result.os.tag == .linux) { + mod.addCSourceFile(.{ + .file = dir.path(mod.owner, "c/nfd_gtk.c"), .flags = cflags, }); } else unreachable; diff --git a/src/vendor/physfs/build.zig b/src/vendor/physfs/build.zig index 6b6a0ff8..a7c235e2 100644 --- a/src/vendor/physfs/build.zig +++ b/src/vendor/physfs/build.zig @@ -1,18 +1,12 @@ const std = @import("std"); -pub fn inject( - _: *std.Build, - bin: *std.Build.Step.Compile, - target: std.Build.ResolvedTarget, - _: std.builtin.Mode, - dir: std.Build.LazyPath, -) void { +pub fn inject(mod: *std.Build.Module, dir: std.Build.LazyPath) void { const cflags = &.{ "-Wno-return-type-c-linkage", "-fno-sanitize=undefined", }; - bin.addCSourceFiles(.{ + mod.addCSourceFiles(.{ .root = dir, .files = &.{ "c/physfs.c", @@ -43,21 +37,21 @@ pub fn inject( }, .flags = cflags, }); - if (target.result.os.tag == .windows) { - bin.linkSystemLibrary("advapi32"); - bin.linkSystemLibrary("shell32"); - } else if (target.result.os.tag == .macos) { - bin.addCSourceFiles(.{ + if (mod.resolved_target.?.result.os.tag == .windows) { + mod.linkSystemLibrary("advapi32", .{}); + mod.linkSystemLibrary("shell32", .{}); + } else if (mod.resolved_target.?.result.os.tag == .macos) { + mod.addCSourceFiles(.{ .root = dir, .files = &.{ "c/physfs_platform_apple.m", }, .flags = cflags, }); - bin.linkSystemLibrary("objc"); - bin.linkFramework("IOKit"); - bin.linkFramework("Foundation"); - } else if (target.result.os.tag == .linux) { - bin.linkSystemLibrary("pthread"); + mod.linkSystemLibrary("objc", .{}); + mod.linkFramework("IOKit", .{}); + mod.linkFramework("Foundation", .{}); + } else if (mod.resolved_target.?.result.os.tag == .linux) { + mod.linkSystemLibrary("pthread", .{}); } else unreachable; } diff --git a/src/vendor/sdl/build.zig b/src/vendor/sdl/build.zig index 04404b0b..861465ef 100644 --- a/src/vendor/sdl/build.zig +++ b/src/vendor/sdl/build.zig @@ -1,21 +1,15 @@ const std = @import("std"); -pub fn inject( - b: *std.Build, - bin: *std.Build.Step.Compile, - target: std.Build.ResolvedTarget, - _: std.builtin.Mode, - dir: std.Build.LazyPath, -) void { - switch (target.result.os.tag) { +pub fn inject(mod: *std.Build.Module, dir: std.Build.LazyPath) void { + switch (mod.resolved_target.?.result.os.tag) { .windows => { - bin.addIncludePath(dir.path(b, "c/windows")); + mod.addIncludePath(dir.path(mod.owner, "c/windows")); }, .macos => { - bin.addIncludePath(dir.path(b, "c/macos")); + mod.addIncludePath(dir.path(mod.owner, "c/macos")); }, .linux => { - bin.addIncludePath(dir.path(b, "c/linux")); + mod.addIncludePath(dir.path(mod.owner, "c/linux")); }, else => unreachable, } diff --git a/src/vendor/stb/build.zig b/src/vendor/stb/build.zig index 4cc154ca..9d1c9051 100644 --- a/src/vendor/stb/build.zig +++ b/src/vendor/stb/build.zig @@ -1,14 +1,8 @@ const std = @import("std"); -pub fn inject( - b: *std.Build, - bin: *std.Build.Step.Compile, - _: std.Build.ResolvedTarget, - _: std.builtin.Mode, - dir: std.Build.LazyPath, -) void { - bin.addCSourceFile(.{ - .file = dir.path(b, "c/stb_wrapper.c"), +pub fn inject(mod: *std.Build.Module, dir: std.Build.LazyPath) void { + mod.addCSourceFile(.{ + .file = dir.path(mod.owner, "c/stb_wrapper.c"), .flags = &.{ "-Wno-return-type-c-linkage", "-fno-sanitize=undefined", diff --git a/src/vendor/svg/build.zig b/src/vendor/svg/build.zig index a6cbad4b..042f4e57 100644 --- a/src/vendor/svg/build.zig +++ b/src/vendor/svg/build.zig @@ -1,14 +1,8 @@ const std = @import("std"); -pub fn inject( - b: *std.Build, - bin: *std.Build.Step.Compile, - _: std.Build.ResolvedTarget, - _: std.builtin.Mode, - dir: std.Build.LazyPath, -) void { - bin.addCSourceFile(.{ - .file = dir.path(b, "c/wrapper.c"), +pub fn inject(mod: *std.Build.Module, dir: std.Build.LazyPath) void { + mod.addCSourceFile(.{ + .file = dir.path(mod.owner, "c/wrapper.c"), .flags = &.{ "-Wno-return-type-c-linkage", "-fno-sanitize=undefined", diff --git a/src/vendor/system_sdk/build.zig b/src/vendor/system_sdk/build.zig index d3ea1b04..d9d773f0 100644 --- a/src/vendor/system_sdk/build.zig +++ b/src/vendor/system_sdk/build.zig @@ -1,25 +1,19 @@ const std = @import("std"); -pub fn inject( - b: *std.Build, - bin: *std.Build.Step.Compile, - target: std.Build.ResolvedTarget, - _: std.builtin.Mode, - dir: std.Build.LazyPath, -) void { - switch (target.result.os.tag) { +pub fn inject(mod: *std.Build.Module, dir: std.Build.LazyPath) void { + switch (mod.resolved_target.?.result.os.tag) { .macos => { - bin.addFrameworkPath(dir.path(b, "macos12/System/Library/Frameworks")); - bin.addSystemIncludePath(dir.path(b, "macos12/usr/include")); - bin.addLibraryPath(dir.path(b, "macos12/usr/lib")); + mod.addFrameworkPath(dir.path(mod.owner, "macos12/System/Library/Frameworks")); + mod.addSystemIncludePath(dir.path(mod.owner, "macos12/usr/include")); + mod.addLibraryPath(dir.path(mod.owner, "macos12/usr/lib")); }, .linux => { - bin.addSystemIncludePath(dir.path(b, "linux/include")); - bin.addSystemIncludePath(dir.path(b, "linux/include/wayland")); - if (target.result.cpu.arch.isX86()) { - bin.addLibraryPath(dir.path(b, "linux/lib/x86_64-linux-gnu")); + mod.addSystemIncludePath(dir.path(mod.owner, "linux/include")); + mod.addSystemIncludePath(dir.path(mod.owner, "linux/include/wayland")); + if (mod.resolved_target.?.result.cpu.arch.isX86()) { + mod.addLibraryPath(dir.path(mod.owner, "linux/lib/x86_64-linux-gnu")); } else { - bin.addLibraryPath(dir.path(b, "linux/lib/aarch64-linux-gnu")); + mod.addLibraryPath(dir.path(mod.owner, "linux/lib/aarch64-linux-gnu")); } }, else => {}, diff --git a/src/vendor/zaudio/build.zig b/src/vendor/zaudio/build.zig index 42d6b8d8..ec607d3a 100644 --- a/src/vendor/zaudio/build.zig +++ b/src/vendor/zaudio/build.zig @@ -1,30 +1,24 @@ const std = @import("std"); -pub fn inject( - b: *std.Build, - bin: *std.Build.Step.Compile, - target: std.Build.ResolvedTarget, - _: std.builtin.Mode, - dir: std.Build.LazyPath, -) void { - bin.addIncludePath(dir.path(b, "c/miniaudio")); - if (target.result.os.tag == .macos) { - bin.linkFramework("CoreAudio"); - bin.linkFramework("CoreFoundation"); - bin.linkFramework("AudioUnit"); - bin.linkFramework("AudioToolbox"); - } else if (target.result.os.tag == .linux) { - bin.linkSystemLibrary("pthread"); - bin.linkSystemLibrary("m"); - bin.linkSystemLibrary("dl"); +pub fn inject(mod: *std.Build.Module, dir: std.Build.LazyPath) void { + mod.addIncludePath(dir.path(mod.owner, "c/miniaudio")); + if (mod.resolved_target.?.result.os.tag == .macos) { + mod.linkFramework("CoreAudio", .{}); + mod.linkFramework("CoreFoundation", .{}); + mod.linkFramework("AudioUnit", .{}); + mod.linkFramework("AudioToolbox", .{}); + } else if (mod.resolved_target.?.result.os.tag == .linux) { + mod.linkSystemLibrary("pthread", .{}); + mod.linkSystemLibrary("m", .{}); + mod.linkSystemLibrary("dl", .{}); } - bin.addCSourceFile(.{ - .file = dir.path(b, "c/zaudio.c"), + mod.addCSourceFile(.{ + .file = dir.path(mod.owner, "c/zaudio.c"), .flags = &.{"-std=c99"}, }); - bin.addCSourceFile(.{ - .file = dir.path(b, "c/miniaudio/miniaudio.c"), + mod.addCSourceFile(.{ + .file = dir.path(mod.owner, "c/miniaudio/miniaudio.c"), .flags = &.{ "-DMA_NO_WEBAUDIO", "-DMA_NO_ENCODING", @@ -34,7 +28,7 @@ pub fn inject( "-DMA_NO_WINMM", "-std=c99", "-fno-sanitize=undefined", - if (target.result.os.tag == .macos) "-DMA_NO_RUNTIME_LINKING" else "", + if (mod.resolved_target.?.result.os.tag == .macos) "-DMA_NO_RUNTIME_LINKING" else "", }, }); } diff --git a/src/vendor/zmath/build.zig b/src/vendor/zmath/build.zig index b496e11e..ed89e973 100644 --- a/src/vendor/zmath/build.zig +++ b/src/vendor/zmath/build.zig @@ -1,9 +1,3 @@ const std = @import("std"); -pub fn inject( - _: *std.Build, - _: *std.Build.Step.Compile, - _: std.Build.ResolvedTarget, - _: std.builtin.Mode, - _: std.Build.LazyPath, -) void {} +pub fn inject(_: *std.Build.Module, _: std.Build.LazyPath) void {} diff --git a/src/vendor/zmesh/build.zig b/src/vendor/zmesh/build.zig index 787491f1..6d9acc30 100644 --- a/src/vendor/zmesh/build.zig +++ b/src/vendor/zmesh/build.zig @@ -1,15 +1,9 @@ const std = @import("std"); -pub fn inject( - b: *std.Build, - bin: *std.Build.Step.Compile, - _: std.Build.ResolvedTarget, - _: std.builtin.Mode, - dir: std.Build.LazyPath, -) void { - bin.addIncludePath(dir.path(b, "c/par_shapes")); - bin.addCSourceFile(.{ - .file = dir.path(b, "c/par_shapes/par_shapes.c"), +pub fn inject(mod: *std.Build.Module, dir: std.Build.LazyPath) void { + mod.addIncludePath(dir.path(mod.owner, "c/par_shapes")); + mod.addCSourceFile(.{ + .file = dir.path(mod.owner, "c/par_shapes/par_shapes.c"), .flags = &.{ "-std=c99", "-fno-sanitize=undefined", @@ -17,7 +11,7 @@ pub fn inject( }, }); - bin.addCSourceFiles(.{ + mod.addCSourceFiles(.{ .root = dir, .files = &.{ "c/meshoptimizer/clusterizer.cpp", @@ -34,9 +28,9 @@ pub fn inject( .flags = &.{""}, }); - bin.addIncludePath(dir.path(b, "c/cgltf")); - bin.addCSourceFile(.{ - .file = dir.path(b, "c/cgltf/cgltf.c"), + mod.addIncludePath(dir.path(mod.owner, "c/cgltf")); + mod.addCSourceFile(.{ + .file = dir.path(mod.owner, "c/cgltf/cgltf.c"), .flags = &.{"-std=c99"}, }); } diff --git a/src/vendor/znoise/build.zig b/src/vendor/znoise/build.zig index 89c36af3..1151f538 100644 --- a/src/vendor/znoise/build.zig +++ b/src/vendor/znoise/build.zig @@ -1,15 +1,9 @@ const std = @import("std"); -pub fn inject( - b: *std.Build, - bin: *std.Build.Step.Compile, - _: std.Build.ResolvedTarget, - _: std.builtin.Mode, - dir: std.Build.LazyPath, -) void { - bin.addIncludePath(dir.path(b, "c/FastNoiseLite")); - bin.addCSourceFile(.{ - .file = dir.path(b, "c/FastNoiseLite/FastNoiseLite.c"), +pub fn inject(mod: *std.Build.Module, dir: std.Build.LazyPath) void { + mod.addIncludePath(dir.path(mod.owner, "c/FastNoiseLite")); + mod.addCSourceFile(.{ + .file = dir.path(mod.owner, "c/FastNoiseLite/FastNoiseLite.c"), .flags = &.{ "-std=c99", "-fno-sanitize=undefined" }, }); }