#!/usr/bin/env bash # Build dgbpow.wasm from DigiByte Core's hash sources with emscripten in # docker (no local toolchain needed). Output: packages/p2p/native/dgbpow.wasm # which the daemon loads at startup (src/pow.ts). # # bash packages/p2p/native/build.sh set -euo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" IMG="${EMSDK_IMAGE:-emscripten/emsdk:3.1.61}" # Git Bash on Windows mangles "/src" style args; MSYS_NO_PATHCONV keeps # the container paths intact. MSYS_NO_PATHCONV=1 docker run --rm -v "$here":/work -w /work "$IMG" bash -c ' set -e emcc -O3 -DNDEBUG -fno-exceptions -fno-rtti \ -s STANDALONE_WASM=1 -s PURE_WASI=0 --no-entry \ -s EXPORTED_FUNCTIONS=_in_ptr,_out_ptr,_hash_qubit,_hash_skein512,_hash_groestl512,_hash_odo,_gcs_scripts_ptr,_gcs_offsets_ptr,_gcs_key_ptr,_gcs_filter_ptr,_gcs_matches_ptr,_gcs_limits_ptr,_gcs_set_count,_gcs_match \ -s INITIAL_MEMORY=33554432 -s ALLOW_MEMORY_GROWTH=0 -s STACK_SIZE=262144 \ -Isrc \ dgbpow.c gcs.c odo_glue.cpp \ src/luffa.cpp src/cubehash.cpp src/shavite.cpp src/simd.cpp src/echo.cpp \ src/skein.cpp src/groestl.cpp src/odocrypt.cpp src/KeccakP-800-reference.cpp \ -o dgbpow.wasm ls -la dgbpow.wasm ' echo "built: $here/dgbpow.wasm"