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();