Build emscripten caches in sandbox

This makes it so that we actually build the various standard
library-like things built within the sandbox rather than being some
random files that I generate ad-hoc and copy into the correct folder.

This requires patching emcc so that it adds the necessary -isystem flags
when building those libraries.

Change-Id: I7b71b36cbbafd511df5d7a8396794aeee2403a05
diff --git a/tools/cpp/emscripten/gencache.sh b/tools/cpp/emscripten/gencache.sh
new file mode 100755
index 0000000..d8391d8
--- /dev/null
+++ b/tools/cpp/emscripten/gencache.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+# This script forces generation of all the necessary cache files from emscripten.
+export EMCC_FORCE_STDLIBS=1
+# Run with WEBGL2 enabled and not, as the compiler will only generate one of the
+# webgl libraries at once.
+tools/cpp/emscripten/emcc.sh -o foo.html.tar tools/cpp/emscripten/foo.o -s 'USE_WEBGL2=1' -no-canonical-prefixes
+tools/cpp/emscripten/emcc.sh -o foo.html.tar tools/cpp/emscripten/foo.o -s 'USE_WEBGL2=0' -no-canonical-prefixes
+for OUTPUT in $@
+do
+  if [ ! -f ${OUTPUT} ]; then
+    cp -f tmp/emscripten_cache/asmjs/$(basename ${OUTPUT}) ${OUTPUT}
+  fi
+done