Merge pull request #1286 from lightpanda-io/zigdom-single-build

Single Build Command
This commit is contained in:
Karl Seguin
2025-12-24 07:09:59 +08:00
committed by GitHub
2 changed files with 40 additions and 39 deletions

View File

@@ -36,6 +36,8 @@ runs:
# Zig version used from the `minimum_zig_version` field in build.zig.zon # Zig version used from the `minimum_zig_version` field in build.zig.zon
- uses: mlugg/setup-zig@v2 - uses: mlugg/setup-zig@v2
# Rust Toolchain for html5ever
- uses: dtolnay/rust-toolchain@stable
- name: Cache v8 - name: Cache v8
id: cache-v8 id: cache-v8
@@ -58,9 +60,3 @@ runs:
run: | run: |
mkdir -p v8 mkdir -p v8
ln -s ${{ inputs.cache-dir }}/v8/libc_v8.a v8/libc_v8.a 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

View File

@@ -36,31 +36,6 @@ pub fn build(b: *Build) !void {
opts.addOption([]const u8, "git_commit", git_commit orelse "dev"); opts.addOption([]const u8, "git_commit", git_commit orelse "dev");
opts.addOption(?[]const u8, "snapshot_path", snapshot_path); 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_tsan = b.option(bool, "tsan", "Enable Thread Sanitizer");
const enable_csan = b.option(std.zig.SanitizeC, "csan", "Enable C Sanitizers"); 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; 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 // browser
const exe = b.addExecutable(.{ 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")); 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);
opts.step.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 // v8
const v8_opts = b.addOptions(); const v8_opts = b.addOptions();