mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-16 16:28:58 +00:00
Merge pull request #1234 from lightpanda-io/nikneym/html5ever-build-changes
Add a build step for `html5ever` in `build.zig`
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,4 +3,4 @@
|
|||||||
lightpanda.id
|
lightpanda.id
|
||||||
/v8/
|
/v8/
|
||||||
/build/
|
/build/
|
||||||
src/html5ever/target/
|
/src/html5ever/target/
|
||||||
|
|||||||
11
Makefile
11
Makefile
@@ -127,20 +127,13 @@ build-v8:
|
|||||||
|
|
||||||
# Install and build required dependencies commands
|
# Install and build required dependencies commands
|
||||||
# ------------
|
# ------------
|
||||||
.PHONY: install-html5ever install-html5ever-dev
|
|
||||||
.PHONY: install install-dev
|
.PHONY: install install-dev
|
||||||
|
|
||||||
## Install and build dependencies for release
|
## Install and build dependencies for release
|
||||||
install: install-submodule install-html5ever
|
install: install-submodule
|
||||||
|
|
||||||
## Install and build dependencies for dev
|
## Install and build dependencies for dev
|
||||||
install-dev: install-submodule install-html5ever-dev
|
install-dev: install-submodule
|
||||||
|
|
||||||
install-html5ever:
|
|
||||||
cd src/html5ever && cargo build --release --target-dir ../../build/html5ever/
|
|
||||||
|
|
||||||
install-html5ever-dev:
|
|
||||||
cd src/html5ever && cargo build --target-dir ../../build/html5ever/
|
|
||||||
|
|
||||||
data:
|
data:
|
||||||
cd src/data && go run public_suffix_list_gen.go > public_suffix_list.zig
|
cd src/data && go run public_suffix_list_gen.go > public_suffix_list.zig
|
||||||
|
|||||||
43
build.zig
43
build.zig
@@ -39,6 +39,9 @@ pub fn build(b: *Build) !void {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const target = b.standardTargetOptions(.{});
|
||||||
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
var opts = b.addOptions();
|
var opts = b.addOptions();
|
||||||
opts.addOption(
|
opts.addOption(
|
||||||
[]const u8,
|
[]const u8,
|
||||||
@@ -46,8 +49,30 @@ pub fn build(b: *Build) !void {
|
|||||||
b.option([]const u8, "git_commit", "Current git commit") orelse "dev",
|
b.option([]const u8, "git_commit", "Current git commit") orelse "dev",
|
||||||
);
|
);
|
||||||
|
|
||||||
const target = b.standardTargetOptions(.{});
|
// Build step to install html5ever dependency.
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
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) {
|
||||||
|
// Consider these as dev builds.
|
||||||
|
.Debug, .ReleaseSafe => argv[0 .. argv.len - 1],
|
||||||
|
.ReleaseFast, .ReleaseSmall => 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");
|
||||||
@@ -65,16 +90,16 @@ pub fn build(b: *Build) !void {
|
|||||||
|
|
||||||
try addDependencies(b, mod, opts);
|
try addDependencies(b, mod, opts);
|
||||||
|
|
||||||
if (optimize == .ReleaseFast or optimize == .ReleaseSmall) {
|
|
||||||
mod.addLibraryPath(b.path("build/html5ever/release"));
|
|
||||||
} else {
|
|
||||||
mod.addLibraryPath(b.path("build/html5ever/debug"));
|
|
||||||
}
|
|
||||||
mod.linkSystemLibrary("litefetch_html5ever", .{});
|
|
||||||
|
|
||||||
break :blk mod;
|
break :blk mod;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const html5ever_obj = switch (optimize) {
|
||||||
|
.Debug, .ReleaseSafe => b.getInstallPath(.prefix, "html5ever/debug/liblitefetch_html5ever.a"),
|
||||||
|
.ReleaseFast, .ReleaseSmall => 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(.{
|
||||||
|
|||||||
Reference in New Issue
Block a user