38 lines
1.1 KiB
Zig
38 lines
1.1 KiB
Zig
|
const std = @import("std");
|
||
|
|
||
|
// Although this function looks imperative, note that its job is to
|
||
|
// declaratively construct a build graph that will be executed by an external
|
||
|
// runner.
|
||
|
pub fn build(b: *std.Build) void {
|
||
|
const target = b.standardTargetOptions(.{});
|
||
|
const optimize = b.standardOptimizeOption(.{});
|
||
|
|
||
|
// Anyascii zig module.
|
||
|
const anyascii = b.addModule("anyascii", .{
|
||
|
.root_source_file = b.path("src/lib.zig"),
|
||
|
.target = target,
|
||
|
.optimize = optimize,
|
||
|
});
|
||
|
anyascii.link_libc = true;
|
||
|
anyascii.addIncludePath(b.path("anyascii"));
|
||
|
anyascii.addCSourceFile(.{
|
||
|
.file = b.path("anyascii/anyascii.c"),
|
||
|
});
|
||
|
|
||
|
// Library unit tests.
|
||
|
const lib_unit_tests = b.addTest(.{
|
||
|
.root_source_file = b.path("src/lib.zig"),
|
||
|
.target = target,
|
||
|
.optimize = optimize,
|
||
|
});
|
||
|
lib_unit_tests.linkLibC();
|
||
|
lib_unit_tests.addIncludePath(b.path("anyascii"));
|
||
|
lib_unit_tests.addCSourceFile(.{
|
||
|
.file = b.path("anyascii/anyascii.c"),
|
||
|
});
|
||
|
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
|
||
|
|
||
|
const test_step = b.step("test", "Run unit tests");
|
||
|
test_step.dependOn(&run_lib_unit_tests.step);
|
||
|
}
|