Skip to content

Commit f6e080b

Browse files
Merge pull request #203 from lightpanda-io/upgrade-zig
Upgrade zig 0.12
2 parents 6724004 + 3744dc1 commit f6e080b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1196
-899
lines changed

.github/workflows/wpt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747

4848
runs-on: ubuntu-latest
4949
container:
50-
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.0-dev.1773-8a8fd47d2
50+
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.1
5151
credentials:
5252
username: ${{ github.actor }}
5353
password: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/zig-fmt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
runs-on: ubuntu-latest
2929
container:
30-
image: ghcr.io/lightpanda-io/zig:0.12.0-dev.1773-8a8fd47d2
30+
image: ghcr.io/lightpanda-io/zig:0.12.1
3131
credentials:
3232
username: ${{ github.actor }}
3333
password: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/zig-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
runs-on: ubuntu-latest
4747
container:
48-
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.0-dev.1773-8a8fd47d2
48+
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.1
4949
credentials:
5050
username: ${{ github.actor }}
5151
password: ${{ secrets.GITHUB_TOKEN }}
@@ -71,7 +71,7 @@ jobs:
7171

7272
runs-on: ubuntu-latest
7373
container:
74-
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.0-dev.1773-8a8fd47d2
74+
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.1
7575
credentials:
7676
username: ${{ github.actor }}
7777
password: ${{ secrets.GITHUB_TOKEN }}
@@ -97,7 +97,7 @@ jobs:
9797

9898
runs-on: ubuntu-latest
9999
container:
100-
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.0-dev.1773-8a8fd47d2
100+
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.1
101101
credentials:
102102
username: ${{ github.actor }}
103103
password: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ We do not provide yet binary versions of Lightpanda, you have to compile it from
7676

7777
### Prerequisites
7878

