Skip to content

Commit fcae52e

Browse files
perttuvepPerttu Vepsäläinen
andauthored
update build script for zig 0.16.0 (#25)
Co-authored-by: Perttu Vepsäläinen <perttuvep+git@proton.me>
1 parent c512b60 commit fcae52e

1 file changed

Lines changed: 26 additions & 28 deletions

File tree

build.zig

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,22 @@ pub fn build(b: *std.Build) void {
116116
.root_module = b.createModule(.{
117117
.target = target,
118118
.optimize = optimize,
119+
.link_libc = true,
120+
.link_libcpp = target.result.abi != .msvc,
119121
}),
120122
});
121123
b.installArtifact(zdawn);
122124

123125
linkSystemDeps(b, zdawn);
124126

125-
zdawn.linkLibC();
126-
if (target.result.abi != .msvc)
127-
zdawn.linkLibCpp();
127+
zdawn.root_module.addIncludePath(b.path("libs/dawn/include"));
128+
zdawn.root_module.addIncludePath(b.path("src"));
128129

129-
zdawn.addIncludePath(b.path("libs/dawn/include"));
130-
zdawn.addIncludePath(b.path("src"));
131-
132-
zdawn.addCSourceFile(.{
130+
zdawn.root_module.addCSourceFile(.{
133131
.file = b.path("src/dawn.cpp"),
134132
.flags = &.{ "-std=c++17", "-fno-sanitize=undefined" },
135133
});
136-
zdawn.addCSourceFile(.{
134+
zdawn.root_module.addCSourceFile(.{
137135
.file = b.path("src/dawn_proc.c"),
138136
.flags = &.{"-fno-sanitize=undefined"},
139137
});
@@ -149,8 +147,8 @@ pub fn build(b: *std.Build) void {
149147
.optimize = optimize,
150148
}),
151149
});
152-
tests.addIncludePath(b.path("libs/dawn/include"));
153-
tests.linkLibrary(zdawn);
150+
tests.root_module.addIncludePath(b.path("libs/dawn/include"));
151+
tests.root_module.linkLibrary(zdawn);
154152
linkSystemDeps(b, tests);
155153
addLibraryPathsTo(tests);
156154
b.installArtifact(tests);
@@ -162,23 +160,23 @@ pub fn linkSystemDeps(b: *std.Build, compile_step: *std.Build.Step.Compile) void
162160
switch (compile_step.rootModuleTarget().os.tag) {
163161
.windows => {
164162
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
165-
compile_step.addLibraryPath(system_sdk.path("windows/lib/x86_64-windows-gnu"));
163+
compile_step.root_module.addLibraryPath(system_sdk.path("windows/lib/x86_64-windows-gnu"));
166164
}
167-
compile_step.linkSystemLibrary("ole32");
168-
compile_step.linkSystemLibrary("dxguid");
165+
compile_step.root_module.linkSystemLibrary("ole32", .{});
166+
compile_step.root_module.linkSystemLibrary("dxguid", .{});
169167
},
170168
.macos => {
171169
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
172-
compile_step.addLibraryPath(system_sdk.path("macos12/usr/lib"));
173-
compile_step.addFrameworkPath(system_sdk.path("macos12/System/Library/Frameworks"));
170+
compile_step.root_module.addLibraryPath(system_sdk.path("macos12/usr/lib"));
171+
compile_step.root_module.addFrameworkPath(system_sdk.path("macos12/System/Library/Frameworks"));
174172
}
175-
compile_step.linkSystemLibrary("objc");
176-
compile_step.linkFramework("Metal");
177-
compile_step.linkFramework("CoreGraphics");
178-
compile_step.linkFramework("Foundation");
179-
compile_step.linkFramework("IOKit");
180-
compile_step.linkFramework("IOSurface");
181-
compile_step.linkFramework("QuartzCore");
173+
compile_step.root_module.linkSystemLibrary("objc", .{});
174+
compile_step.root_module.linkFramework("Metal", .{});
175+
compile_step.root_module.linkFramework("CoreGraphics", .{});
176+
compile_step.root_module.linkFramework("Foundation", .{});
177+
compile_step.root_module.linkFramework("IOKit", .{});
178+
compile_step.root_module.linkFramework("IOSurface", .{});
179+
compile_step.root_module.linkFramework("QuartzCore", .{});
182180
},
183181
else => {},
184182
}
@@ -190,34 +188,34 @@ pub fn addLibraryPathsTo(compile_step: *std.Build.Step.Compile) void {
190188
switch (target.os.tag) {
191189
.windows => {
192190
if (b.lazyDependency("dawn_x86_64_windows_gnu", .{})) |dawn_prebuilt| {
193-
compile_step.addLibraryPath(dawn_prebuilt.path(""));
191+
compile_step.root_module.addLibraryPath(dawn_prebuilt.path(""));
194192
}
195193
},
196194
.linux => {
197195
if (target.cpu.arch.isX86()) {
198196
if (b.lazyDependency("dawn_x86_64_linux_gnu", .{})) |dawn_prebuilt| {
199-
compile_step.addLibraryPath(dawn_prebuilt.path(""));
197+
compile_step.root_module.addLibraryPath(dawn_prebuilt.path(""));
200198
}
201199
} else if (target.cpu.arch.isAARCH64()) {
202200
if (b.lazyDependency("dawn_aarch64_linux_gnu", .{})) |dawn_prebuilt| {
203-
compile_step.addLibraryPath(dawn_prebuilt.path(""));
201+
compile_step.root_module.addLibraryPath(dawn_prebuilt.path(""));
204202
}
205203
}
206204
},
207205
.macos => {
208206
if (target.cpu.arch.isX86()) {
209207
if (b.lazyDependency("dawn_x86_64_macos", .{})) |dawn_prebuilt| {
210-
compile_step.addLibraryPath(dawn_prebuilt.path(""));
208+
compile_step.root_module.addLibraryPath(dawn_prebuilt.path(""));
211209
}
212210
} else if (target.cpu.arch.isAARCH64()) {
213211
if (b.lazyDependency("dawn_aarch64_macos", .{})) |dawn_prebuilt| {
214-
compile_step.addLibraryPath(dawn_prebuilt.path(""));
212+
compile_step.root_module.addLibraryPath(dawn_prebuilt.path(""));
215213
}
216214
}
217215
},
218216
else => {},
219217
}
220-
compile_step.linkSystemLibrary("dawn");
218+
compile_step.root_module.linkSystemLibrary("dawn", .{});
221219
}
222220

223221
pub fn checkTargetSupported(target: std.Target) bool {

0 commit comments

Comments
 (0)