mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
Update to jsruntime engine interface
Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
8
Makefile
8
Makefile
@@ -22,12 +22,12 @@ help:
|
||||
## Build in debug mode
|
||||
build:
|
||||
@printf "\e[36mBuilding (debug)...\e[0m\n"
|
||||
@zig build || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
||||
@zig build -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
||||
@printf "\e[33mBuild OK\e[0m\n"
|
||||
|
||||
build-release:
|
||||
@printf "\e[36mBuilding (release safe)...\e[0m\n"
|
||||
@zig build -Drelease-safe || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
||||
@zig build -Drelease-safe -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
||||
@printf "\e[33mBuild OK\e[0m\n"
|
||||
|
||||
## Run the server
|
||||
@@ -38,10 +38,10 @@ run: build
|
||||
## Run a JS shell in release-safe mode
|
||||
shell:
|
||||
@printf "\e[36mBuilding shell...\e[0m\n"
|
||||
@zig build shell || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
||||
@zig build shell -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;)
|
||||
|
||||
## Test
|
||||
test:
|
||||
@printf "\e[36mTesting...\e[0m\n"
|
||||
@zig build test || (printf "\e[33mTest ERROR\e[0m\n"; exit 1;)
|
||||
@zig build test -Dengine=v8 || (printf "\e[33mTest ERROR\e[0m\n"; exit 1;)
|
||||
@printf "\e[33mTest OK\e[0m\n"
|
||||
|
||||
16
build.zig
16
build.zig
@@ -1,18 +1,21 @@
|
||||
const std = @import("std");
|
||||
|
||||
const jsruntime_path: []const u8 = "vendor/jsruntime-lib/";
|
||||
const jsruntime_pkgs = @import("vendor/jsruntime-lib/build.zig").packages(jsruntime_path);
|
||||
const jsruntime_path = "vendor/jsruntime-lib/";
|
||||
const jsruntime = @import("vendor/jsruntime-lib/build.zig");
|
||||
const jsruntime_pkgs = jsruntime.packages(jsruntime_path);
|
||||
|
||||
pub fn build(b: *std.build.Builder) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const mode = b.standardReleaseOptions();
|
||||
|
||||
const options = try jsruntime.buildOptions(b);
|
||||
|
||||
// browser
|
||||
// -------
|
||||
|
||||
// compile and install
|
||||
const exe = b.addExecutable("browsercore", "src/main.zig");
|
||||
try common(exe, mode, target);
|
||||
try common(exe, mode, target, options);
|
||||
exe.install();
|
||||
|
||||
// run
|
||||
@@ -31,7 +34,7 @@ pub fn build(b: *std.build.Builder) !void {
|
||||
|
||||
// compile and install
|
||||
const shell = b.addExecutable("browsercore-shell", "src/main_shell.zig");
|
||||
try common(shell, mode, target);
|
||||
try common(shell, mode, target, options);
|
||||
try jsruntime_pkgs.add_shell(shell, mode);
|
||||
// do not install shell binary
|
||||
shell.install();
|
||||
@@ -52,7 +55,7 @@ pub fn build(b: *std.build.Builder) !void {
|
||||
|
||||
// compile
|
||||
const exe_tests = b.addTest("src/run_tests.zig");
|
||||
try common(exe_tests, mode, target);
|
||||
try common(exe_tests, mode, target, options);
|
||||
|
||||
// step
|
||||
const test_step = b.step("test", "Run unit tests");
|
||||
@@ -63,10 +66,11 @@ fn common(
|
||||
step: *std.build.LibExeObjStep,
|
||||
mode: std.builtin.Mode,
|
||||
target: std.zig.CrossTarget,
|
||||
options: jsruntime.Options,
|
||||
) !void {
|
||||
step.setTarget(target);
|
||||
step.setBuildMode(mode);
|
||||
try jsruntime_pkgs.add(step, mode);
|
||||
try jsruntime_pkgs.add(step, mode, options);
|
||||
linkLexbor(step);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const std = @import("std");
|
||||
|
||||
const jsruntime = @import("jsruntime");
|
||||
const Console = @import("jsruntime").Console;
|
||||
|
||||
const parser = @import("parser.zig");
|
||||
const DOM = @import("dom.zig");
|
||||
|
||||
@@ -18,7 +18,7 @@ fn testsExecFn(
|
||||
) !void {
|
||||
|
||||
// start JS env
|
||||
js_env.start();
|
||||
js_env.start(apis);
|
||||
defer js_env.stop();
|
||||
|
||||
// add document object
|
||||
|
||||
Reference in New Issue
Block a user