Skip to content

Commit a8cfdb5

Browse files
committed
Migrate from deprecated Step.Compile APIs
1 parent 0f3e60a commit a8cfdb5

File tree

13 files changed

+1342
-1332
lines changed

13 files changed

+1342
-1332
lines changed

doc/langref/build.zig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ pub fn build(b: *std.Build) void {
44
const optimize = b.standardOptimizeOption(.{});
55
const exe = b.addExecutable(.{
66
.name = "example",
7-
.root_source_file = b.path("example.zig"),
8-
.optimize = optimize,
7+
.root_module = b.createModule(.{
8+
.root_source_file = b.path("example.zig"),
9+
.optimize = optimize,
10+
}),
911
});
1012
b.default_step.dependOn(&exe.step);
1113
}

doc/langref/build_c.zig

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ const std = @import("std");
33
pub fn build(b: *std.Build) void {
44
const lib = b.addSharedLibrary(.{
55
.name = "mathtest",
6-
.root_source_file = b.path("mathtest.zig"),
6+
.root_module = b.createModule(.{
7+
.root_source_file = b.path("mathtest.zig"),
8+
}),
79
.version = .{ .major = 1, .minor = 0, .patch = 0 },
810
});
911
const exe = b.addExecutable(.{
1012
.name = "test",
13+
.root_module = b.createModule(.{
14+
.link_libc = true,
15+
}),
1116
});
12-
exe.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
13-
exe.linkLibrary(lib);
14-
exe.linkSystemLibrary("c");
17+
exe.root_module.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
18+
exe.root_module.linkLibrary(lib);
1519

1620
b.default_step.dependOn(&exe.step);
1721

doc/langref/build_object.zig

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ const std = @import("std");
33
pub fn build(b: *std.Build) void {
44
const obj = b.addObject(.{
55
.name = "base64",
6-
.root_source_file = b.path("base64.zig"),
6+
.root_module = b.createModule(.{
7+
.root_source_file = b.path("base64.zig"),
8+
}),
79
});
810

911
const exe = b.addExecutable(.{
1012
.name = "test",
13+
.root_module = b.createModule(.{
14+
.link_libc = true,
15+
}),
1116
});
12-
exe.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
13-
exe.addObject(obj);
14-
exe.linkSystemLibrary("c");
17+
exe.root_module.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
18+
exe.root_module.addObject(obj);
1519
b.installArtifact(exe);
1620
}
1721

0 commit comments

Comments
 (0)