const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const c = b.addModule("c", .{ .root_source_file = b.path("src/c.zig"), .target = target, .optimize = optimize, }); // c.addLibraryPath(b.path("/usr/local/lib")); c.linkSystemLibrary("SDL3", .{}); c.addIncludePath(b.path("open-simplex/include")); c.linkSystemLibrary("SDL3_image", .{}); const engine = b.addModule("engine", .{ .root_source_file = b.path("src/engine/root.zig"), .target = target, .optimize = optimize, }); engine.addImport("engine", engine); engine.addImport("c", c); const exe = b.addExecutable(.{ .name = "hadean", .root_source_file = b.path("src/hadean/main.zig"), .target = target, .optimize = optimize, }); exe.root_module.addImport("engine", engine); exe.root_module.addImport("c", c); exe.addCSourceFile(.{ .file = b.path("open-simplex/src/OpenSimplex2F.c") }); exe.addIncludePath(b.path("open-simplex/include")); exe.linkLibC(); exe.root_module.addRPathSpecial("$ORIGIN/../lib"); b.getInstallStep().dependOn(&(b.addInstallFile(.{ .cwd_relative = "/usr/local/lib/libSDL3.so.0.1.7" }, "lib/libSDL3.so.0")).step); b.getInstallStep().dependOn(&(b.addInstallFile(.{ .cwd_relative = "/usr/local/lib/libSDL3_image.so.0.1.0" }, "lib/libSDL3_image.so.0")).step); b.getInstallStep().dependOn(&(b.addInstallFile( b.path("assets/textures.png"), "assets/textures.png" )).step); b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_cmd.addArgs(args); } const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); // because engine and hadean are diff modules their c modules // get different caches, causing opaques to be different between them. // kinda makes sense, because zig is namespacy and c is not! // it would be nice to in some way ensure both got the same version, though. }