From daa8fff5f398d9ec5455191dc034c5405b654dca Mon Sep 17 00:00:00 2001 From: Navid EMAD Date: Thu, 21 May 2026 14:39:25 +0200 Subject: [PATCH] Add ZIGFLAGS= make download-v8 to fetch prebuilt V8 and skip the source build --- .gitignore | 1 + Makefile | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 48403d38..c23d7cc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.zig-cache/ /.lp-cache/ +/v8/ /zig-pkg/ zig-out lightpanda.id diff --git a/Makefile b/Makefile index 9daa2c75..4f30d2fd 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,27 @@ else endif +# Prebuilt V8 +# ----------- +# Building V8 from source takes 10+ minutes. `make download-v8` fetches the +# matching prebuilt archive from the zig-v8-fork releases instead. The versions +# are read from the install action so they can't drift from CI. +V8_ACTION := .github/actions/install/action.yml +V8_VERSION := $(shell awk -F\' '/^ v8:/{f=1} f&&/default:/{print $$2; exit}' $(V8_ACTION)) +ZIG_V8_TAG := $(shell awk -F\' '/^ zig-v8:/{f=1} f&&/default:/{print $$2; exit}' $(V8_ACTION)) +V8_ARCHIVE := libc_v8_$(V8_VERSION)_$(OS)_$(ARCH).a +V8_CACHE := .lp-cache/prebuilt-v8/$(V8_ARCHIVE) +V8_LINK := v8/libc_v8.a + +# If the prebuilt archive is in place and the caller hasn't set ZIGFLAGS, link +# against it (the same flag CI passes) rather than building V8 from source. +ifeq ($(strip $(ZIGFLAGS)),) + ifneq ($(wildcard $(V8_LINK)),) + ZIGFLAGS := -Dprebuilt_v8_path=$(V8_LINK) + endif +endif + + # Infos # ----- .PHONY: help @@ -52,7 +73,18 @@ help: # $(ZIG) commands # ------------ -.PHONY: build build-v8-snapshot build-dev 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 + +## Download the prebuilt V8 archive (skips the 10+ min source build) +download-v8: + @mkdir -p $(dir $(V8_CACHE)) $(dir $(V8_LINK)) + @test -f $(V8_CACHE) || ( \ + printf "\033[36mDownloading prebuilt V8 $(V8_VERSION) ($(ZIG_V8_TAG))...\033[0m\n"; \ + curl -fL --progress-bar -o $(V8_CACHE) \ + https://github.com/lightpanda-io/zig-v8-fork/releases/download/$(ZIG_V8_TAG)/$(V8_ARCHIVE) \ + || (rm -f $(V8_CACHE); printf "\033[33mDownload ERROR\033[0m\n"; exit 1) ) + @ln -sf $(abspath $(V8_CACHE)) $(V8_LINK) + @printf "\033[33mV8 ready: %s -> %s\033[0m\n" "$(V8_LINK)" "$(V8_CACHE)" ## Build v8 snapshot build-v8-snapshot: