2024-08-21 15:57:18 -04:00
|
|
|
const std = @import("std");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn build(b: *std.Build) void {
|
2025-01-02 05:28:40 -05:00
|
|
|
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,
|
2024-08-21 15:57:18 -04:00
|
|
|
});
|
2025-01-02 05:28:40 -05:00
|
|
|
// 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,
|
2024-09-03 13:13:28 -04:00
|
|
|
});
|
2025-01-02 05:28:40 -05:00
|
|
|
|
|
|
|
|
exe.root_module.addImport("engine", engine);
|
|
|
|
|
exe.root_module.addImport("c", c);
|
|
|
|
|
exe.addCSourceFile(.{ .file = b.path("open-simplex/src/OpenSimplex2F.c") });
|
2024-09-03 13:13:28 -04:00
|
|
|
exe.addIncludePath(b.path("open-simplex/include"));
|
|
|
|
|
|
2024-08-21 15:57:18 -04:00
|
|
|
exe.linkLibC();
|
2025-01-02 05:28:40 -05:00
|
|
|
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);
|
2024-08-21 15:57:18 -04:00
|
|
|
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);
|
|
|
|
|
|
2025-01-02 05:28:40 -05:00
|
|
|
// 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.
|
2024-08-21 15:57:18 -04:00
|
|
|
}
|