generate-emscripten-symbols.sh (1393B)
1 #! /bin/sh 2 3 set -e 4 5 LIBSODIUM=${LIBSODIUM:-/tmp/sodium/lib/libsodium.26.dylib} 6 7 symbols() { 8 { 9 SUMO="$1" 10 while read symbol standard sumo; do 11 found="$standard" 12 if [ "x$SUMO" = "xsumo" ]; then 13 found="$sumo" 14 fi 15 if [ "$found" = "1" ]; then 16 eval "defined_${symbol}=yes" 17 else 18 eval "defined_${symbol}=no" 19 fi 20 done <emscripten-symbols.def 21 22 /usr/bin/nm "$LIBSODIUM" | 23 fgrep ' T _' | 24 cut -d' ' -f3 | { 25 while read symbol; do 26 eval "found=\$defined_${symbol}" 27 if [ "$found" = "yes" ]; then 28 echo "$symbol" 29 elif [ "$found" != "no" ]; then 30 echo >&2 31 echo "*** [$symbol] was not expected ***" >&2 32 echo >&2 33 exit 1 34 fi 35 done 36 } 37 } | 38 sort | 39 { 40 out='"_malloc","_free"' 41 while read symbol; do 42 if [ ! -z "$out" ]; then 43 out="${out}," 44 fi 45 out="${out}\"${symbol}\"" 46 done 47 echo "[${out}]" 48 } 49 } 50 51 out=$(symbols standard) 52 sed s/EXPORTED_FUNCTIONS_STANDARD=\'.*\'/EXPORTED_FUNCTIONS_STANDARD=\'${out}\'/ <emscripten.sh >emscripten.sh.tmp && 53 mv -f emscripten.sh.tmp emscripten.sh 54 55 out=$(symbols sumo) 56 sed s/EXPORTED_FUNCTIONS_SUMO=\'.*\'/EXPORTED_FUNCTIONS_SUMO=\'${out}\'/ <emscripten.sh >emscripten.sh.tmp && 57 mv -f emscripten.sh.tmp emscripten.sh 58 59 chmod +x emscripten.sh