From 596ee82a527eebf0f373545454c1165b5aefbe11 Mon Sep 17 00:00:00 2001 From: Muki Kiboigo Date: Fri, 19 Dec 2025 11:37:22 -0800 Subject: [PATCH 1/2] zig build builds everything --- build.zig | 71 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/build.zig b/build.zig index 4378ade1..8adf7b44 100644 --- a/build.zig +++ b/build.zig @@ -36,31 +36,6 @@ pub fn build(b: *Build) !void { opts.addOption([]const u8, "git_commit", git_commit orelse "dev"); opts.addOption(?[]const u8, "snapshot_path", snapshot_path); - // Build step to install html5ever dependency. - const html5ever_argv = blk: { - const argv: []const []const u8 = &.{ - "cargo", - "build", - // Seems cargo can figure out required paths out of Cargo.toml. - "--manifest-path", - "src/html5ever/Cargo.toml", - // TODO: We can prefer `--artifact-dir` once it become stable. - "--target-dir", - b.getInstallPath(.prefix, "html5ever"), - // This must be the last argument. - "--release", - }; - - break :blk switch (optimize) { - // Prefer dev build on debug option. - .Debug => argv[0 .. argv.len - 1], - else => argv, - }; - }; - const html5ever_exec_cargo = b.addSystemCommand(html5ever_argv); - const html5ever_step = b.step("html5ever", "Install html5ever dependency (requires cargo)"); - html5ever_step.dependOn(&html5ever_exec_cargo.step); - const enable_tsan = b.option(bool, "tsan", "Enable Thread Sanitizer"); const enable_csan = b.option(std.zig.SanitizeC, "csan", "Enable C Sanitizers"); @@ -80,14 +55,6 @@ pub fn build(b: *Build) !void { break :blk mod; }; - const html5ever_obj = switch (optimize) { - .Debug => b.getInstallPath(.prefix, "html5ever/debug/liblitefetch_html5ever.a"), - // Release builds. - else => b.getInstallPath(.prefix, "html5ever/release/liblitefetch_html5ever.a"), - }; - - lightpanda_module.addObjectFile(.{ .cwd_relative = html5ever_obj }); - { // browser const exe = b.addExecutable(.{ @@ -217,6 +184,44 @@ fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options, pre mod.addIncludePath(b.path("vendor/lightpanda")); + { + // html5ever + + // Build step to install html5ever dependency. + const html5ever_argv = blk: { + const argv: []const []const u8 = &.{ + "cargo", + "build", + // Seems cargo can figure out required paths out of Cargo.toml. + "--manifest-path", + "src/html5ever/Cargo.toml", + // TODO: We can prefer `--artifact-dir` once it become stable. + "--target-dir", + b.getInstallPath(.prefix, "html5ever"), + // This must be the last argument. + "--release", + }; + + break :blk switch (mod.optimize.?) { + // Prefer dev build on debug option. + .Debug => argv[0 .. argv.len - 1], + else => argv, + }; + }; + const html5ever_exec_cargo = b.addSystemCommand(html5ever_argv); + const html5ever_step = b.step("html5ever", "Install html5ever dependency (requires cargo)"); + html5ever_step.dependOn(&html5ever_exec_cargo.step); + b.getInstallStep().dependOn(html5ever_step); + + const html5ever_obj = switch (mod.optimize.?) { + .Debug => b.getInstallPath(.prefix, "html5ever/debug/liblitefetch_html5ever.a"), + // Release builds. + else => b.getInstallPath(.prefix, "html5ever/release/liblitefetch_html5ever.a"), + }; + + mod.addObjectFile(.{ .cwd_relative = html5ever_obj }); + } + { // v8 const v8_opts = b.addOptions(); From c9f6cb75200356b540b117b644ecabbc7b48fdd7 Mon Sep 17 00:00:00 2001 From: Muki Kiboigo Date: Mon, 22 Dec 2025 10:41:22 -0800 Subject: [PATCH 2/2] fix single build with rust in ci --- .github/actions/install/action.yml | 8 ++------ build.zig | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/actions/install/action.yml b/.github/actions/install/action.yml index 8ed95370..bf29a12a 100644 --- a/.github/actions/install/action.yml +++ b/.github/actions/install/action.yml @@ -36,6 +36,8 @@ runs: # Zig version used from the `minimum_zig_version` field in build.zig.zon - uses: mlugg/setup-zig@v2 + # Rust Toolchain for html5ever + - uses: dtolnay/rust-toolchain@stable - name: Cache v8 id: cache-v8 @@ -58,9 +60,3 @@ runs: run: | mkdir -p v8 ln -s ${{ inputs.cache-dir }}/v8/libc_v8.a v8/libc_v8.a - - - name: hmtl5ever - shell: bash - run: | - zig build html5ever - zig build -Doptimize=ReleaseFast html5ever diff --git a/build.zig b/build.zig index 8adf7b44..2f761073 100644 --- a/build.zig +++ b/build.zig @@ -211,7 +211,7 @@ fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options, pre const html5ever_exec_cargo = b.addSystemCommand(html5ever_argv); const html5ever_step = b.step("html5ever", "Install html5ever dependency (requires cargo)"); html5ever_step.dependOn(&html5ever_exec_cargo.step); - b.getInstallStep().dependOn(html5ever_step); + opts.step.dependOn(html5ever_step); const html5ever_obj = switch (mod.optimize.?) { .Debug => b.getInstallPath(.prefix, "html5ever/debug/liblitefetch_html5ever.a"),