const std = @import("std");

pub fn build(builder: *std.build.Builder) void {
    const target = builder.standardTargetOptions(.{});
    const mode = builder.standardReleaseOptions();

    // Ona executable.
    {
        const ona_exe = builder.addExecutable("ona", "./src/main.zig");

        ona_exe.setTarget(target);
        ona_exe.setBuildMode(mode);
        ona_exe.install();
        ona_exe.addIncludeDir("./ext");
        ona_exe.linkSystemLibrary("SDL2");
        ona_exe.linkLibC();

        const run_cmd = ona_exe.run();

        run_cmd.step.dependOn(builder.getInstallStep());

        if (builder.args) |args| run_cmd.addArgs(args);

        builder.step("run", "Run Ona application").dependOn(&run_cmd.step);
    }

    // Ona tests.
    {
        const ona_tests = builder.addTestExe("test", "./src/main.zig");

        ona_tests.setTarget(target);
        ona_tests.setBuildMode(mode);
        builder.step("test", "Run Ona unit tests").dependOn(&ona_tests.step);
    }
}