Skip to content

Lightpanda: the headless browser designed for AI and automation

Merge pull request #3231 from lightpanda-io/screenshot

Karl Seguin289502e19a04
diff --cc build.zig
index ec613c997,8aa420445..9e9f54ecb
--- a/build.zig
+++ b/build.zig
@@@ -330,34 -331,25 +331,29 @@@ fn linkRust(b: *Build, mod: *Build.Modu
"cargo", "build",
"--profile", if (is_debug) "dev" else "release",
"--features", if (is_debug) "memstats" else "",
- "--manifest-path", "src/html5ever/Cargo.toml",
+ "--manifest-path", "src/rust/ffi/Cargo.toml",
});
- // Track Rust sources so edits invalidate the cargo step's cache.
- // Without this, Zig keys the step on argv only and won't re-run cargo
- // when lib.rs/Cargo.toml change.
- for ([_][]const u8{
- "src/html5ever/Cargo.toml",
- "src/html5ever/Cargo.lock",
- "src/html5ever/lib.rs",
- "src/html5ever/sink.rs",
- "src/html5ever/types.rs",
- "src/html5ever/url.rs",
- }) |path| {
- exec_cargo.addFileInput(b.path(path));
- }
+ addDirInputs(b, exec_cargo, "src/rust", "target") catch |err| {
+ std.debug.panic("walk src/rust: {t}", .{err});
+ };
+
+ // Cargo reports progress on stderr; left uncaptured, Zig prints it as a
+ // "failed command: ..." diagnostic on a successful build. A non-zero exit
+ // still surfaces the captured output.
+ _ = exec_cargo.captureStdErr(.{});
+ // don't let cargo's progress report (sent to stderr) cause Zig's build to
+ // print a 'failed command: ...' message. (non-zero status still outputs the error)
+ _ = exec_cargo.captureStdErr(.{});
+
// TODO: We can prefer `--artifact-dir` once it become stable.
- const out_dir = exec_cargo.addPrefixedOutputDirectoryArg("--target-dir=", "html5ever");
+ const out_dir = exec_cargo.addPrefixedOutputDirectoryArg("--target-dir=", "rust");
- const html5ever_step = b.step("html5ever", "Install html5ever dependency (requires cargo)");
- html5ever_step.dependOn(&exec_cargo.step);
+ const rust_step = b.step("rust", "Build the Rust staticlib (requires cargo)");
+ rust_step.dependOn(&exec_cargo.step);
- const obj = out_dir.path(b, if (is_debug) "debug" else "release").path(b, "liblitefetch_html5ever.a");
+ const obj = out_dir.path(b, if (is_debug) "debug" else "release").path(b, "liblightpanda_ffi.a");
mod.addObjectFile(obj);
}