mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
Makes build.zig Zig 0.15 ready
Our build.zig is using a number of deprecated features, which are removed in 0.15. This updates build.zig so that it still works in 0.14 and [hopefully] will work in 0.15. Related: https://github.com/lightpanda-io/zig-v8-fork/pull/87
This commit is contained in:
140
build.zig
140
build.zig
@@ -49,6 +49,13 @@ pub fn build(b: *Build) !void {
|
|||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
|
const lightpanda_module = b.addModule("lightpanda", .{
|
||||||
|
.root_source_file = b.path("src/main.zig"),
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
try addDependencies(b, lightpanda_module, opts);
|
||||||
|
|
||||||
{
|
{
|
||||||
// browser
|
// browser
|
||||||
// -------
|
// -------
|
||||||
@@ -56,12 +63,8 @@ pub fn build(b: *Build) !void {
|
|||||||
// compile and install
|
// compile and install
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "lightpanda",
|
.name = "lightpanda",
|
||||||
.target = target,
|
.root_module = lightpanda_module,
|
||||||
.optimize = optimize,
|
|
||||||
.root_source_file = b.path("src/main.zig"),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
try common(b, opts, exe);
|
|
||||||
b.installArtifact(exe);
|
b.installArtifact(exe);
|
||||||
|
|
||||||
// run
|
// run
|
||||||
@@ -75,6 +78,52 @@ pub fn build(b: *Build) !void {
|
|||||||
run_step.dependOn(&run_cmd.step);
|
run_step.dependOn(&run_cmd.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// tests
|
||||||
|
// ----
|
||||||
|
|
||||||
|
// compile
|
||||||
|
const tests = b.addTest(.{
|
||||||
|
.root_module = lightpanda_module,
|
||||||
|
.test_runner = .{ .path = b.path("src/test_runner.zig"), .mode = .simple },
|
||||||
|
});
|
||||||
|
|
||||||
|
const run_tests = b.addRunArtifact(tests);
|
||||||
|
if (b.args) |args| {
|
||||||
|
run_tests.addArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// step
|
||||||
|
const tests_step = b.step("test", "Run unit tests");
|
||||||
|
tests_step.dependOn(&run_tests.step);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// wpt
|
||||||
|
// -----
|
||||||
|
const wpt_module = b.addModule("lightpanda", .{
|
||||||
|
.root_source_file = b.path("src/main_wpt.zig"),
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
try addDependencies(b, wpt_module, opts);
|
||||||
|
|
||||||
|
// compile and install
|
||||||
|
const wpt = b.addExecutable(.{
|
||||||
|
.name = "lightpanda-wpt",
|
||||||
|
.root_module = wpt_module,
|
||||||
|
});
|
||||||
|
|
||||||
|
// run
|
||||||
|
const wpt_cmd = b.addRunArtifact(wpt);
|
||||||
|
if (b.args) |args| {
|
||||||
|
wpt_cmd.addArgs(args);
|
||||||
|
}
|
||||||
|
// step
|
||||||
|
const wpt_step = b.step("wpt", "WPT tests");
|
||||||
|
wpt_step.dependOn(&wpt_cmd.step);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// get v8
|
// get v8
|
||||||
// -------
|
// -------
|
||||||
@@ -92,70 +141,24 @@ pub fn build(b: *Build) !void {
|
|||||||
const build_step = b.step("build-v8", "Build v8");
|
const build_step = b.step("build-v8", "Build v8");
|
||||||
build_step.dependOn(&build_v8.step);
|
build_step.dependOn(&build_v8.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
// tests
|
|
||||||
// ----
|
|
||||||
|
|
||||||
// compile
|
|
||||||
const tests = b.addTest(.{
|
|
||||||
.root_source_file = b.path("src/main.zig"),
|
|
||||||
.test_runner = .{ .path = b.path("src/test_runner.zig"), .mode = .simple },
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
try common(b, opts, tests);
|
|
||||||
|
|
||||||
const run_tests = b.addRunArtifact(tests);
|
|
||||||
if (b.args) |args| {
|
|
||||||
run_tests.addArgs(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// step
|
|
||||||
const tests_step = b.step("test", "Run unit tests");
|
|
||||||
tests_step.dependOn(&run_tests.step);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// wpt
|
|
||||||
// -----
|
|
||||||
|
|
||||||
// compile and install
|
|
||||||
const wpt = b.addExecutable(.{
|
|
||||||
.name = "lightpanda-wpt",
|
|
||||||
.root_source_file = b.path("src/main_wpt.zig"),
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
try common(b, opts, wpt);
|
|
||||||
|
|
||||||
// run
|
|
||||||
const wpt_cmd = b.addRunArtifact(wpt);
|
|
||||||
if (b.args) |args| {
|
|
||||||
wpt_cmd.addArgs(args);
|
|
||||||
}
|
|
||||||
// step
|
|
||||||
const wpt_step = b.step("wpt", "WPT tests");
|
|
||||||
wpt_step.dependOn(&wpt_cmd.step);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn common(b: *Build, opts: *Build.Step.Options, step: *Build.Step.Compile) !void {
|
fn addDependencies(b: *Build, mod: *Build.Module, opts: *Build.Step.Options) !void {
|
||||||
const mod = step.root_module;
|
try moduleNetSurf(b, mod);
|
||||||
const target = mod.resolved_target.?;
|
|
||||||
const optimize = mod.optimize.?;
|
|
||||||
const dep_opts = .{ .target = target, .optimize = optimize };
|
|
||||||
|
|
||||||
try moduleNetSurf(b, step, target);
|
|
||||||
mod.addImport("build_config", opts.createModule());
|
mod.addImport("build_config", opts.createModule());
|
||||||
|
|
||||||
|
const target = mod.resolved_target.?;
|
||||||
|
const dep_opts = .{
|
||||||
|
.target = target,
|
||||||
|
.optimize = mod.optimize.?,
|
||||||
|
};
|
||||||
|
|
||||||
mod.addImport("tigerbeetle-io", b.dependency("tigerbeetle_io", .{}).module("tigerbeetle_io"));
|
mod.addImport("tigerbeetle-io", b.dependency("tigerbeetle_io", .{}).module("tigerbeetle_io"));
|
||||||
|
|
||||||
mod.addIncludePath(b.path("vendor/lightpanda"));
|
mod.addIncludePath(b.path("vendor/lightpanda"));
|
||||||
|
|
||||||
{
|
{
|
||||||
// v8
|
// v8
|
||||||
mod.link_libcpp = true;
|
|
||||||
|
|
||||||
const v8_opts = b.addOptions();
|
const v8_opts = b.addOptions();
|
||||||
v8_opts.addOption(bool, "inspector_subtype", false);
|
v8_opts.addOption(bool, "inspector_subtype", false);
|
||||||
|
|
||||||
@@ -386,7 +389,8 @@ fn common(b: *Build, opts: *Build.Step.Options, step: *Build.Step.Compile) !void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn moduleNetSurf(b: *Build, step: *Build.Step.Compile, target: std.Build.ResolvedTarget) !void {
|
fn moduleNetSurf(b: *Build, mod: *Build.Module) !void {
|
||||||
|
const target = mod.resolved_target.?;
|
||||||
const os = target.result.os.tag;
|
const os = target.result.os.tag;
|
||||||
const arch = target.result.cpu.arch;
|
const arch = target.result.cpu.arch;
|
||||||
|
|
||||||
@@ -401,8 +405,8 @@ fn moduleNetSurf(b: *Build, step: *Build.Step.Compile, target: std.Build.Resolve
|
|||||||
"vendor/libiconv/out/{s}-{s}/lib/libiconv.a",
|
"vendor/libiconv/out/{s}-{s}/lib/libiconv.a",
|
||||||
.{ @tagName(os), @tagName(arch) },
|
.{ @tagName(os), @tagName(arch) },
|
||||||
);
|
);
|
||||||
step.addObjectFile(b.path(libiconv_lib_path));
|
mod.addObjectFile(b.path(libiconv_lib_path));
|
||||||
step.addIncludePath(b.path(libiconv_include_path));
|
mod.addIncludePath(b.path(libiconv_include_path));
|
||||||
|
|
||||||
{
|
{
|
||||||
// mimalloc
|
// mimalloc
|
||||||
@@ -412,8 +416,8 @@ fn moduleNetSurf(b: *Build, step: *Build.Step.Compile, target: std.Build.Resolve
|
|||||||
mimalloc ++ "/out/{s}-{s}/lib/libmimalloc.a",
|
mimalloc ++ "/out/{s}-{s}/lib/libmimalloc.a",
|
||||||
.{ @tagName(os), @tagName(arch) },
|
.{ @tagName(os), @tagName(arch) },
|
||||||
);
|
);
|
||||||
step.addObjectFile(b.path(lib_path));
|
mod.addObjectFile(b.path(lib_path));
|
||||||
step.addIncludePath(b.path(mimalloc ++ "/include"));
|
mod.addIncludePath(b.path(mimalloc ++ "/include"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// netsurf libs
|
// netsurf libs
|
||||||
@@ -423,7 +427,7 @@ fn moduleNetSurf(b: *Build, step: *Build.Step.Compile, target: std.Build.Resolve
|
|||||||
ns ++ "/out/{s}-{s}/include",
|
ns ++ "/out/{s}-{s}/include",
|
||||||
.{ @tagName(os), @tagName(arch) },
|
.{ @tagName(os), @tagName(arch) },
|
||||||
);
|
);
|
||||||
step.addIncludePath(b.path(ns_include_path));
|
mod.addIncludePath(b.path(ns_include_path));
|
||||||
|
|
||||||
const libs: [4][]const u8 = .{
|
const libs: [4][]const u8 = .{
|
||||||
"libdom",
|
"libdom",
|
||||||
@@ -437,8 +441,8 @@ fn moduleNetSurf(b: *Build, step: *Build.Step.Compile, target: std.Build.Resolve
|
|||||||
ns ++ "/out/{s}-{s}/lib/" ++ lib ++ ".a",
|
ns ++ "/out/{s}-{s}/lib/" ++ lib ++ ".a",
|
||||||
.{ @tagName(os), @tagName(arch) },
|
.{ @tagName(os), @tagName(arch) },
|
||||||
);
|
);
|
||||||
step.addObjectFile(b.path(ns_lib_path));
|
mod.addObjectFile(b.path(ns_lib_path));
|
||||||
step.addIncludePath(b.path(ns ++ "/" ++ lib ++ "/src"));
|
mod.addIncludePath(b.path(ns ++ "/" ++ lib ++ "/src"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
.fingerprint = 0xda130f3af836cea0,
|
.fingerprint = 0xda130f3af836cea0,
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.tigerbeetle_io = .{
|
.tigerbeetle_io = .{
|
||||||
.url = "https://github.com/lightpanda-io/tigerbeetle-io/archive/61d9652f1a957b7f4db723ea6aa0ce9635e840ce.tar.gz",
|
.url = "https://github.com/lightpanda-io/tigerbeetle-io/archive/19ae89eb3814d48c202ac9e0495fc5cadb29dfe7.tar.gz",
|
||||||
.hash = "tigerbeetle_io-0.0.0-ViLgxpyRBAB5BMfIcj3KMXfbJzwARs9uSl8aRy2OXULd",
|
.hash = "tigerbeetle_io-0.0.0-ViLgxjqSBADhuHO_RZm4yNzuoKDXWP39hDn60Kht40OC",
|
||||||
},
|
},
|
||||||
.v8 = .{
|
.v8 = .{
|
||||||
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/b22911e02e4884a76acf52aa9aff2ba169d05b40.tar.gz",
|
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/13f64a747c65a6b97ce08b89a2a1c9eb922e5495.tar.gz",
|
||||||
.hash = "v8-0.0.0-xddH69zCAwAzm1u5cQVa-uG5ib2y6PpENXCl8yEYdUYk",
|
.hash = "v8-0.0.0-xddH6-3DAwAi5Enn3IxrIUvsSa7vBBqxZBAHZzAAyKeq",
|
||||||
},
|
},
|
||||||
//.v8 = .{ .path = "../zig-v8-fork" },
|
//.v8 = .{ .path = "../zig-v8-fork" },
|
||||||
//.tigerbeetle_io = .{ .path = "../tigerbeetle-io" },
|
//.tigerbeetle_io = .{ .path = "../tigerbeetle-io" },
|
||||||
|
|||||||
Reference in New Issue
Block a user