Skip to content

Commit e456ebd

Browse files
authored
Add EMSDK_QUIET to make emsdk_env less chatting (#1091)
Without this the recommended way to silence emsdk_env was to pipe its stderr to /dev/null.. but then you also loose potentially useful error message. Fixes: #946
1 parent c220895 commit e456ebd

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

emsdk.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,15 @@
5656
# Enable this to do very verbose printing about the different steps that are
5757
# being run. Useful for debugging.
5858
VERBOSE = int(os.getenv('EMSDK_VERBOSE', '0'))
59+
QUIET = int(os.getenv('EMSDK_QUIET', '0'))
5960
TTY_OUTPUT = not os.getenv('EMSDK_NOTTY', not sys.stdout.isatty())
6061

6162

63+
def info(msg):
64+
if not QUIET:
65+
print(msg, file=sys.stderr)
66+
67+
6268
def errlog(msg):
6369
print(msg, file=sys.stderr)
6470

@@ -2663,10 +2669,10 @@ def get_env_vars_to_add(tools_to_activate, system, user):
26632669
env_vars_to_add += [('PATH', newpath)]
26642670

26652671
if added_path:
2666-
errlog('Adding directories to PATH:')
2672+
info('Adding directories to PATH:')
26672673
for item in added_path:
2668-
errlog('PATH += ' + item)
2669-
errlog('')
2674+
info('PATH += ' + item)
2675+
info('')
26702676

26712677
# A core variable EMSDK points to the root of Emscripten SDK directory.
26722678
env_vars_to_add += [('EMSDK', to_unix_path(emsdk_path()))]
@@ -2705,6 +2711,7 @@ def get_env_vars_to_add(tools_to_activate, system, user):
27052711

27062712

27072713
def construct_env(tools_to_activate, system, user):
2714+
info('Setting up EMSDK environment (suppress these messages with EMSDK_QUIET=1)')
27082715
return construct_env_with_vars(get_env_vars_to_add(tools_to_activate, system, user))
27092716

27102717

@@ -2723,13 +2730,13 @@ def unset_env(key):
27232730
def construct_env_with_vars(env_vars_to_add):
27242731
env_string = ''
27252732
if env_vars_to_add:
2726-
errlog('Setting environment variables:')
2733+
info('Setting environment variables:')
27272734

27282735
for key, value in env_vars_to_add:
27292736
# Don't set env vars which are already set to the correct value.
27302737
if key in os.environ and to_unix_path(os.environ[key]) == to_unix_path(value):
27312738
continue
2732-
errlog(key + ' = ' + value)
2739+
info(key + ' = ' + value)
27332740
if POWERSHELL:
27342741
env_string += '$env:' + key + '="' + value + '"\n'
27352742
elif CMD:
@@ -2757,9 +2764,9 @@ def construct_env_with_vars(env_vars_to_add):
27572764
'EMSDK_NUM_CORES', 'EMSDK_NOTTY', 'EMSDK_KEEP_DOWNLOADS'])
27582765
env_keys_to_add = set(pair[0] for pair in env_vars_to_add)
27592766
for key in os.environ:
2760-
if key.startswith('EMSDK_') or key.startswith('EM_'):
2767+
if key.startswith('EMSDK_') or key.startswith('EM_CACHE'):
27612768
if key not in env_keys_to_add and key not in ignore_keys:
2762-
errlog('Clearing existing environment variable: %s' % key)
2769+
info('Clearing existing environment variable: %s' % key)
27632770
env_string += unset_env(key)
27642771

27652772
return env_string

0 commit comments

Comments
 (0)