build: link netsurf

Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
Francis Bouvier
2023-09-07 16:51:29 +02:00
parent 97348cef5c
commit d6027b238b
2 changed files with 30 additions and 1 deletions

View File

@@ -75,7 +75,6 @@ endif
install-netsurf:
@printf "\e[36mInstalling NetSurf...\e[0m\n" && \
ls $(ICONV) 1> /dev/null || (printf "\e[33mERROR: you need to install libiconv in your system (on MacOS on with Homebrew)\e[0m\n"; exit 1;) && \
mkdir -p vendor/netfurf/build && \
export PREFIX=$(BC_NS) && \
export LDFLAGS="-L$(ICONV)/lib" && \
export CFLAGS="-I/$(ICONV)/include -I$(BC_NS)/libparserutils/include -I$(BC_NS)/libhubbub/include -I$(BC_NS)/libwapcaplet/include" && \

View File

@@ -78,6 +78,7 @@ fn common(
) !void {
try jsruntime_pkgs.add(step, options);
linkLexbor(step);
linkNetSurf(step);
}
fn linkLexbor(step: *std.build.LibExeObjStep) void {
@@ -86,3 +87,32 @@ fn linkLexbor(step: *std.build.LibExeObjStep) void {
step.addObjectFile(.{ .path = lib_path });
step.addIncludePath(.{ .path = "vendor/lexbor-src/source" });
}
fn linkNetSurf(step: *std.build.LibExeObjStep) void {
// iconv
var iconv_lib: []const u8 = undefined;
var iconv_include: []const u8 = undefined;
const os = step.target.getOsTag();
if (os == .macos) {
iconv_lib = "/opt/homebrew/opt/libiconv/lib/libiconv.a";
iconv_include = "/opt/homebrew/opt/libiconv/include";
} else if (os == .linux) {
@panic("you need to modify build.zig to specify libiconv paths");
}
step.addObjectFile(iconv_lib);
step.addIncludePath(iconv_include);
// netsurf libs
const ns = "vendor/netsurf/";
const libs: [4][]const u8 = .{
"libdom",
"libhubbub",
"libparserutils",
"libwapcaplet",
};
inline for (libs) |lib| {
step.addObjectFile(ns ++ "/build/" ++ lib ++ "/" ++ lib ++ ".a");
step.addIncludePath(ns ++ lib ++ "/include");
}
}