mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
build: support multi os/arch conf for mimalloc
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
26
build.zig
26
build.zig
@@ -146,15 +146,16 @@ fn common(
|
||||
step: *std.Build.Step.Compile,
|
||||
options: jsruntime.Options,
|
||||
) !void {
|
||||
const target = step.root_module.resolved_target.?;
|
||||
const jsruntimemod = try jsruntime_pkgs.module(
|
||||
b,
|
||||
options,
|
||||
step.root_module.optimize.?,
|
||||
step.root_module.resolved_target.?,
|
||||
target,
|
||||
);
|
||||
step.root_module.addImport("jsruntime", jsruntimemod);
|
||||
|
||||
const netsurf = moduleNetSurf(b);
|
||||
const netsurf = try moduleNetSurf(b, target);
|
||||
netsurf.addImport("jsruntime", jsruntimemod);
|
||||
step.root_module.addImport("netsurf", netsurf);
|
||||
|
||||
@@ -164,16 +165,17 @@ fn common(
|
||||
step.root_module.addImport("tls", tlsmod);
|
||||
}
|
||||
|
||||
fn moduleNetSurf(b: *std.Build) *std.Build.Module {
|
||||
fn moduleNetSurf(b: *std.Build, target: std.Build.ResolvedTarget) !*std.Build.Module {
|
||||
const mod = b.addModule("netsurf", .{
|
||||
.root_source_file = b.path("src/netsurf/netsurf.zig"),
|
||||
.target = target,
|
||||
});
|
||||
// iconv
|
||||
mod.addObjectFile(b.path("vendor/libiconv/lib/libiconv.a"));
|
||||
mod.addIncludePath(b.path("vendor/libiconv/include"));
|
||||
|
||||
// mimalloc
|
||||
mod.addImport("mimalloc", moduleMimalloc(b));
|
||||
mod.addImport("mimalloc", (try moduleMimalloc(b, target)));
|
||||
|
||||
// netsurf libs
|
||||
const ns = "vendor/netsurf";
|
||||
@@ -193,13 +195,23 @@ fn moduleNetSurf(b: *std.Build) *std.Build.Module {
|
||||
return mod;
|
||||
}
|
||||
|
||||
fn moduleMimalloc(b: *std.Build) *std.Build.Module {
|
||||
fn moduleMimalloc(b: *std.Build, target: std.Build.ResolvedTarget) !*std.Build.Module {
|
||||
const mod = b.addModule("mimalloc", .{
|
||||
.root_source_file = b.path("src/mimalloc/mimalloc.zig"),
|
||||
.target = target,
|
||||
});
|
||||
|
||||
mod.addObjectFile(b.path("vendor/mimalloc/out/libmimalloc.a"));
|
||||
mod.addIncludePath(b.path("vendor/mimalloc/out/include"));
|
||||
const os = target.result.os.tag;
|
||||
const arch = target.result.cpu.arch;
|
||||
|
||||
const mimalloc = "vendor/mimalloc";
|
||||
const lib_path = try std.fmt.allocPrint(
|
||||
mod.owner.allocator,
|
||||
mimalloc ++ "/out/{s}-{s}/lib/libmimalloc.a",
|
||||
.{ @tagName(os), @tagName(arch) },
|
||||
);
|
||||
mod.addObjectFile(b.path(lib_path));
|
||||
mod.addIncludePath(b.path(mimalloc ++ "/include"));
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user