2026-08-09 14:17:49 +01:00
|
|
|
const std = @import("std");
|
|
|
|
|
|
2026-08-11 21:26:15 +01:00
|
|
|
pub fn build(b: *std.Build) !void {
|
2026-08-09 14:17:49 +01:00
|
|
|
// --- TARGET ---
|
|
|
|
|
const target = b.standardTargetOptions(.{});
|
|
|
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
|
|
|
|
|
|
// --- MOD ---
|
|
|
|
|
const mod = b.addModule("NYXGFX", .{
|
|
|
|
|
.root_source_file = b.path("src/gfx.zig"),
|
|
|
|
|
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const mod_tests = b.addTest(.{
|
|
|
|
|
.root_module = mod,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const run_mod_tests = b.addRunArtifact(mod_tests);
|
|
|
|
|
|
|
|
|
|
const test_step = b.step("test", "Run tests");
|
|
|
|
|
test_step.dependOn(&run_mod_tests.step);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// DEPENDANCIES
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
const gtl = b.dependency("gtl", .{
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
});
|
|
|
|
|
mod.addImport("gtl", gtl.module("gtl"));
|
|
|
|
|
|
2026-08-11 21:06:28 +01:00
|
|
|
const math = b.dependency("NYXMath", .{
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
});
|
|
|
|
|
mod.addImport("math", math.module("NYXMath"));
|
|
|
|
|
|
2026-08-09 14:17:49 +01:00
|
|
|
//
|
|
|
|
|
// SYSTEM DEPENDENCIES
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
const vulkan = b.addTranslateC(.{
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
.root_source_file = b.path("./src/vendor/vulkan/vulkan.h"),
|
|
|
|
|
});
|
|
|
|
|
mod.addImport("vulkan", vulkan.createModule());
|
|
|
|
|
mod.linkSystemLibrary("vulkan", .{});
|
2026-08-11 21:26:15 +01:00
|
|
|
|
2026-08-12 14:52:27 +01:00
|
|
|
const stb_image = b.addTranslateC(.{
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
.root_source_file = b.path("./src/vendor/stb_image/stb_image.h"),
|
|
|
|
|
});
|
|
|
|
|
mod.addImport("stb_image", stb_image.createModule());
|
|
|
|
|
mod.addCSourceFile(.{ .file = b.path("src/vendor/stb_image/stb_image.c") });
|
|
|
|
|
|
2026-08-12 20:31:05 +01:00
|
|
|
const fast_obj = b.addTranslateC(.{
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
.root_source_file = b.path("./src/vendor/fast_obj/fast_obj.h"),
|
|
|
|
|
});
|
|
|
|
|
mod.addImport("fast_obj", fast_obj.createModule());
|
|
|
|
|
mod.addCSourceFiles(.{ .files = &.{"src/vendor/fast_obj/fast_obj.c"} });
|
|
|
|
|
|
2026-08-11 21:26:15 +01:00
|
|
|
//
|
|
|
|
|
// EXAMPLES
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
inline for ([_]struct {
|
|
|
|
|
name: []const u8,
|
|
|
|
|
src: []const u8,
|
|
|
|
|
}{
|
|
|
|
|
.{ .name = "simple", .src = "examples/simple/simple.zig" },
|
2026-08-12 20:31:05 +01:00
|
|
|
.{ .name = "3D", .src = "examples/simple_3D/simple_3D.zig" },
|
2026-08-11 21:26:15 +01:00
|
|
|
}) |excfg| {
|
|
|
|
|
const ex_name = excfg.name;
|
|
|
|
|
const ex_src = excfg.src;
|
|
|
|
|
|
|
|
|
|
const ex_build_desc = try std.fmt.allocPrint(
|
|
|
|
|
b.allocator,
|
|
|
|
|
"build the {s} example",
|
|
|
|
|
.{ex_name},
|
|
|
|
|
);
|
|
|
|
|
const ex_run_stepname = try std.fmt.allocPrint(
|
|
|
|
|
b.allocator,
|
|
|
|
|
"run-{s}",
|
|
|
|
|
.{ex_name},
|
|
|
|
|
);
|
|
|
|
|
const ex_run_stepdesc = try std.fmt.allocPrint(
|
|
|
|
|
b.allocator,
|
|
|
|
|
"run the {s} example",
|
|
|
|
|
.{ex_name},
|
|
|
|
|
);
|
|
|
|
|
const example_run_step = b.step(ex_run_stepname, ex_run_stepdesc);
|
|
|
|
|
const example_step = b.step(ex_name, ex_build_desc);
|
|
|
|
|
|
|
|
|
|
const exe_mod = b.addModule(ex_name, .{
|
|
|
|
|
.root_source_file = b.path(ex_src),
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var example = b.addExecutable(.{
|
|
|
|
|
.name = ex_name,
|
|
|
|
|
.root_module = exe_mod,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
example.root_module.addImport("gfx", mod);
|
|
|
|
|
|
|
|
|
|
const sdl = b.addTranslateC(.{
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
.root_source_file = b.path("examples/vendor/sdl3.h"),
|
|
|
|
|
});
|
|
|
|
|
example.root_module.addImport("sdl", sdl.createModule());
|
|
|
|
|
example.root_module.linkSystemLibrary("SDL3", .{});
|
|
|
|
|
|
2026-08-12 20:31:05 +01:00
|
|
|
const example_math = b.dependency("NYXMath", .{
|
|
|
|
|
.target = target,
|
|
|
|
|
.optimize = optimize,
|
|
|
|
|
});
|
|
|
|
|
example.root_module.addImport("math", example_math.module("NYXMath"));
|
|
|
|
|
|
2026-08-11 21:26:15 +01:00
|
|
|
const example_run = b.addRunArtifact(example);
|
|
|
|
|
example_run_step.dependOn(&example_run.step);
|
|
|
|
|
|
|
|
|
|
const example_build_step = b.addInstallArtifact(example, .{});
|
|
|
|
|
example_step.dependOn(&example_build_step.step);
|
2026-08-12 14:52:27 +01:00
|
|
|
|
2026-08-12 20:31:05 +01:00
|
|
|
// const check_step = b.step("check", "Check if compiles");
|
|
|
|
|
// check_step.dependOn(&example.step);
|
2026-08-11 21:26:15 +01:00
|
|
|
}
|
2026-08-09 14:17:49 +01:00
|
|
|
}
|