build: update for 0.12.0-dev.2208+4debd4338

I am hoping that by starting to roll over to zig 0.12 now it will be
easier to migrate when the release actually happens. Unfortunately,
the build system API changed fairly significantly and supporting both
0.11 and 0.12-dev is not very interesting.
This commit is contained in:
torque 2024-01-15 22:10:15 -08:00
parent 875b1b6344
commit ad73ea6508
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk

View File

@ -5,7 +5,7 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const nice = b.addModule("nice", .{ const nice = b.addModule("nice", .{
.source_file = .{ .path = "src/nice.zig" }, .root_source_file = .{ .path = "src/nice.zig" },
}); });
const tests = b.addTest(.{ const tests = b.addTest(.{
@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
.optimize = optimize, .optimize = optimize,
}); });
tests.addModule("nice", nice); tests.root_module.addImport("nice", nice);
const run_main_tests = b.addRunArtifact(tests); const run_main_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run tests"); const test_step = b.step("test", "Run tests");
@ -29,7 +29,7 @@ pub fn build(b: *std.Build) void {
} }
const ExampleOptions = struct { const ExampleOptions = struct {
target: std.zig.CrossTarget, target: std.Build.ResolvedTarget,
nice_mod: *std.Build.Module, nice_mod: *std.Build.Module,
}; };
@ -44,7 +44,7 @@ const examples = [_]Example{
.{ .name = "reify", .file = "examples/reify.zig" }, .{ .name = "reify", .file = "examples/reify.zig" },
}; };
pub fn add_examples(b: *std.build, options: ExampleOptions) void { pub fn add_examples(b: *std.Build, options: ExampleOptions) void {
const example_step = b.step("examples", "build examples"); const example_step = b.step("examples", "build examples");
inline for (examples) |example| { inline for (examples) |example| {
@ -55,7 +55,7 @@ pub fn add_examples(b: *std.build, options: ExampleOptions) void {
.optimize = .Debug, .optimize = .Debug,
}); });
ex_exe.addModule("nice", options.nice_mod); ex_exe.root_module.addImport("nice", options.nice_mod);
const install = b.addInstallArtifact(ex_exe, .{}); const install = b.addInstallArtifact(ex_exe, .{});
example_step.dependOn(&install.step); example_step.dependOn(&install.step);
} }