59 lines
1.8 KiB
Zig
59 lines
1.8 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
// Parser executable
|
|
const parser_exe = b.addExecutable(.{
|
|
.name = "sdl-parser",
|
|
.root_module = b.createModule(.{
|
|
.root_source_file = b.path("src/parser.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
}),
|
|
});
|
|
|
|
b.installArtifact(parser_exe);
|
|
|
|
// Run command
|
|
const run_cmd = b.addRunArtifact(parser_exe);
|
|
run_cmd.step.dependOn(b.getInstallStep());
|
|
|
|
if (b.args) |args| {
|
|
run_cmd.addArgs(args);
|
|
}
|
|
|
|
const run_step = b.step("run", "Run the SDL3 header parser");
|
|
run_step.dependOn(&run_cmd.step);
|
|
|
|
// Test mocks generation target
|
|
const test_mocks_cmd = b.addRunArtifact(parser_exe);
|
|
test_mocks_cmd.step.dependOn(b.getInstallStep());
|
|
|
|
const test_header_path = b.path("test_small.h");
|
|
const test_output = b.path("zig-out/test_small.zig");
|
|
const test_mocks = b.path("zig-out/test_small_mock.c");
|
|
|
|
test_mocks_cmd.addArg(test_header_path.getPath(b));
|
|
test_mocks_cmd.addArg(b.fmt("--output={s}", .{test_output.getPath(b)}));
|
|
test_mocks_cmd.addArg(b.fmt("--mocks={s}", .{test_mocks.getPath(b)}));
|
|
|
|
const test_mocks_step = b.step("test-mocks", "Test mock generation with test_small.h");
|
|
test_mocks_step.dependOn(&test_mocks_cmd.step);
|
|
|
|
// Tests
|
|
const parser_tests = b.addTest(.{
|
|
.root_module = b.createModule(.{
|
|
.root_source_file = b.path("src/parser.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
}),
|
|
});
|
|
|
|
const run_tests = b.addRunArtifact(parser_tests);
|
|
|
|
const test_step = b.step("test", "Run parser tests");
|
|
test_step.dependOn(&run_tests.step);
|
|
}
|