From cd721cfc1fc82ac2c26086368ace8c874c74dc74 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 25 Aug 2017 15:11:37 +0200 Subject: [PATCH] Have generate-emscripten-symbols.sh automatically update the js/wasm build script --- dist-build/generate-emscripten-symbols.sh | 91 +++++++++++++---------- 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/dist-build/generate-emscripten-symbols.sh b/dist-build/generate-emscripten-symbols.sh index b81556d2..e7ddd666 100755 --- a/dist-build/generate-emscripten-symbols.sh +++ b/dist-build/generate-emscripten-symbols.sh @@ -1,43 +1,58 @@ #! /bin/sh -if [ "x$1" = "x--sumo" ]; then - SUMO=yes -fi +set -e -{ -while read symbol standard sumo; do - found="$standard" - if [ "x$SUMO" != "x" ]; then - found="$sumo" - fi - if [ "$found" = "1" ]; then - eval "defined_${symbol}=yes" - else - eval "defined_${symbol}=no" - fi -done < emscripten-symbols.def - -nm /usr/local/lib/libsodium.18.dylib | \ -fgrep ' T _' | \ -cut -d' ' -f3 | { - while read symbol; do - eval "found=\$defined_${symbol}" - if [ "$found" = "yes" ]; then - echo "$symbol" - elif [ "$found" != "no" ]; then - echo >&2 - echo "*** [$symbol] was not expected ***" >&2 - echo >&2 - exit 1 +symbols() { + { + SUMO="$1" + while read symbol standard sumo; do + found="$standard" + if [ "x$SUMO" != "sumo" ]; then + found="$sumo" fi - done - } -} | \ -sort | \ -{ -out='' -while read symbol ; do - out="${out},\"${symbol}\"" -done -echo $out + if [ "$found" = "1" ]; then + eval "defined_${symbol}=yes" + else + eval "defined_${symbol}=no" + fi + done < emscripten-symbols.def + + nm /usr/local/lib/libsodium.18.dylib | \ + fgrep ' T _' | \ + cut -d' ' -f3 | { + while read symbol; do + eval "found=\$defined_${symbol}" + if [ "$found" = "yes" ]; then + echo "$symbol" + elif [ "$found" != "no" ]; then + echo >&2 + echo "*** [$symbol] was not expected ***" >&2 + echo >&2 + exit 1 + fi + done + } + } | \ + sort | \ + { + while read symbol ; do + if [ ! -z "$out" ]; then + out="${out}," + fi + out="${out}\"${symbol}\"" + done + echo "[${out}]" + } } + +out=$(symbols standard) +sed s/EXPORTED_FUNCTIONS_STANDARD=\'.*\'/EXPORTED_FUNCTIONS_STANDARD=\'${out}\'/ < emscripten.sh > emscripten.sh.tmp && \ + mv -f emscripten.sh.tmp emscripten.sh +sed s/EXPORTED_FUNCTIONS_STANDARD=\'.*\'/EXPORTED_FUNCTIONS_STANDARD=\'${out}\'/ < emscripten-wasm.sh > emscripten-wasm.sh.tmp && \ + mv -f emscripten-wasm.sh.tmp emscripten-wasm.sh + +out=$(symbols sumo) +sed s/EXPORTED_FUNCTIONS_SUMO=\'.*\'/EXPORTED_FUNCTIONS_SUMO=\'${out}\'/ < emscripten.sh > emscripten.sh.tmp && \ + mv -f emscripten.sh.tmp emscripten.sh +sed s/EXPORTED_FUNCTIONS_SUMO=\'.*\'/EXPORTED_FUNCTIONS_SUMO=\'${out}\'/ < emscripten-wasm.sh > emscripten-wasm.sh.tmp && \ + mv -f emscripten-wasm.sh.tmp emscripten-wasm.sh