diff --git a/Makefile b/Makefile index c7b2d36c..89dd7145 100644 --- a/Makefile +++ b/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" diff --git a/build.zig b/build.zig index 4834dcdd..62c4e783 100644 --- a/build.zig +++ b/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); } diff --git a/src/main_shell.zig b/src/main_shell.zig index 18871fb0..ffb56311 100644 --- a/src/main_shell.zig +++ b/src/main_shell.zig @@ -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"); diff --git a/src/run_tests.zig b/src/run_tests.zig index ff4f51de..ff579757 100644 --- a/src/run_tests.zig +++ b/src/run_tests.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