Andrew Kelley 8f481dfc3c fix std.Build.OptionsStep
* use the same hash function as the rest of the steps
 * fix race condition due to a macOS oddity.
 * fix race condition due to file truncation (rename into place instead)
 * integrate with marking Step.result_cached. check if the file already
   exists with fs.access before doing anything else.
 * use a directory so that the file basename can be "options.zig"
   instead of a hash digest.
 * better error reporting in case of file system failures.
2023-03-19 00:39:29 -04:00

22 lines
797 B
Zig

const std = @import("std");
pub fn build(b: *std.Build) void {
const main = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.target = .{},
.optimize = .Debug,
});
const options = b.addOptions();
main.addOptions("build_options", options);
options.addOption(bool, "bool_true", b.option(bool, "bool_true", "t").?);
options.addOption(bool, "bool_false", b.option(bool, "bool_false", "f").?);
options.addOption(u32, "int", b.option(u32, "int", "i").?);
const E = enum { one, two, three };
options.addOption(E, "e", b.option(E, "e", "e").?);
options.addOption([]const u8, "string", b.option([]const u8, "string", "s").?);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&main.run().step);
}