mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
build v8 with zig
This commit is contained in:
15
Makefile
15
Makefile
@@ -47,7 +47,7 @@ help:
|
|||||||
|
|
||||||
# $(ZIG) commands
|
# $(ZIG) commands
|
||||||
# ------------
|
# ------------
|
||||||
.PHONY: build build-dev run run-release shell test bench download-zig wpt data get-v8 build-v8 build-v8-dev
|
.PHONY: build build-dev run run-release shell test bench download-zig wpt data
|
||||||
.PHONY: end2end
|
.PHONY: end2end
|
||||||
|
|
||||||
zig_version = $(shell grep 'recommended_zig_version = "' "vendor/zig-js-runtime/build.zig" | cut -d'"' -f2)
|
zig_version = $(shell grep 'recommended_zig_version = "' "vendor/zig-js-runtime/build.zig" | cut -d'"' -f2)
|
||||||
@@ -112,19 +112,6 @@ end2end:
|
|||||||
@test -d ../demo
|
@test -d ../demo
|
||||||
cd ../demo && go run runner/main.go
|
cd ../demo && go run runner/main.go
|
||||||
|
|
||||||
## v8
|
|
||||||
get-v8:
|
|
||||||
@printf "\e[36mGetting v8 source...\e[0m\n"
|
|
||||||
@$(ZIG) build get-v8
|
|
||||||
|
|
||||||
build-v8-dev:
|
|
||||||
@printf "\e[36mBuilding v8 (dev)...\e[0m\n"
|
|
||||||
@$(ZIG) build build-v8
|
|
||||||
|
|
||||||
build-v8:
|
|
||||||
@printf "\e[36mBuilding v8...\e[0m\n"
|
|
||||||
@$(ZIG) build -Doptimize=ReleaseSafe build-v8
|
|
||||||
|
|
||||||
# Install and build required dependencies commands
|
# Install and build required dependencies commands
|
||||||
# ------------
|
# ------------
|
||||||
.PHONY: install-submodule
|
.PHONY: install-submodule
|
||||||
|
|||||||
39
build.zig
39
build.zig
@@ -131,24 +131,6 @@ pub fn build(b: *Build) !void {
|
|||||||
const wpt_step = b.step("wpt", "WPT tests");
|
const wpt_step = b.step("wpt", "WPT tests");
|
||||||
wpt_step.dependOn(&wpt_cmd.step);
|
wpt_step.dependOn(&wpt_cmd.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
// get v8
|
|
||||||
// -------
|
|
||||||
const v8 = b.dependency("v8", .{ .target = target, .optimize = optimize });
|
|
||||||
const get_v8 = b.addRunArtifact(v8.artifact("get-v8"));
|
|
||||||
const get_step = b.step("get-v8", "Get v8");
|
|
||||||
get_step.dependOn(&get_v8.step);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// build v8
|
|
||||||
// -------
|
|
||||||
const v8 = b.dependency("v8", .{ .target = target, .optimize = optimize });
|
|
||||||
const build_v8 = b.addRunArtifact(v8.artifact("build-v8"));
|
|
||||||
const build_step = b.step("build-v8", "Build v8");
|
|
||||||
build_step.dependOn(&build_v8.step);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !void {
|
fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !void {
|
||||||
@@ -172,27 +154,6 @@ fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !vo
|
|||||||
v8_mod.addOptions("default_exports", v8_opts);
|
v8_mod.addOptions("default_exports", v8_opts);
|
||||||
mod.addImport("v8", v8_mod);
|
mod.addImport("v8", v8_mod);
|
||||||
|
|
||||||
const release_dir = if (mod.optimize.? == .Debug) "debug" else "release";
|
|
||||||
const os = switch (target.result.os.tag) {
|
|
||||||
.linux => "linux",
|
|
||||||
.macos => "macos",
|
|
||||||
else => return error.UnsupportedPlatform,
|
|
||||||
};
|
|
||||||
var lib_path = try std.fmt.allocPrint(
|
|
||||||
mod.owner.allocator,
|
|
||||||
"v8/out/{s}/{s}/obj/zig/libc_v8.a",
|
|
||||||
.{ os, release_dir },
|
|
||||||
);
|
|
||||||
std.fs.cwd().access(lib_path, .{}) catch {
|
|
||||||
// legacy path
|
|
||||||
lib_path = try std.fmt.allocPrint(
|
|
||||||
mod.owner.allocator,
|
|
||||||
"v8/out/{s}/obj/zig/libc_v8.a",
|
|
||||||
.{release_dir},
|
|
||||||
);
|
|
||||||
};
|
|
||||||
mod.addObjectFile(mod.owner.path(lib_path));
|
|
||||||
|
|
||||||
switch (target.result.os.tag) {
|
switch (target.result.os.tag) {
|
||||||
.macos => {
|
.macos => {
|
||||||
// v8 has a dependency, abseil-cpp, which, on Mac, uses CoreFoundation
|
// v8 has a dependency, abseil-cpp, which, on Mac, uses CoreFoundation
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
.fingerprint = 0xda130f3af836cea0,
|
.fingerprint = 0xda130f3af836cea0,
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.v8 = .{
|
.v8 = .{
|
||||||
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/305bb3706716d32d59b2ffa674731556caa1002b.tar.gz",
|
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/fbefa84efdf1b5c1401c930cdc5e99aee508a1f9.tar.gz",
|
||||||
.hash = "v8-0.0.0-xddH63bVAwBSEobaUok9J0er1FqsvEujCDDVy6ItqKQ5",
|
.hash = "v8-0.0.0-xddH62UlBAC-QfZy4qD6pF87wF8VjY54IOTu8SnFV4ub",
|
||||||
},
|
},
|
||||||
//.v8 = .{ .path = "../zig-v8-fork" }
|
//.v8 = .{ .path = "../zig-v8-fork" },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user