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