48 lines
1.3 KiB
Zig
48 lines
1.3 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const lib = b.addStaticLibrary(.{
|
|
.name = "tokenizer",
|
|
.optimize = optimize,
|
|
.target = target,
|
|
});
|
|
lib.addCSourceFile(.{
|
|
.file = b.path("tokenizer.c"),
|
|
.flags = &[_][]const u8{
|
|
"-std=c11",
|
|
"-Wall",
|
|
"-Wvla",
|
|
"-Wextra",
|
|
"-Werror",
|
|
"-Wshadow",
|
|
"-Wswitch",
|
|
"-Walloca",
|
|
"-Wformat=2",
|
|
"-fno-common",
|
|
"-Wconversion",
|
|
"-Wswitch-enum",
|
|
"-Wuninitialized",
|
|
"-Wdouble-promotion",
|
|
"-fstack-protector-all",
|
|
"-Wimplicit-fallthrough",
|
|
//"-D_FORTIFY_SOURCE=2", // consider when optimization flags are enabled
|
|
},
|
|
});
|
|
lib.addIncludePath(b.path("."));
|
|
lib.linkLibC();
|
|
|
|
const test_step = b.step("test", "Run unit tests");
|
|
|
|
const test_exe = b.addTest(.{
|
|
.root_source_file = b.path("test_all.zig"),
|
|
.optimize = optimize,
|
|
});
|
|
test_exe.linkLibrary(lib);
|
|
test_exe.addIncludePath(b.path("."));
|
|
|
|
test_step.dependOn(&b.addRunArtifact(test_exe).step);
|
|
}
|