Skip to content
This repository was archived by the owner on Sep 8, 2026. It is now read-only.

Commit 831321d

Browse files
committed
Make build_js.sh non-interactive by switching to public emsdk bootstrap and removing submodule auth dependency
1 parent 661e5b8 commit 831321d

1 file changed

Lines changed: 37 additions & 17 deletions

File tree

‎build_js.sh‎

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,48 @@
55
#
66
# Please see the included LICENSE file for more information.
77

8+
set -euo pipefail
89

9-
# Set up emscripten
10+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11+
EMSDK_DIR="${ROOT_DIR}/emsdk"
12+
EMSDK_GIT_URL="https://github.com/emscripten-core/emsdk.git"
1013

11-
if [[ -z "${EMSDK}" ]]; then
12-
echo "Installing emscripten..."
13-
echo ""
14-
if [[ ! -e ./emsdk/emsdk ]]; then
15-
git submodule init
16-
git submodule update
14+
# Set up emscripten in a non-interactive way.
15+
# This avoids prompts such as:
16+
# "Username for 'https://github.com':"
17+
if ! command -v emconfigure >/dev/null 2>&1; then
18+
if [[ -z "${EMSDK:-}" ]]; then
19+
echo "Installing emscripten..."
20+
echo ""
21+
22+
if [[ ! -x "${EMSDK_DIR}/emsdk" ]]; then
23+
GIT_TERMINAL_PROMPT=0 git clone --depth 1 "${EMSDK_GIT_URL}" "${EMSDK_DIR}"
24+
fi
25+
26+
pushd "${EMSDK_DIR}" >/dev/null
27+
./emsdk install latest
28+
./emsdk activate latest
29+
# shellcheck disable=SC1091
30+
source "${EMSDK_DIR}/emsdk_env.sh"
31+
popd >/dev/null
32+
else
33+
# shellcheck disable=SC1091
34+
source "${EMSDK}/emsdk_env.sh"
1735
fi
18-
cd emsdk && git pull
19-
./emsdk install latest && ./emsdk activate latest
20-
source ./emsdk_env.sh
21-
cd ..
2236
fi
2337

24-
# This applies a patch to fastcomp to make sure that the
25-
# environment is set correctly for react environments
26-
patch -N --verbose emsdk/fastcomp/emscripten/src/shell.js scripts/emscripten.patch
38+
# This patch only applies to old fastcomp layouts.
39+
if [[ -f "${EMSDK_DIR}/fastcomp/emscripten/src/shell.js" ]]; then
40+
patch -N --verbose "${EMSDK_DIR}/fastcomp/emscripten/src/shell.js" "${ROOT_DIR}/scripts/emscripten.patch" || true
41+
fi
42+
43+
mkdir -p "${ROOT_DIR}/dist"
44+
mkdir -p "${ROOT_DIR}/jsbuild"
45+
cd "${ROOT_DIR}/jsbuild"
46+
rm -rf *
2747

28-
mkdir -p jsbuild && cd jsbuild && rm -rf *
2948
emconfigure cmake .. -DNO_AES=1 -DARCH=default -DBUILD_WASM=1 -DBUILD_JS=0
30-
make && cp wrkzcoin-crypto-wasm.js ../dist
49+
make && cp wrkzcoin-crypto-wasm.js "${ROOT_DIR}/dist"
50+
3151
emconfigure cmake .. -DNO_AES=1 -DARCH=default -DBUILD_WASM=0 -DBUILD_JS=1
32-
make && cp wrkzcoin-crypto.js ../dist
52+
make && cp wrkzcoin-crypto.js "${ROOT_DIR}/dist"

0 commit comments

Comments
 (0)