Fossil SCM
Bring the configure/build Emscripten support in sync with its counterpart in the sqlite tree.
Commit
a3843d419d3c101f16258b4d1c0e2ce22b951be25c165d302c5d13eaff52b665
Parent
f020f4568157c59…
2 files changed
+74
-29
+23
-17
M
auto.def
+74
-29
| --- auto.def | ||
| +++ auto.def | ||
| @@ -706,37 +706,10 @@ | ||
| 706 | 706 | $tclconfig(TCL_LD_FLAGS)] |
| 707 | 707 | define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS) |
| 708 | 708 | define FOSSIL_ENABLE_TCL |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | -# Emscripten is a purely optional component used only for doing | |
| 712 | -# in-tree builds of WASM stuff, as opposed to WASM binaries we import | |
| 713 | -# from other places. This is only set up for Unix-style OSes and is | |
| 714 | -# untested anywhere but Linux. | |
| 715 | -set emsdkHome [opt-val with-emsdk] | |
| 716 | -define EMSDK_HOME "" | |
| 717 | -define EMSDK_ENV "" | |
| 718 | -define EMCC_OPT "-Oz" | |
| 719 | -if {$emsdkHome eq "" && [info exists ::env(EMSDK)]} { | |
| 720 | - # Fall back to checking the environment. $EMSDK gets set | |
| 721 | - # by sourcing emsdk_env.sh. | |
| 722 | - set emsdkHome $::env(EMSDK) | |
| 723 | -} | |
| 724 | -if {$emsdkHome ne ""} { | |
| 725 | - define EMSDK_HOME $emsdkHome | |
| 726 | - set emsdkEnv "$emsdkHome/emsdk_env.sh" | |
| 727 | - if {[file exists $emsdkEnv]} { | |
| 728 | - puts "Using Emscripten SDK environment from $emsdkEnv." | |
| 729 | - define EMSDK_ENV $emsdkEnv | |
| 730 | - if {[info exists ::env(EMCC_OPT)]} { | |
| 731 | - define EMCC_OPT $::env(EMCC_OPT) | |
| 732 | - } | |
| 733 | - } else { | |
| 734 | - puts "emsdk_env.sh not found. Assuming emcc is in the PATH." | |
| 735 | - } | |
| 736 | -} | |
| 737 | - | |
| 738 | 711 | # Network functions require libraries on some systems |
| 739 | 712 | cc-check-function-in-lib gethostbyname nsl |
| 740 | 713 | if {![cc-check-function-in-lib socket {socket network}]} { |
| 741 | 714 | # Last resort, may be Windows |
| 742 | 715 | if {[is_mingw]} { |
| @@ -767,11 +740,11 @@ | ||
| 767 | 740 | cc-check-functions strchrnul |
| 768 | 741 | cc-check-functions pledge |
| 769 | 742 | cc-check-functions backtrace |
| 770 | 743 | |
| 771 | 744 | # Termux on Android adds "getpass(char *)" to unistd.h, so check this so we |
| 772 | -# guard against including it again; use cctest as cc-check-functions and | |
| 745 | +# guard against including it again; use cctest as cc-check-functions and | |
| 773 | 746 | # cctest_function check for "getpass()" with no args and fail |
| 774 | 747 | if {[cctest -link 1 -includes {unistd.h} -code "getpass(0);"]} { |
| 775 | 748 | define FOSSIL_HAVE_GETPASS 1 |
| 776 | 749 | msg-result "Found getpass() with unistd.h" |
| 777 | 750 | } |
| @@ -859,16 +832,88 @@ | ||
| 859 | 832 | # Linux can only infer the dependency on pthread from OpenSSL when |
| 860 | 833 | # doing dynamic linkage. |
| 861 | 834 | define-append LIBS -lpthread |
| 862 | 835 | } |
| 863 | 836 | |
| 864 | -if {[get-define EMSDK_HOME] ne ""} { | |
| 837 | + | |
| 838 | +######################################################################## | |
| 839 | +# @proj-check-emsdk | |
| 840 | +# | |
| 841 | +# Emscripten is used for doing in-tree builds of web-based WASM stuff, | |
| 842 | +# as opposed to WASI-based WASM or WASM binaries we import from other | |
| 843 | +# places. This is only set up for Unix-style OSes and is untested | |
| 844 | +# anywhere but Linux. Requires that the --with-emsdk flag be | |
| 845 | +# registered with autosetup. | |
| 846 | +# | |
| 847 | +# It looks for the SDK in the location specified by --with-emsdk. | |
| 848 | +# Values of "" or "auto" mean to check for the environment var EMSDK | |
| 849 | +# (which gets set by the emsdk_env.sh script from the SDK) or that | |
| 850 | +# same var passed to configure. | |
| 851 | +# | |
| 852 | +# If the given directory is found, it expects to find emsdk_env.sh in | |
| 853 | +# that directory, as well as the emcc compiler somewhere under there. | |
| 854 | +# | |
| 855 | +# If the --with-emsdk flag is explicitly provided and the SDK is not | |
| 856 | +# found then a fatal error is generated, otherwise failure to find the | |
| 857 | +# SDK is not fatal. | |
| 858 | +# | |
| 859 | +# Defines the following: | |
| 860 | +# | |
| 861 | +# - EMSDK_HOME = top dir of the emsdk or "". | |
| 862 | +# - EMSDK_ENV_SH = path to EMSDK_HOME/emsdk_env.sh or "" | |
| 863 | +# - BIN_EMCC = $EMSDK_HOME/upstream/emscripten/emcc or "" | |
| 864 | +# - HAVE_EMSDK = 0 or 1 (this function's return value) | |
| 865 | +# | |
| 866 | +# Returns 1 if EMSDK_ENV_SH is found, else 0. If EMSDK_HOME is not empty | |
| 867 | +# but BIN_EMCC is then emcc was not found in the EMSDK_HOME, in which | |
| 868 | +# case we have to rely on the fact that sourcing $EMSDK_ENV_SH from a | |
| 869 | +# shell will add emcc to the $PATH. | |
| 870 | +proc proj-check-emsdk {} { | |
| 871 | + set emsdkHome [opt-val with-emsdk] | |
| 872 | + define EMSDK_HOME "" | |
| 873 | + define EMSDK_ENV_SH "" | |
| 874 | + define BIN_EMCC "" | |
| 875 | + set hadValue [llength $emsdkHome] | |
| 876 | + msg-checking "Emscripten SDK? " | |
| 877 | + if {$emsdkHome in {"" "auto"}} { | |
| 878 | + # Check the environment. $EMSDK gets set by sourcing emsdk_env.sh. | |
| 879 | + set emsdkHome [get-env EMSDK ""] | |
| 880 | + } | |
| 881 | + set rc 0 | |
| 882 | + if {$emsdkHome ne ""} { | |
| 883 | + define EMSDK_HOME $emsdkHome | |
| 884 | + set emsdkEnv "$emsdkHome/emsdk_env.sh" | |
| 885 | + if {[file exists $emsdkEnv]} { | |
| 886 | + msg-result "$emsdkHome" | |
| 887 | + define EMSDK_ENV_SH $emsdkEnv | |
| 888 | + set rc 1 | |
| 889 | + set emcc "$emsdkHome/upstream/emscripten/emcc" | |
| 890 | + if {[file exists $emcc]} { | |
| 891 | + define BIN_EMCC $emcc | |
| 892 | + } | |
| 893 | + } else { | |
| 894 | + msg-result "emsdk_env.sh not found in $emsdkHome" | |
| 895 | + } | |
| 896 | + } else { | |
| 897 | + msg-result "not found" | |
| 898 | + } | |
| 899 | + if {$hadValue && 0 == $rc} { | |
| 900 | + # Fail if it was explicitly requested but not found | |
| 901 | + proj-fatal "Cannot find the Emscripten SDK" | |
| 902 | + } | |
| 903 | + define HAVE_EMSDK $rc | |
| 904 | + return $rc | |
| 905 | +} | |
| 906 | + | |
| 907 | +if {[proj-check-emsdk]} { | |
| 865 | 908 | define EMCC_WRAPPER $::autosetup(dir)/../tools/emcc.sh |
| 909 | + define EMCC_OPT [get-env EMCC_OPT "-Oz"]; # optional flags to pass to emcc | |
| 866 | 910 | make-template tools/emcc.sh.in |
| 867 | 911 | catch {exec chmod u+x tools/emcc.sh} |
| 868 | 912 | } else { |
| 869 | 913 | define EMCC_WRAPPER "" |
| 914 | + define EMCC_OPT "" | |
| 870 | 915 | catch {exec rm -f tools/emcc.sh} |
| 871 | 916 | } |
| 872 | 917 | |
| 873 | 918 | # Tag container builds with a prefix of the checkin ID of the version |
| 874 | 919 | # of Fossil each one contains. This not only allows multiple images |
| 875 | 920 |
| --- auto.def | |
| +++ auto.def | |
| @@ -706,37 +706,10 @@ | |
| 706 | $tclconfig(TCL_LD_FLAGS)] |
| 707 | define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS) |
| 708 | define FOSSIL_ENABLE_TCL |
| 709 | } |
| 710 | |
| 711 | # Emscripten is a purely optional component used only for doing |
| 712 | # in-tree builds of WASM stuff, as opposed to WASM binaries we import |
| 713 | # from other places. This is only set up for Unix-style OSes and is |
| 714 | # untested anywhere but Linux. |
| 715 | set emsdkHome [opt-val with-emsdk] |
| 716 | define EMSDK_HOME "" |
| 717 | define EMSDK_ENV "" |
| 718 | define EMCC_OPT "-Oz" |
| 719 | if {$emsdkHome eq "" && [info exists ::env(EMSDK)]} { |
| 720 | # Fall back to checking the environment. $EMSDK gets set |
| 721 | # by sourcing emsdk_env.sh. |
| 722 | set emsdkHome $::env(EMSDK) |
| 723 | } |
| 724 | if {$emsdkHome ne ""} { |
| 725 | define EMSDK_HOME $emsdkHome |
| 726 | set emsdkEnv "$emsdkHome/emsdk_env.sh" |
| 727 | if {[file exists $emsdkEnv]} { |
| 728 | puts "Using Emscripten SDK environment from $emsdkEnv." |
| 729 | define EMSDK_ENV $emsdkEnv |
| 730 | if {[info exists ::env(EMCC_OPT)]} { |
| 731 | define EMCC_OPT $::env(EMCC_OPT) |
| 732 | } |
| 733 | } else { |
| 734 | puts "emsdk_env.sh not found. Assuming emcc is in the PATH." |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | # Network functions require libraries on some systems |
| 739 | cc-check-function-in-lib gethostbyname nsl |
| 740 | if {![cc-check-function-in-lib socket {socket network}]} { |
| 741 | # Last resort, may be Windows |
| 742 | if {[is_mingw]} { |
| @@ -767,11 +740,11 @@ | |
| 767 | cc-check-functions strchrnul |
| 768 | cc-check-functions pledge |
| 769 | cc-check-functions backtrace |
| 770 | |
| 771 | # Termux on Android adds "getpass(char *)" to unistd.h, so check this so we |
| 772 | # guard against including it again; use cctest as cc-check-functions and |
| 773 | # cctest_function check for "getpass()" with no args and fail |
| 774 | if {[cctest -link 1 -includes {unistd.h} -code "getpass(0);"]} { |
| 775 | define FOSSIL_HAVE_GETPASS 1 |
| 776 | msg-result "Found getpass() with unistd.h" |
| 777 | } |
| @@ -859,16 +832,88 @@ | |
| 859 | # Linux can only infer the dependency on pthread from OpenSSL when |
| 860 | # doing dynamic linkage. |
| 861 | define-append LIBS -lpthread |
| 862 | } |
| 863 | |
| 864 | if {[get-define EMSDK_HOME] ne ""} { |
| 865 | define EMCC_WRAPPER $::autosetup(dir)/../tools/emcc.sh |
| 866 | make-template tools/emcc.sh.in |
| 867 | catch {exec chmod u+x tools/emcc.sh} |
| 868 | } else { |
| 869 | define EMCC_WRAPPER "" |
| 870 | catch {exec rm -f tools/emcc.sh} |
| 871 | } |
| 872 | |
| 873 | # Tag container builds with a prefix of the checkin ID of the version |
| 874 | # of Fossil each one contains. This not only allows multiple images |
| 875 |
| --- auto.def | |
| +++ auto.def | |
| @@ -706,37 +706,10 @@ | |
| 706 | $tclconfig(TCL_LD_FLAGS)] |
| 707 | define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS) |
| 708 | define FOSSIL_ENABLE_TCL |
| 709 | } |
| 710 | |
| 711 | # Network functions require libraries on some systems |
| 712 | cc-check-function-in-lib gethostbyname nsl |
| 713 | if {![cc-check-function-in-lib socket {socket network}]} { |
| 714 | # Last resort, may be Windows |
| 715 | if {[is_mingw]} { |
| @@ -767,11 +740,11 @@ | |
| 740 | cc-check-functions strchrnul |
| 741 | cc-check-functions pledge |
| 742 | cc-check-functions backtrace |
| 743 | |
| 744 | # Termux on Android adds "getpass(char *)" to unistd.h, so check this so we |
| 745 | # guard against including it again; use cctest as cc-check-functions and |
| 746 | # cctest_function check for "getpass()" with no args and fail |
| 747 | if {[cctest -link 1 -includes {unistd.h} -code "getpass(0);"]} { |
| 748 | define FOSSIL_HAVE_GETPASS 1 |
| 749 | msg-result "Found getpass() with unistd.h" |
| 750 | } |
| @@ -859,16 +832,88 @@ | |
| 832 | # Linux can only infer the dependency on pthread from OpenSSL when |
| 833 | # doing dynamic linkage. |
| 834 | define-append LIBS -lpthread |
| 835 | } |
| 836 | |
| 837 | |
| 838 | ######################################################################## |
| 839 | # @proj-check-emsdk |
| 840 | # |
| 841 | # Emscripten is used for doing in-tree builds of web-based WASM stuff, |
| 842 | # as opposed to WASI-based WASM or WASM binaries we import from other |
| 843 | # places. This is only set up for Unix-style OSes and is untested |
| 844 | # anywhere but Linux. Requires that the --with-emsdk flag be |
| 845 | # registered with autosetup. |
| 846 | # |
| 847 | # It looks for the SDK in the location specified by --with-emsdk. |
| 848 | # Values of "" or "auto" mean to check for the environment var EMSDK |
| 849 | # (which gets set by the emsdk_env.sh script from the SDK) or that |
| 850 | # same var passed to configure. |
| 851 | # |
| 852 | # If the given directory is found, it expects to find emsdk_env.sh in |
| 853 | # that directory, as well as the emcc compiler somewhere under there. |
| 854 | # |
| 855 | # If the --with-emsdk flag is explicitly provided and the SDK is not |
| 856 | # found then a fatal error is generated, otherwise failure to find the |
| 857 | # SDK is not fatal. |
| 858 | # |
| 859 | # Defines the following: |
| 860 | # |
| 861 | # - EMSDK_HOME = top dir of the emsdk or "". |
| 862 | # - EMSDK_ENV_SH = path to EMSDK_HOME/emsdk_env.sh or "" |
| 863 | # - BIN_EMCC = $EMSDK_HOME/upstream/emscripten/emcc or "" |
| 864 | # - HAVE_EMSDK = 0 or 1 (this function's return value) |
| 865 | # |
| 866 | # Returns 1 if EMSDK_ENV_SH is found, else 0. If EMSDK_HOME is not empty |
| 867 | # but BIN_EMCC is then emcc was not found in the EMSDK_HOME, in which |
| 868 | # case we have to rely on the fact that sourcing $EMSDK_ENV_SH from a |
| 869 | # shell will add emcc to the $PATH. |
| 870 | proc proj-check-emsdk {} { |
| 871 | set emsdkHome [opt-val with-emsdk] |
| 872 | define EMSDK_HOME "" |
| 873 | define EMSDK_ENV_SH "" |
| 874 | define BIN_EMCC "" |
| 875 | set hadValue [llength $emsdkHome] |
| 876 | msg-checking "Emscripten SDK? " |
| 877 | if {$emsdkHome in {"" "auto"}} { |
| 878 | # Check the environment. $EMSDK gets set by sourcing emsdk_env.sh. |
| 879 | set emsdkHome [get-env EMSDK ""] |
| 880 | } |
| 881 | set rc 0 |
| 882 | if {$emsdkHome ne ""} { |
| 883 | define EMSDK_HOME $emsdkHome |
| 884 | set emsdkEnv "$emsdkHome/emsdk_env.sh" |
| 885 | if {[file exists $emsdkEnv]} { |
| 886 | msg-result "$emsdkHome" |
| 887 | define EMSDK_ENV_SH $emsdkEnv |
| 888 | set rc 1 |
| 889 | set emcc "$emsdkHome/upstream/emscripten/emcc" |
| 890 | if {[file exists $emcc]} { |
| 891 | define BIN_EMCC $emcc |
| 892 | } |
| 893 | } else { |
| 894 | msg-result "emsdk_env.sh not found in $emsdkHome" |
| 895 | } |
| 896 | } else { |
| 897 | msg-result "not found" |
| 898 | } |
| 899 | if {$hadValue && 0 == $rc} { |
| 900 | # Fail if it was explicitly requested but not found |
| 901 | proj-fatal "Cannot find the Emscripten SDK" |
| 902 | } |
| 903 | define HAVE_EMSDK $rc |
| 904 | return $rc |
| 905 | } |
| 906 | |
| 907 | if {[proj-check-emsdk]} { |
| 908 | define EMCC_WRAPPER $::autosetup(dir)/../tools/emcc.sh |
| 909 | define EMCC_OPT [get-env EMCC_OPT "-Oz"]; # optional flags to pass to emcc |
| 910 | make-template tools/emcc.sh.in |
| 911 | catch {exec chmod u+x tools/emcc.sh} |
| 912 | } else { |
| 913 | define EMCC_WRAPPER "" |
| 914 | define EMCC_OPT "" |
| 915 | catch {exec rm -f tools/emcc.sh} |
| 916 | } |
| 917 | |
| 918 | # Tag container builds with a prefix of the checkin ID of the version |
| 919 | # of Fossil each one contains. This not only allows multiple images |
| 920 |
+23
-17
| --- tools/emcc.sh.in | ||
| +++ tools/emcc.sh.in | ||
| @@ -1,6 +1,7 @@ | ||
| 1 | -#!/usr/bin/bash | |
| 1 | +#!/bin/sh | |
| 2 | +# ^^^^^^^ Please try to keep this script Bourne-compatible. | |
| 2 | 3 | ######################################################################## |
| 3 | 4 | # WARNING: emcc.sh is generated from emcc.sh.in by the configure |
| 4 | 5 | # process. Do not edit emcc.sh directly, as it may be deleted or |
| 5 | 6 | # overwritten by the configure script. |
| 6 | 7 | # |
| @@ -7,54 +8,59 @@ | ||
| 7 | 8 | # A wrapper around the emcc compiler which uses configure-time state |
| 8 | 9 | # to locate the Emscripten SDK and import the SDK's environment |
| 9 | 10 | # script, if needed. |
| 10 | 11 | ######################################################################## |
| 11 | 12 | # EMSDK_HOME comes from the configure --with-emsdk=/dir flag. |
| 12 | -# EMSDK_ENV is ${thatDir}/emsdk_env.sh and is also set by the | |
| 13 | +# EMSDK_ENV_SH is ${thatDir}/emsdk_env.sh and is also set by the | |
| 13 | 14 | # configure process. |
| 14 | 15 | EMSDK_HOME="@EMSDK_HOME@" |
| 15 | -EMSDK_ENV="@EMSDK_ENV@" | |
| 16 | +EMSDK_ENV_SH="@EMSDK_ENV_SH@" | |
| 17 | +emcc="@BIN_EMCC@" | |
| 16 | 18 | |
| 17 | -emcc=$(which emcc 2>/dev/null) | |
| 19 | +if [ x = "x${emcc}" ]; then | |
| 20 | + emcc=`which emcc 2>/dev/null` | |
| 21 | +fi | |
| 18 | 22 | |
| 19 | 23 | if [ x = "x${emcc}" ]; then |
| 20 | 24 | # If emcc is not found in the path, try to find it via an emsdk |
| 21 | - # installation. The SDK variant is the official installation | |
| 22 | - # style supported by the Emscripten folks, but emcc is also | |
| 23 | - # available via package managers on some OSes. | |
| 25 | + # installation. The SDK variant is the official installation style | |
| 26 | + # supported by the Emscripten project, but emcc is also available | |
| 27 | + # via package managers on some OSes. | |
| 24 | 28 | if [ x = "x${EMSDK_HOME}" ]; then |
| 25 | 29 | echo "EMSDK_HOME is not set. Pass --with-emsdk=/path/to/emsdk" \ |
| 26 | 30 | "to the configure script." 1>&2 |
| 27 | 31 | exit 1 |
| 28 | 32 | fi |
| 29 | 33 | |
| 30 | - if [ x = "x${EMSDK_ENV}" ]; then | |
| 34 | + if [ x = "x${EMSDK_ENV_SH}" ]; then | |
| 31 | 35 | if [ -f "${EMSDK_HOME}/emsdk_env.sh" ]; then |
| 32 | - EMSDK_ENV="${EMSDK_HOME}/emsdk_env.sh" | |
| 36 | + EMSDK_ENV_SH="${EMSDK_HOME}/emsdk_env.sh" | |
| 33 | 37 | else |
| 34 | - echo "EMSDK_ENV is not set. Expecting configure script to set it." 1>&2 | |
| 38 | + echo "EMSDK_ENV_SH is not set. Expecting configure script to set it." 1>&2 | |
| 35 | 39 | exit 2 |
| 36 | 40 | fi |
| 37 | 41 | fi |
| 38 | 42 | |
| 39 | - if [ ! -f "${EMSDK_ENV}" ]; then | |
| 40 | - echo "emsdk_env script not found: $EMSDK_ENV" 1>&2 | |
| 43 | + if [ ! -f "${EMSDK_ENV_SH}" ]; then | |
| 44 | + echo "emsdk_env script not found: $EMSDK_ENV_SH" 1>&2 | |
| 41 | 45 | exit 3 |
| 42 | 46 | fi |
| 43 | 47 | |
| 44 | 48 | # $EMSDK is part of the state set by emsdk_env.sh. |
| 45 | 49 | if [ x = "x${EMSDK}" ]; then |
| 46 | - source "${EMSDK_ENV}" >/dev/null 2>&1 || { | |
| 47 | - # ^^^ unfortunately outputs lots of noise to stderr | |
| 50 | + EMSDK_QUIET=1 | |
| 51 | + export EMSDK_QUIET | |
| 52 | + # ^^^ Squelches informational output from ${EMSDK_ENV_SH}. | |
| 53 | + source "${EMSDK_ENV_SH}" || { | |
| 48 | 54 | rc=$? |
| 49 | - echo "Error sourcing ${EMSDK_ENV}" | |
| 55 | + echo "Error sourcing ${EMSDK_ENV_SH}" | |
| 50 | 56 | exit $rc |
| 51 | 57 | } |
| 52 | 58 | fi |
| 53 | - emcc=$(which emcc 2>/dev/null) | |
| 59 | + emcc=`which emcc 2>/dev/null` | |
| 54 | 60 | if [ x = "x${emcc}" ]; then |
| 55 | - echo "emcc not found in PATH. Normally that's set up by EMSDK_ENV." 1>&2 | |
| 61 | + echo "emcc not found in PATH. Normally that's set up by ${EMSDK_ENV_SH}." 1>&2 | |
| 56 | 62 | exit 4 |
| 57 | 63 | fi |
| 58 | 64 | fi |
| 59 | 65 | |
| 60 | 66 | exec $emcc "$@" |
| 61 | 67 |
| --- tools/emcc.sh.in | |
| +++ tools/emcc.sh.in | |
| @@ -1,6 +1,7 @@ | |
| 1 | #!/usr/bin/bash |
| 2 | ######################################################################## |
| 3 | # WARNING: emcc.sh is generated from emcc.sh.in by the configure |
| 4 | # process. Do not edit emcc.sh directly, as it may be deleted or |
| 5 | # overwritten by the configure script. |
| 6 | # |
| @@ -7,54 +8,59 @@ | |
| 7 | # A wrapper around the emcc compiler which uses configure-time state |
| 8 | # to locate the Emscripten SDK and import the SDK's environment |
| 9 | # script, if needed. |
| 10 | ######################################################################## |
| 11 | # EMSDK_HOME comes from the configure --with-emsdk=/dir flag. |
| 12 | # EMSDK_ENV is ${thatDir}/emsdk_env.sh and is also set by the |
| 13 | # configure process. |
| 14 | EMSDK_HOME="@EMSDK_HOME@" |
| 15 | EMSDK_ENV="@EMSDK_ENV@" |
| 16 | |
| 17 | emcc=$(which emcc 2>/dev/null) |
| 18 | |
| 19 | if [ x = "x${emcc}" ]; then |
| 20 | # If emcc is not found in the path, try to find it via an emsdk |
| 21 | # installation. The SDK variant is the official installation |
| 22 | # style supported by the Emscripten folks, but emcc is also |
| 23 | # available via package managers on some OSes. |
| 24 | if [ x = "x${EMSDK_HOME}" ]; then |
| 25 | echo "EMSDK_HOME is not set. Pass --with-emsdk=/path/to/emsdk" \ |
| 26 | "to the configure script." 1>&2 |
| 27 | exit 1 |
| 28 | fi |
| 29 | |
| 30 | if [ x = "x${EMSDK_ENV}" ]; then |
| 31 | if [ -f "${EMSDK_HOME}/emsdk_env.sh" ]; then |
| 32 | EMSDK_ENV="${EMSDK_HOME}/emsdk_env.sh" |
| 33 | else |
| 34 | echo "EMSDK_ENV is not set. Expecting configure script to set it." 1>&2 |
| 35 | exit 2 |
| 36 | fi |
| 37 | fi |
| 38 | |
| 39 | if [ ! -f "${EMSDK_ENV}" ]; then |
| 40 | echo "emsdk_env script not found: $EMSDK_ENV" 1>&2 |
| 41 | exit 3 |
| 42 | fi |
| 43 | |
| 44 | # $EMSDK is part of the state set by emsdk_env.sh. |
| 45 | if [ x = "x${EMSDK}" ]; then |
| 46 | source "${EMSDK_ENV}" >/dev/null 2>&1 || { |
| 47 | # ^^^ unfortunately outputs lots of noise to stderr |
| 48 | rc=$? |
| 49 | echo "Error sourcing ${EMSDK_ENV}" |
| 50 | exit $rc |
| 51 | } |
| 52 | fi |
| 53 | emcc=$(which emcc 2>/dev/null) |
| 54 | if [ x = "x${emcc}" ]; then |
| 55 | echo "emcc not found in PATH. Normally that's set up by EMSDK_ENV." 1>&2 |
| 56 | exit 4 |
| 57 | fi |
| 58 | fi |
| 59 | |
| 60 | exec $emcc "$@" |
| 61 |
| --- tools/emcc.sh.in | |
| +++ tools/emcc.sh.in | |
| @@ -1,6 +1,7 @@ | |
| 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 | # |
| @@ -7,54 +8,59 @@ | |
| 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 | |
| 19 | if [ x = "x${emcc}" ]; then |
| 20 | emcc=`which emcc 2>/dev/null` |
| 21 | fi |
| 22 | |
| 23 | if [ x = "x${emcc}" ]; then |
| 24 | # If emcc is not found in the path, try to find it via an emsdk |
| 25 | # installation. The SDK variant is the official installation style |
| 26 | # supported by the Emscripten project, but emcc is also available |
| 27 | # via package managers on some OSes. |
| 28 | if [ x = "x${EMSDK_HOME}" ]; then |
| 29 | echo "EMSDK_HOME is not set. Pass --with-emsdk=/path/to/emsdk" \ |
| 30 | "to the configure script." 1>&2 |
| 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | if [ x = "x${EMSDK_ENV_SH}" ]; then |
| 35 | if [ -f "${EMSDK_HOME}/emsdk_env.sh" ]; then |
| 36 | EMSDK_ENV_SH="${EMSDK_HOME}/emsdk_env.sh" |
| 37 | else |
| 38 | echo "EMSDK_ENV_SH is not set. Expecting configure script to set it." 1>&2 |
| 39 | exit 2 |
| 40 | fi |
| 41 | fi |
| 42 | |
| 43 | if [ ! -f "${EMSDK_ENV_SH}" ]; then |
| 44 | echo "emsdk_env script not found: $EMSDK_ENV_SH" 1>&2 |
| 45 | exit 3 |
| 46 | fi |
| 47 | |
| 48 | # $EMSDK is part of the state set by emsdk_env.sh. |
| 49 | if [ x = "x${EMSDK}" ]; then |
| 50 | EMSDK_QUIET=1 |
| 51 | export EMSDK_QUIET |
| 52 | # ^^^ Squelches informational output from ${EMSDK_ENV_SH}. |
| 53 | source "${EMSDK_ENV_SH}" || { |
| 54 | rc=$? |
| 55 | echo "Error sourcing ${EMSDK_ENV_SH}" |
| 56 | exit $rc |
| 57 | } |
| 58 | fi |
| 59 | emcc=`which emcc 2>/dev/null` |
| 60 | if [ x = "x${emcc}" ]; then |
| 61 | echo "emcc not found in PATH. Normally that's set up by ${EMSDK_ENV_SH}." 1>&2 |
| 62 | exit 4 |
| 63 | fi |
| 64 | fi |
| 65 | |
| 66 | exec $emcc "$@" |
| 67 |