From fbc175692f75e59d07f71d1b67a4e0208316eb39 Mon Sep 17 00:00:00 2001 From: Bradley Walters Date: Wed, 7 Jan 2026 15:44:57 -0800 Subject: [PATCH] feat(cmake): log download failure from SetupWebKit.cmake (#25813) ### What does this PR do? Before this change, downloading WebKit would fail silently if there were e.g. a connection or TLS certificate issue. I experienced this when trying to build bun in an overly-restrictive sandbox. After this change, the failure reason will be visible. ### How did you verify your code works?
Brought down my network interface and ran the build: ```sh $ node ./scripts/build.mjs \ -GNinja \ -DCMAKE_BUILD_TYPE=Debug \ -B build/debug \ --log-level=NOTICE \ -DBUN_EXECUTABLE="$(which node)" \ -DNPM_EXECUTABLE="$(which npm)" \ -DZIG_EXECUTABLE="$(which zig)" \ -DENABLE_ASAN=OFF Globbed 1971 sources [180.67ms] CMake Configure $ cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -B /work/bun/build/debug --log-level NOTICE -DBUN_EXECUTABLE=/bin/node -DNPM_EXECUTABLE=/bin/npm -DZIG_EXECUTABLE=/bin/zig -DENABLE_ASAN=OFF -S /work/bun -DCACHE_STRATEGY=auto sccache: Using local cache strategy. ... ```
Result: ``` CMake Error at cmake/tools/SetupWebKit.cmake:99 (message): Failed to download WebKit: 6;"Could not resolve hostname" Call Stack (most recent call first): cmake/targets/BuildBun.cmake:1204 (include) CMakeLists.txt:66 (include) ``` --- cmake/tools/SetupWebKit.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/tools/SetupWebKit.cmake b/cmake/tools/SetupWebKit.cmake index 6e2ce7d677..545f82dd68 100644 --- a/cmake/tools/SetupWebKit.cmake +++ b/cmake/tools/SetupWebKit.cmake @@ -90,7 +90,14 @@ if(EXISTS ${WEBKIT_PATH}/package.json) endif() endif() -file(DOWNLOAD ${WEBKIT_DOWNLOAD_URL} ${CACHE_PATH}/${WEBKIT_FILENAME} SHOW_PROGRESS) +file( + DOWNLOAD ${WEBKIT_DOWNLOAD_URL} ${CACHE_PATH}/${WEBKIT_FILENAME} SHOW_PROGRESS + STATUS WEBKIT_DOWNLOAD_STATUS +) +if(NOT "${WEBKIT_DOWNLOAD_STATUS}" MATCHES "^0;") + message(FATAL_ERROR "Failed to download WebKit: ${WEBKIT_DOWNLOAD_STATUS}") +endif() + file(ARCHIVE_EXTRACT INPUT ${CACHE_PATH}/${WEBKIT_FILENAME} DESTINATION ${CACHE_PATH} TOUCH) file(REMOVE ${CACHE_PATH}/${WEBKIT_FILENAME}) file(REMOVE_RECURSE ${WEBKIT_PATH})