const std = @import("std"); const Module = std.Build.Module; pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const raylib_dep = b.dependency("raylib-zig", .{ .target = target, .optimize = optimize, }); const exe = b.addExecutable(.{ .name = "daq-view", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); exe.addIncludePath(b.path("src")); exe.addCSourceFile(.{ .file = b.path("src/cute_aseprite.c") }); exe.linkLibrary(raylib_dep.artifact("raylib")); exe.root_module.addImport("raylib", raylib_dep.module("raylib")); const external_compiler_support_dir = try std.process.getEnvVarOwned(b.allocator, "NIEXTCCOMPILERSUPP"); exe.addSystemIncludePath(.{ .cwd_relative = try std.fs.path.join(b.allocator, &.{ external_compiler_support_dir, "include" }) }); // TODO: Emebed all assets using build.zig // https://github.com/ziglang/zig/issues/14637#issuecomment-1428689051 if (target.result.os.tag == .windows) { exe.subsystem = if (optimize == .Debug) .Console else .Windows; const resource_file = b.addWriteFiles(); // https://www.ryanliptak.com/blog/zig-is-a-windows-resource-compiler/ // TODO: Generate icon file at build time exe.addWin32ResourceFile(.{ .file = resource_file.add("daq-view.rc", "IDI_ICON ICON \"./src/assets/icon.ico\""), }); exe.linkSystemLibrary("Comdlg32"); } 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 program"); run_step.dependOn(&run_cmd.step); const unit_tests = b.addTest(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); const run_unit_tests = b.addRunArtifact(unit_tests); const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&run_unit_tests.step); }