79-
Lightpanda is written with [Zig](https://ziglang.org/) `0.12`. You have to
79+
Lightpanda is written with [Zig](https://ziglang.org/) `0.12.1`. You have to
8080
install it with the right version in order to build the project.
8181

8282
Lightpanda also depends on

build.zig

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const jsruntime_pkgs = jsruntime.packages(jsruntime_path);
2828
/// which zig version to install.
2929
const recommended_zig_version = jsruntime.recommended_zig_version;
3030

31-
pub fn build(b: *std.build.Builder) !void {
31+
pub fn build(b: *std.Build) !void {
3232
switch (comptime builtin.zig_version.order(std.SemanticVersion.parse(recommended_zig_version) catch unreachable)) {
3333
.eq => {},
3434
.lt => {
@@ -53,11 +53,11 @@ pub fn build(b: *std.build.Builder) !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.Builder) !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,17 +98,17 @@ pub fn build(b: *std.build.Builder) !void {
9898

9999
// compile
100100
const tests = b.addTest(.{
101-
.root_source_file = .{ .path = "src/run_tests.zig" },
102-
.test_runner = "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
108-
const pretty = tests.step.owner.createModule(.{
109-
.source_file = .{ .path = "vendor/zig-js-runtime/src/pretty.zig" },
109+
tests.root_module.addAnonymousImport("pretty", .{
110+
.root_source_file = b.path("vendor/zig-js-runtime/src/pretty.zig"),
110111
});
111-
tests.addModule("pretty", pretty);
112112

113113
const run_tests = b.addRunArtifact(tests);
114114
if (b.args) |args| {
@@ -125,12 +125,11 @@ pub fn build(b: *std.build.Builder) !void {
125125
// compile and install
126126
const wpt = b.addExecutable(.{
127127
.name = "browsercore-wpt",
128-
.root_source_file = .{ .path = "src/main_wpt.zig" },
128+
.root_source_file = b.path("src/main_wpt.zig"),
129129
.target = target,
130130
.optimize = mode,
131131
});
132-
try common(wpt, options);
133-
b.installArtifact(wpt);
132+
try common(b, wpt, options);
134133

135134
// run
136135
const wpt_cmd = b.addRunArtifact(wpt);
@@ -147,11 +146,11 @@ pub fn build(b: *std.build.Builder) !void {
147146
// compile and install
148147
const get = b.addExecutable(.{
149148
.name = "browsercore-get",
150-
.root_source_file = .{ .path = "src/main_get.zig" },
149+
.root_source_file = b.path("src/main_get.zig"),
151150
.target = target,
152151
.optimize = mode,
153152
});
154-
try common(get, options);
153+
try common(b, get, options);
155154
b.installArtifact(get);
156155

157156
// run
@@ -165,34 +164,59 @@ pub fn build(b: *std.build.Builder) !void {
165164
}
166165

167166
fn common(
167+
b: *std.Build,
168168
step: *std.Build.Step.Compile,
169169
options: jsruntime.Options,
170170
) !void {
171-
try jsruntime_pkgs.add(step, options);
172-
linkNetSurf(step);
173-
174-
// link mimalloc
175-
step.addObjectFile(.{ .path = "vendor/mimalloc/out/libmimalloc.a" });
176-
step.addIncludePath(.{ .path = "vendor/mimalloc/out/include" });
171+
const jsruntimemod = try jsruntime_pkgs.module(
172+
b,
173+
options,
174+
step.root_module.optimize.?,
175+
step.root_module.resolved_target.?,
176+
);
177+
step.root_module.addImport("jsruntime", jsruntimemod);
178+
179+
const netsurf = moduleNetSurf(b);
180+
netsurf.addImport("jsruntime", jsruntimemod);
181+
step.root_module.addImport("netsurf", netsurf);
177182
}
178183

179-
fn linkNetSurf(step: *std.build.LibExeObjStep) void {
180-
184+
fn moduleNetSurf(b: *std.Build) *std.Build.Module {
185+
const mod = b.addModule("netsurf", .{
186+
.root_source_file = b.path("src/netsurf/netsurf.zig"),
187+
});
181188
// iconv
182-
step.addObjectFile(.{ .path = "vendor/libiconv/lib/libiconv.a" });
183-
step.addIncludePath(.{ .path = "vendor/libiconv/include" });
189+
mod.addObjectFile(b.path("vendor/libiconv/lib/libiconv.a"));
190+
mod.addIncludePath(b.path("vendor/libiconv/include"));
191+
192+
// mimalloc
193+
mod.addImport("mimalloc", moduleMimalloc(b));
184194

185195
// netsurf libs
186196
const ns = "vendor/netsurf";
197+
mod.addIncludePath(b.path(ns ++ "/include"));
198+
187199
const libs: [4][]const u8 = .{
188200
"libdom",
189201
"libhubbub",
190202
"libparserutils",
191203
"libwapcaplet",
192204
};
193205
inline for (libs) |lib| {
194-
step.addObjectFile(.{ .path = ns ++ "/lib/" ++ lib ++ ".a" });
195-
step.addIncludePath(.{ .path = ns ++ "/" ++ lib ++ "/src" });
206+
mod.addObjectFile(b.path(ns ++ "/lib/" ++ lib ++ ".a"));
207+
mod.addIncludePath(b.path(ns ++ "/" ++ lib ++ "/src"));
196208
}
197-
step.addIncludePath(.{ .path = ns ++ "/include" });
209+
210+
return mod;
211+
}
212+
213+
fn moduleMimalloc(b: *std.Build) *std.Build.Module {
214+
const mod = b.addModule("mimalloc", .{
215+
.root_source_file = b.path("src/mimalloc/mimalloc.zig"),
216+
});
217+
218+
mod.addObjectFile(b.path("vendor/mimalloc/out/libmimalloc.a"));
219+
mod.addIncludePath(b.path("vendor/mimalloc/out/include"));
220+
221+
return mod;
198222
}

0 commit comments

Comments
 (0)