Skip to content

Commit 68c8372

Browse files
committed
build: use path() func
1 parent ef364f8 commit 68c8372

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

build.zig

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ pub fn build(b: *std.Build) !void {
5353
// compile and install
5454
const exe = b.addExecutable(.{
5555
.name = "browsercore",
56-
.root_source_file = .{ .path = "src/main.zig" },
56+
.root_source_file = b.path("src/main.zig"),
5757
.target = target,
5858
.optimize = mode,
5959
});
60-
try common(exe, options);
60+
try common(b, exe, options);
6161
b.installArtifact(exe);
6262

6363
// run
@@ -76,11 +76,11 @@ pub fn build(b: *std.Build) !void {
7676
// compile and install
7777
const shell = b.addExecutable(.{
7878
.name = "browsercore-shell",
79-
.root_source_file = .{ .path = "src/main_shell.zig" },
79+
.root_source_file = b.path("src/main_shell.zig"),
8080
.target = target,
8181
.optimize = mode,
8282
});
83-
try common(shell, options);
83+
try common(b, shell, options);
8484
try jsruntime_pkgs.add_shell(shell);
8585

8686
// run
@@ -98,15 +98,16 @@ pub fn build(b: *std.Build) !void {
9898

9999
// compile
100100
const tests = b.addTest(.{
101-
.root_source_file = .{ .path = "src/run_tests.zig" },
102-
.test_runner = .{ .path = "src/test_runner.zig" },
103-
.single_threaded = true,
101+
.root_source_file = b.path("src/run_tests.zig"),
102+
.test_runner = b.path("src/test_runner.zig"),
103+
.target = target,
104+
.optimize = mode,
104105
});
105-
try common(tests, options);
106+
try common(b, tests, options);
106107

107108
// add jsruntime pretty deps
108109
tests.root_module.addAnonymousImport("pretty", .{
109-
.root_source_file = .{ .path = "vendor/zig-js-runtime/src/pretty.zig" },
110+
.root_source_file = b.path("vendor/zig-js-runtime/src/pretty.zig"),
110111
});
111112

112113
const run_tests = b.addRunArtifact(tests);
@@ -124,12 +125,11 @@ pub fn build(b: *std.Build) !void {
124125
// compile and install
125126
const wpt = b.addExecutable(.{
126127
.name = "browsercore-wpt",
127-
.root_source_file = .{ .path = "src/main_wpt.zig" },
128+
.root_source_file = b.path("src/main_wpt.zig"),
128129
.target = target,
129130
.optimize = mode,
130131
});
131-
try common(wpt, options);
132-
b.installArtifact(wpt);
132+
try common(b, wpt, options);
133133

134134
// run
135135
const wpt_cmd = b.addRunArtifact(wpt);
@@ -146,11 +146,11 @@ pub fn build(b: *std.Build) !void {
146146
// compile and install
147147
const get = b.addExecutable(.{
148148
.name = "browsercore-get",
149-
.root_source_file = .{ .path = "src/main_get.zig" },
149+
.root_source_file = b.path("src/main_get.zig"),
150150
.target = target,
151151
.optimize = mode,
152152
});
153-
try common(get, options);
153+
try common(b, get, options);
154154
b.installArtifact(get);
155155

156156
// run
@@ -164,34 +164,35 @@ pub fn build(b: *std.Build) !void {
164164
}
165165

166166
fn common(
167+
b: *std.Build,
167168
step: *std.Build.Step.Compile,
168169
options: jsruntime.Options,
169170
) !void {
170171
try jsruntime_pkgs.add(step, options);
171-
linkNetSurf(step);
172+
linkNetSurf(b, step);
172173

173174
// link mimalloc
174-
step.addObjectFile(.{ .path = "vendor/mimalloc/out/libmimalloc.a" });
175-
step.addIncludePath(.{ .path = "vendor/mimalloc/out/include" });
175+
step.addObjectFile(b.path("vendor/mimalloc/out/libmimalloc.a"));
176+
step.addIncludePath(b.path("vendor/mimalloc/out/include"));
176177
}
177178

178-
fn linkNetSurf(step: *std.Build.Step.Compile) void {
179-
179+
fn linkNetSurf(b: *std.Build, step: *std.Build.Step.Compile) void {
180180
// iconv
181-
step.addObjectFile(.{ .path = "vendor/libiconv/lib/libiconv.a" });
182-
step.addIncludePath(.{ .path = "vendor/libiconv/include" });
181+
step.addObjectFile(b.path("vendor/libiconv/lib/libiconv.a"));
182+
step.addIncludePath(b.path("vendor/libiconv/include"));
183183

184184
// netsurf libs
185185
const ns = "vendor/netsurf";
186+
step.addIncludePath(b.path(ns ++ "/include"));
187+
186188
const libs: [4][]const u8 = .{
187189
"libdom",
188190
"libhubbub",
189191
"libparserutils",
190192
"libwapcaplet",
191193
};
192194
inline for (libs) |lib| {
193-
step.addObjectFile(.{ .path = ns ++ "/lib/" ++ lib ++ ".a" });
194-
step.addIncludePath(.{ .path = ns ++ "/" ++ lib ++ "/src" });
195+
step.addObjectFile(b.path(ns ++ "/lib/" ++ lib ++ ".a"));
196+
step.addIncludePath(b.path(ns ++ "/" ++ lib ++ "/src"));
195197
}
196-
step.addIncludePath(.{ .path = ns ++ "/include" });
197198
}

0 commit comments

Comments
 (0)