const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const sdl_dep = b.dependency("sdl", .{
        .target = target,
        .optimize = optimize,
    });

    const sdl3_lib = sdl_dep.artifact("SDL3");

    const mod = b.addModule("sdl3", .{
        .target = target,
        .optimize = optimize,
        .root_source_file = b.path("src/sdl3.zig"),
    });

    mod.addIncludePath(b.path("SDL/include"));
    mod.linkLibrary(sdl3_lib);

    const test_step = b.step("test", "run unit tests for sdl3");
    const tests = b.addExecutable(.{
        .name = "hello-triangle",
        .target = target,
        .optimize = optimize,
        .root_source_file = b.path("src/samples/hello-triangle.zig"),
        .link_libc = true,
    });

    tests.root_module.addImport("sdl3", mod);

    const runArtifact = b.addRunArtifact(tests);
    test_step.dependOn(&runArtifact.step);

    b.installArtifact(tests);
}
