emcc.sh.in 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. # ^^^^^^^ Please try to keep this script Bourne-compatible.
  3. ########################################################################
  4. # WARNING: emcc.sh is generated from emcc.sh.in by the configure
  5. # process. Do not edit emcc.sh directly, as it may be deleted or
  6. # overwritten by the configure script.
  7. #
  8. # A wrapper around the emcc compiler which uses configure-time state
  9. # to locate the Emscripten SDK and import the SDK's environment
  10. # script, if needed.
  11. ########################################################################
  12. # EMSDK_HOME comes from the configure --with-emsdk=/dir flag.
  13. # EMSDK_ENV_SH is ${thatDir}/emsdk_env.sh and is also set by the
  14. # configure process.
  15. EMSDK_HOME="@EMSDK_HOME@"
  16. EMSDK_ENV_SH="@EMSDK_ENV_SH@"
  17. emcc="@BIN_EMCC@"
  18. if [ x = "x${emcc}" ]; then
  19. emcc=`which emcc 2>/dev/null`
  20. fi
  21. if [ x = "x${emcc}" ]; then
  22. # If emcc is not found in the path, try to find it via an emsdk
  23. # installation. The SDK variant is the official installation style
  24. # supported by the Emscripten project, but emcc is also available
  25. # via package managers on some OSes.
  26. if [ x = "x${EMSDK_HOME}" ]; then
  27. echo "EMSDK_HOME is not set. Pass --with-emsdk=/path/to/emsdk" \
  28. "to the configure script." 1>&2
  29. exit 1
  30. fi
  31. if [ x = "x${EMSDK_ENV_SH}" ]; then
  32. if [ -f "${EMSDK_HOME}/emsdk_env.sh" ]; then
  33. EMSDK_ENV_SH="${EMSDK_HOME}/emsdk_env.sh"
  34. else
  35. echo "EMSDK_ENV_SH is not set. Expecting configure script to set it." 1>&2
  36. exit 2
  37. fi
  38. fi
  39. if [ ! -f "${EMSDK_ENV_SH}" ]; then
  40. echo "emsdk_env script not found: $EMSDK_ENV_SH" 1>&2
  41. exit 3
  42. fi
  43. # $EMSDK is part of the state set by emsdk_env.sh.
  44. if [ x = "x${EMSDK}" ]; then
  45. EMSDK_QUIET=1
  46. export EMSDK_QUIET
  47. # ^^^ Squelches informational output from ${EMSDK_ENV_SH}.
  48. source "${EMSDK_ENV_SH}" || {
  49. rc=$?
  50. echo "Error sourcing ${EMSDK_ENV_SH}"
  51. exit $rc
  52. }
  53. fi
  54. emcc=`which emcc 2>/dev/null`
  55. if [ x = "x${emcc}" ]; then
  56. echo "emcc not found in PATH. Normally that's set up by ${EMSDK_ENV_SH}." 1>&2
  57. exit 4
  58. fi
  59. fi
  60. exec emcc "$@"