Files
workinf_Blender_Wasm/tools/web/emscripten-env.sh
mes123456 6090995999
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
perf(web): reuse incremental build and status caches
2026-09-06 10:27:26 +08:00

55 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
WEB_EMSCRIPTEN_VERSION="3.1.69"
web_workspace_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
# Prefer the repository-local SDK prepared by tools/web/prepare-build-env.sh.
if [[ -x "${web_workspace_root}/.emsdk/upstream/emscripten/emcc" ]]; then
export EMSDK="${web_workspace_root}/.emsdk"
export PATH="${EMSDK}/upstream/emscripten:${EMSDK}/node/24.19.0_64bit/bin:${EMSDK}:${PATH}"
# Override copied-host settings in .emscripten-web with this checkout's SDK.
export EM_LLVM_ROOT="${EM_LLVM_ROOT-${EMSDK}/upstream/bin}"
export EM_BINARYEN_ROOT="${EM_BINARYEN_ROOT-${EMSDK}/upstream}"
export EM_NODE_JS="${EM_NODE_JS-${EMSDK}/node/24.19.0_64bit/bin/node}"
export EM_LLVM_ADD_VERSION="${EM_LLVM_ADD_VERSION-}"
export EM_CLANG_ADD_VERSION="${EM_CLANG_ADD_VERSION-}"
fi
if command -v emcc >/dev/null 2>&1; then
detected_version="$(emcc --version | awk '{for (i = 1; i <= NF; i++) if ($i ~ /^[0-9]+\.[0-9]+\.[0-9]+$/) {print $i; exit}}')"
if [[ "${detected_version}" != "${WEB_EMSCRIPTEN_VERSION}" ]]; then
echo "Expected Emscripten ${WEB_EMSCRIPTEN_VERSION}, found ${detected_version}" >&2
exit 1
fi
else
echo "emcc was not found; install or activate emsdk ${WEB_EMSCRIPTEN_VERSION}" >&2
exit 1
fi
export WEB_EMSCRIPTEN_VERSION
export EM_CONFIG="${web_workspace_root}/.emscripten-web"
# Prefer RAM-backed compiler caches on Linux hosts with enough tmpfs space.
# The cache only contains derived Emscripten artifacts; evidence and source
# outputs remain in the repository. Callers can override either path.
if [[ -d /dev/shm && -w /dev/shm ]]; then
web_ram_cache_root="${WEB_RAM_CACHE_ROOT-/dev/shm/blender-wasm-${UID}}"
mkdir -p "${web_ram_cache_root}/emcache" "${web_ram_cache_root}/tmp"
export EM_CACHE="${EM_CACHE-${web_ram_cache_root}/emcache}"
export TMPDIR="${TMPDIR-${web_ram_cache_root}/tmp}"
else
export EM_CACHE="${EM_CACHE-${web_workspace_root}/.emcache}"
fi
web_build_jobs="$(WEB_BUILD_MEMORY_GIB_PER_JOB=4 WEB_BUILD_JOBS_CAP=16 bash "${web_workspace_root}/tools/web/compute-build-jobs.sh")"
export WEB_BUILD_JOBS="${WEB_BUILD_JOBS-${web_build_jobs}}"
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL-${WEB_BUILD_JOBS}}"
export NINJAFLAGS="${NINJAFLAGS--j${WEB_BUILD_JOBS}}"
export WEB_EMSCRIPTEN_CFLAGS="-sENVIRONMENT=web,worker -sMODULARIZE=1 -sEXPORT_ES6=1"
export WEB_EMSCRIPTEN_LDFLAGS="-sALLOW_MEMORY_GROWTH=1 -sFILESYSTEM=1"
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
emcc --version | head -3
node --version
cmake --version | head -1
fi