const std = @import("std"); pub fn build(b: *std.Build) !void { // --- 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")); const math = b.dependency("NYXMath", .{ .target = target, .optimize = optimize, }); mod.addImport("math", math.module("NYXMath")); // // 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", .{}); 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") }); 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"} }); // // EXAMPLES // inline for ([_]struct { name: []const u8, src: []const u8, }{ .{ .name = "simple", .src = "examples/simple/simple.zig" }, .{ .name = "3D", .src = "examples/simple_3D/simple_3D.zig" }, }) |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", .{}); const example_math = b.dependency("NYXMath", .{ .target = target, .optimize = optimize, }); example.root_module.addImport("math", example_math.module("NYXMath")); 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); // const check_step = b.step("check", "Check if compiles"); // check_step.dependOn(&example.step); } }