Skip to content

Lightpanda: the headless browser designed for AI and automation

make: create the zig global cache tmp dir before building

Adrià Arrufat825aef086c8a
diff --git a/Makefile b/Makefile
index a1466144c..0279a332d 100644
--- a/Makefile
+++ b/Makefile
@@ -77,7 +77,14 @@ help:
# $(ZIG) commands
# ------------
-.PHONY: build build-v8-snapshot build-dev download-v8 run run-release test bench data end2end clean
+.PHONY: build build-v8-snapshot build-dev download-v8 run run-release test bench data end2end clean zig-cache-tmp
+
+# Zig 0.16.0 doesn't create <global cache>/tmp before fetching .zip deps.
+# https://codeberg.org/ziglang/zig/issues/31964
+zig-cache-tmp:
+ @dir=$$($(ZIG) env | sed -n 's/^ *\.global_cache_dir = "\(.*\)",$$/\1/p'); \
+ test -n "$$dir" || { printf "\033[33mCould not read global_cache_dir from '$(ZIG) env'\033[0m\n"; exit 1; }; \
+ mkdir -p "$$dir/tmp"
## Download the prebuilt V8 libraries (skips the 10+ min source build)
download-v8:
@@ -98,7 +105,7 @@ ifeq ($(OS)_$(ARCH),linux_x86_64)
endif
## Build v8 snapshot
-build-v8-snapshot:
+build-v8-snapshot: zig-cache-tmp
@printf "\033[36mBuilding v8 snapshot (release safe)...\033[0m\n"
@$(ZIG) build $(ZIGFLAGS) -Doptimize=ReleaseFast snapshot_creator -- src/snapshot.bin || (printf "\033[33mBuild ERROR\033[0m\n"; exit 1;)
@printf "\033[33mBuild OK\033[0m\n"
@@ -110,7 +117,7 @@ build: build-v8-snapshot
@printf "\033[33mBuild OK\033[0m\n"
## Build in debug mode
-build-dev:
+build-dev: zig-cache-tmp
@printf "\033[36mBuilding (debug)...\033[0m\n"
@$(ZIG) build $(ZIGFLAGS) || (printf "\033[33mBuild ERROR\033[0m\n"; exit 1;)
@printf "\033[33mBuild OK\033[0m\n"
@@ -125,7 +132,7 @@ run-debug: build-dev
@printf "\033[36mRunning...\033[0m\n"
@./zig-out/bin/lightpanda || (printf "\033[33mRun ERROR\033[0m\n"; exit 1;)
-test:
+test: zig-cache-tmp
TEST_FILTER="$(or $(F),$(TEST_FILTER))" $(ZIG) build $(ZIGFLAGS) test -freference-trace
## Run demo/runner end to end tests