Skip to content

Commit b9e2be2

Browse files
build: support multi os/arch conf for netsurf
Signed-off-by: Francis Bouvier <[email protected]>
1 parent be5d702 commit b9e2be2

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,27 @@ test:
100100
.PHONY: install-dev install
101101

102102
## Install and build dependencies for release
103-
install: install-submodule install-zig-js-runtime install-netsurf install-mimalloc
103+
install: install-submodule install-zig-js-runtime install-libiconv install-netsurf install-mimalloc
104104

105105
## Install and build dependencies for dev
106-
install-dev: install-submodule install-zig-js-runtime-dev install-netsurf-dev install-mimalloc-dev
106+
install-dev: install-submodule install-zig-js-runtime-dev install-libiconv install-netsurf-dev install-mimalloc-dev
107107

108108
install-netsurf-dev: _install-netsurf
109109
install-netsurf-dev: OPTCFLAGS := -O0 -g -DNDEBUG
110110

111111
install-netsurf: _install-netsurf
112112
install-netsurf: OPTCFLAGS := -DNDEBUG
113113

114-
BC_NS := $(BC)vendor/netsurf
114+
BC_NS := $(BC)vendor/netsurf/out/$(OS)-$(ARCH)
115115
ICONV := $(BC)vendor/libiconv/out/$(OS)-$(ARCH)
116116
# TODO: add Linux iconv path (I guess it depends on the distro)
117117
# TODO: this way of linking libiconv is not ideal. We should have a more generic way
118118
# and stick to a specif version. Maybe build from source. Anyway not now.
119-
_install-netsurf: install-libiconv
119+
_install-netsurf: clean-netsurf
120120
@printf "\e[36mInstalling NetSurf...\e[0m\n" && \
121-
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;) && \
121+
ls $(ICONV)/lib/libiconv.a 1> /dev/null || (printf "\e[33mERROR: you need to execute 'make install-libiconv'\e[0m\n"; exit 1;) && \
122+
mkdir -p $(BC_NS) && \
123+
cp -R vendor/netsurf/share $(BC_NS) && \
122124
export PREFIX=$(BC_NS) && \
123125
export OPTLDFLAGS="-L$(ICONV)/lib" && \
124126
export OPTCFLAGS="$(OPTCFLAGS) -I$(ICONV)/include" && \
@@ -156,10 +158,7 @@ _install-netsurf: install-libiconv
156158

157159
clean-netsurf:
158160
@printf "\e[36mCleaning NetSurf build...\e[0m\n" && \
159-
cd vendor/netsurf && \
160-
rm -R build && \
161-
rm -R lib && \
162-
rm -R include
161+
rm -Rf $(BC_NS)
163162

164163
test-netsurf:
165164
@printf "\e[36mTesting NetSurf...\e[0m\n" && \
@@ -195,6 +194,7 @@ install-zig-js-runtime:
195194
make install
196195

197196
.PHONY: _build_mimalloc
197+
198198
MIMALLOC := $(BC)vendor/mimalloc/out/$(OS)-$(ARCH)
199199
_build_mimalloc: clean-mimalloc
200200
@mkdir -p $(MIMALLOC)/build && \

build.zig

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,12 @@ fn moduleNetSurf(b: *std.Build, target: std.Build.ResolvedTarget) !*std.Build.Mo
193193

194194
// netsurf libs
195195
const ns = "vendor/netsurf";
196-
mod.addIncludePath(b.path(ns ++ "/include"));
196+
const ns_include_path = try std.fmt.allocPrint(
197+
mod.owner.allocator,
198+
ns ++ "/out/{s}-{s}/include",
199+
.{ @tagName(os), @tagName(arch) },
200+
);
201+
mod.addIncludePath(b.path(ns_include_path));
197202

198203
const libs: [4][]const u8 = .{
199204
"libdom",
@@ -202,7 +207,12 @@ fn moduleNetSurf(b: *std.Build, target: std.Build.ResolvedTarget) !*std.Build.Mo
202207
"libwapcaplet",
203208
};
204209
inline for (libs) |lib| {
205-
mod.addObjectFile(b.path(ns ++ "/lib/" ++ lib ++ ".a"));
210+
const ns_lib_path = try std.fmt.allocPrint(
211+
mod.owner.allocator,
212+
ns ++ "/out/{s}-{s}/lib/" ++ lib ++ ".a",
213+
.{ @tagName(os), @tagName(arch) },
214+
);
215+
mod.addObjectFile(b.path(ns_lib_path));
206216
mod.addIncludePath(b.path(ns ++ "/" ++ lib ++ "/src"));
207217
}
208218

0 commit comments

Comments
 (0)