Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/wpt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

runs-on: ubuntu-latest
container:
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.0-dev.1773-8a8fd47d2
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.1
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zig-fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

runs-on: ubuntu-latest
container:
image: ghcr.io/lightpanda-io/zig:0.12.0-dev.1773-8a8fd47d2
image: ghcr.io/lightpanda-io/zig:0.12.1
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/zig-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

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

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

runs-on: ubuntu-latest
container:
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.0-dev.1773-8a8fd47d2
image: ghcr.io/lightpanda-io/zig-browsercore:0.12.1
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ We do not provide yet binary versions of Lightpanda, you have to compile it from

### Prerequisites

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

Lightpanda also depends on
Expand Down
84 changes: 54 additions & 30 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const jsruntime_pkgs = jsruntime.packages(jsruntime_path);
/// which zig version to install.
const recommended_zig_version = jsruntime.recommended_zig_version;

pub fn build(b: *std.build.Builder) !void {
pub fn build(b: *std.Build) !void {
switch (comptime builtin.zig_version.order(std.SemanticVersion.parse(recommended_zig_version) catch unreachable)) {
.eq => {},
.lt => {
Expand All @@ -53,11 +53,11 @@ pub fn build(b: *std.build.Builder) !void {
// compile and install
const exe = b.addExecutable(.{
.name = "browsercore",
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = mode,
});
try common(exe, options);
try common(b, exe, options);
b.installArtifact(exe);

// run
Expand All @@ -76,11 +76,11 @@ pub fn build(b: *std.build.Builder) !void {
// compile and install
const shell = b.addExecutable(.{
.name = "browsercore-shell",
.root_source_file = .{ .path = "src/main_shell.zig" },
.root_source_file = b.path("src/main_shell.zig"),
.target = target,
.optimize = mode,
});
try common(shell, options);
try common(b, shell, options);
try jsruntime_pkgs.add_shell(shell);

// run
Expand All @@ -98,17 +98,17 @@ pub fn build(b: *std.build.Builder) !void {

// compile
const tests = b.addTest(.{
.root_source_file = .{ .path = "src/run_tests.zig" },
.test_runner = "src/test_runner.zig",
.single_threaded = true,
.root_source_file = b.path("src/run_tests.zig"),
.test_runner = b.path("src/test_runner.zig"),
.target = target,
.optimize = mode,
});
try common(tests, options);
try common(b, tests, options);

// add jsruntime pretty deps
const pretty = tests.step.owner.createModule(.{
.source_file = .{ .path = "vendor/zig-js-runtime/src/pretty.zig" },
tests.root_module.addAnonymousImport("pretty", .{
.root_source_file = b.path("vendor/zig-js-runtime/src/pretty.zig"),
});
tests.addModule("pretty", pretty);

const run_tests = b.addRunArtifact(tests);
if (b.args) |args| {
Expand All @@ -125,12 +125,11 @@ pub fn build(b: *std.build.Builder) !void {
// compile and install
const wpt = b.addExecutable(.{
.name = "browsercore-wpt",
.root_source_file = .{ .path = "src/main_wpt.zig" },
.root_source_file = b.path("src/main_wpt.zig"),
.target = target,
.optimize = mode,
});
try common(wpt, options);
b.installArtifact(wpt);
try common(b, wpt, options);

// run
const wpt_cmd = b.addRunArtifact(wpt);
Expand All @@ -147,11 +146,11 @@ pub fn build(b: *std.build.Builder) !void {
// compile and install
const get = b.addExecutable(.{
.name = "browsercore-get",
.root_source_file = .{ .path = "src/main_get.zig" },
.root_source_file = b.path("src/main_get.zig"),
.target = target,
.optimize = mode,
});
try common(get, options);
try common(b, get, options);
b.installArtifact(get);

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

fn common(
b: *std.Build,
step: *std.Build.Step.Compile,
options: jsruntime.Options,
) !void {
try jsruntime_pkgs.add(step, options);
linkNetSurf(step);

// link mimalloc
step.addObjectFile(.{ .path = "vendor/mimalloc/out/libmimalloc.a" });
step.addIncludePath(.{ .path = "vendor/mimalloc/out/include" });
const jsruntimemod = try jsruntime_pkgs.module(
b,
options,
step.root_module.optimize.?,
step.root_module.resolved_target.?,
);
step.root_module.addImport("jsruntime", jsruntimemod);

const netsurf = moduleNetSurf(b);
netsurf.addImport("jsruntime", jsruntimemod);
step.root_module.addImport("netsurf", netsurf);
}

fn linkNetSurf(step: *std.build.LibExeObjStep) void {

fn moduleNetSurf(b: *std.Build) *std.Build.Module {
const mod = b.addModule("netsurf", .{
.root_source_file = b.path("src/netsurf/netsurf.zig"),
});
// iconv
step.addObjectFile(.{ .path = "vendor/libiconv/lib/libiconv.a" });
step.addIncludePath(.{ .path = "vendor/libiconv/include" });
mod.addObjectFile(b.path("vendor/libiconv/lib/libiconv.a"));
mod.addIncludePath(b.path("vendor/libiconv/include"));

// mimalloc
mod.addImport("mimalloc", moduleMimalloc(b));

// netsurf libs
const ns = "vendor/netsurf";
mod.addIncludePath(b.path(ns ++ "/include"));

const libs: [4][]const u8 = .{
"libdom",
"libhubbub",
"libparserutils",
"libwapcaplet",
};
inline for (libs) |lib| {
step.addObjectFile(.{ .path = ns ++ "/lib/" ++ lib ++ ".a" });
step.addIncludePath(.{ .path = ns ++ "/" ++ lib ++ "/src" });
mod.addObjectFile(b.path(ns ++ "/lib/" ++ lib ++ ".a"));
mod.addIncludePath(b.path(ns ++ "/" ++ lib ++ "/src"));
}
step.addIncludePath(.{ .path = ns ++ "/include" });

return mod;
}

fn moduleMimalloc(b: *std.Build) *std.Build.Module {
const mod = b.addModule("mimalloc", .{
.root_source_file = b.path("src/mimalloc/mimalloc.zig"),
});

mod.addObjectFile(b.path("vendor/mimalloc/out/libmimalloc.a"));
mod.addIncludePath(b.path("vendor/mimalloc/out/include"));

return mod;
}
Loading