mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
0.11: ugrade build.zig
This commit is contained in:
44
build.zig
44
build.zig
@@ -14,12 +14,17 @@ pub fn build(b: *std.build.Builder) !void {
|
||||
// -------
|
||||
|
||||
// compile and install
|
||||
const exe = b.addExecutable("browsercore", "src/main.zig");
|
||||
try common(exe, mode, target, options);
|
||||
exe.install();
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "browsercore",
|
||||
.root_source_file = .{ .path = "src/main.zig" },
|
||||
.target = target,
|
||||
.optimize = mode,
|
||||
});
|
||||
try common(exe, options);
|
||||
b.installArtifact(exe);
|
||||
|
||||
// run
|
||||
const run_cmd = exe.run();
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
@@ -33,14 +38,19 @@ 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, options);
|
||||
try jsruntime_pkgs.add_shell(shell, mode);
|
||||
const shell = b.addExecutable(.{
|
||||
.name = "browsercore-shell",
|
||||
.root_source_file = .{ .path = "src/main_shell.zig" },
|
||||
.target = target,
|
||||
.optimize = mode,
|
||||
});
|
||||
try common(shell, options);
|
||||
try jsruntime_pkgs.add_shell(shell);
|
||||
// do not install shell binary
|
||||
shell.install();
|
||||
b.installArtifact(shell);
|
||||
|
||||
// run
|
||||
const shell_cmd = shell.run();
|
||||
const shell_cmd = b.addRunArtifact(shell);
|
||||
shell_cmd.step.dependOn(b.getInstallStep());
|
||||
if (b.args) |args| {
|
||||
shell_cmd.addArgs(args);
|
||||
@@ -54,8 +64,8 @@ pub fn build(b: *std.build.Builder) !void {
|
||||
// ----
|
||||
|
||||
// compile
|
||||
const exe_tests = b.addTest("src/run_tests.zig");
|
||||
try common(exe_tests, mode, target, options);
|
||||
const exe_tests = b.addTest(.{ .root_source_file = .{ .path = "src/run_tests.zig" } });
|
||||
try common(exe_tests, options);
|
||||
|
||||
// step
|
||||
const test_step = b.step("test", "Run unit tests");
|
||||
@@ -63,20 +73,16 @@ pub fn build(b: *std.build.Builder) !void {
|
||||
}
|
||||
|
||||
fn common(
|
||||
step: *std.build.LibExeObjStep,
|
||||
mode: std.builtin.Mode,
|
||||
target: std.zig.CrossTarget,
|
||||
step: *std.Build.CompileStep,
|
||||
options: jsruntime.Options,
|
||||
) !void {
|
||||
step.setTarget(target);
|
||||
step.setBuildMode(mode);
|
||||
try jsruntime_pkgs.add(step, mode, options);
|
||||
try jsruntime_pkgs.add(step, options);
|
||||
linkLexbor(step);
|
||||
}
|
||||
|
||||
fn linkLexbor(step: *std.build.LibExeObjStep) void {
|
||||
// cmake . -DLEXBOR_BUILD_SHARED=OFF
|
||||
const lib_path = "vendor/lexbor/liblexbor_static.a";
|
||||
step.addObjectFile(lib_path);
|
||||
step.addIncludePath("vendor/lexbor-src/source");
|
||||
step.addObjectFile(.{ .path = lib_path });
|
||||
step.addIncludePath(.{ .path = "vendor/lexbor-src/source" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user