transparent-cube

Minimal cross-platform native/wasm graphics example.
git clone git://git.amin.space/transparent-cube.git
Log | Files | Refs | README | LICENSE

build_wasm.sh (1520B)


      1 #!/usr/bin/env bash
      2 
      3 set -e                     # fail if any command has a non-zero exit status
      4 set -u                     # fail if any undefined variable is referenced
      5 set -o pipefail            # propagate failure exit status through a pipeline
      6 shopt -s globstar nullglob # enable recursive and null globbing
      7 
      8 out_dir="./out"
      9 wasm_dir="${out_dir}/wasm"
     10 
     11 mkdir -p $wasm_dir
     12 cp src/platform_wasm_loader.js $wasm_dir/script.js
     13 cp src/platform_wasm_index.html $wasm_dir/index.html
     14 cp -r shader/ $wasm_dir
     15 
     16 clang                                                           \
     17     --no-standard-libraries                                     \
     18     --target=wasm32                                             \
     19     -DGAME_WEBGL                                                \
     20     -O3                                                         \
     21     -Wall                                                       \
     22     -Wno-unused-function                                        \
     23     -std=c11                                                    \
     24     -Wl,--allow-undefined-file=src/platform_wasm_js_symbols.txt \
     25     -Wl,--export=init                                           \
     26     -Wl,--export=render                                         \
     27     -Wl,--export=window_resize                                  \
     28     -Wl,--import-memory                                         \
     29     -Wl,--no-entry                                              \
     30     -o $wasm_dir/binary.wasm                                    \
     31     src/platform_wasm.c