Skip to content

Commit a2bc9a3

Browse files
author
Alan Kligman
committed
Updated to add a PYTHON config option instead of defaulting to python2. This should preserve the default behavior in a way that can be overridden.
1 parent 14077b9 commit a2bc9a3

4 files changed

Lines changed: 18 additions & 12 deletions

File tree

em++

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ import os, subprocess, sys
88
from tools import shared
99

1010
os.environ['EMMAKEN_CXX'] = '1'
11-
exit(subprocess.call(['python2', shared.EMCC] + sys.argv[1:]))
11+
exit(subprocess.call([shared.PYTHON, shared.EMCC] + sys.argv[1:]))
1212

emcc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -925,9 +925,9 @@ try:
925925
# dlmalloc
926926
def create_dlmalloc():
927927
if DEBUG: print >> sys.stderr, 'emcc: building dlmalloc for cache'
928-
execute(shared.ENV_PREFIX + ['python2', shared.EMCC, shared.path_from_root('system', 'lib', 'dlmalloc.c'), '-g', '-o', in_temp('dlmalloc.o')], stdout=stdout, stderr=stderr)
928+
execute([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', 'dlmalloc.c'), '-g', '-o', in_temp('dlmalloc.o')], stdout=stdout, stderr=stderr)
929929
# we include the libc++ new stuff here, so that the common case of using just new/delete is quick to link
930-
execute(shared.ENV_PREFIX + ['python2', shared.EMXX, shared.path_from_root('system', 'lib', 'libcxx', 'new.cpp'), '-g', '-o', in_temp('new.o')], stdout=stdout, stderr=stderr)
930+
execute([shared.PYTHON, shared.EMXX, shared.path_from_root('system', 'lib', 'libcxx', 'new.cpp'), '-g', '-o', in_temp('new.o')], stdout=stdout, stderr=stderr)
931931
shared.Building.link([in_temp('dlmalloc.o'), in_temp('new.o')], in_temp('dlmalloc_full.o'))
932932
return in_temp('dlmalloc_full.o')
933933
def fix_dlmalloc():
@@ -950,7 +950,7 @@ try:
950950
os = []
951951
for src in ['algorithm.cpp', 'condition_variable.cpp', 'future.cpp', 'iostream.cpp', 'memory.cpp', 'random.cpp', 'stdexcept.cpp', 'system_error.cpp', 'utility.cpp', 'bind.cpp', 'debug.cpp', 'hash.cpp', 'mutex.cpp', 'string.cpp', 'thread.cpp', 'valarray.cpp', 'chrono.cpp', 'exception.cpp', 'ios.cpp', 'locale.cpp', 'regex.cpp', 'strstream.cpp', 'typeinfo.cpp']:
952952
o = in_temp(src + '.o')
953-
execute(shared.ENV_PREFIX + ['python2', shared.EMXX, shared.path_from_root('system', 'lib', 'libcxx', src), '-o', o], stdout=stdout, stderr=stderr)
953+
execute([shared.PYTHON, shared.EMXX, shared.path_from_root('system', 'lib', 'libcxx', src), '-o', o], stdout=stdout, stderr=stderr)
954954
os.append(o)
955955
shared.Building.link(os, in_temp('libcxx.bc'))
956956
return in_temp('libcxx.bc')
@@ -969,7 +969,7 @@ try:
969969
os = []
970970
for src in ['private_typeinfo.cpp']:
971971
o = in_temp(src + '.o')
972-
execute(shared.ENV_PREFIX + ['python2', shared.EMXX, shared.path_from_root('system', 'lib', 'libcxxabi', 'src', src), '-o', o], stdout=stdout, stderr=stderr)
972+
execute([shared.PYTHON, shared.EMXX, shared.path_from_root('system', 'lib', 'libcxxabi', 'src', src), '-o', o], stdout=stdout, stderr=stderr)
973973
os.append(o)
974974
shared.Building.link(os, in_temp('libcxxabi.bc'))
975975
return in_temp('libcxxabi.bc')
@@ -1075,7 +1075,7 @@ try:
10751075

10761076
if AUTODEBUG:
10771077
if DEBUG: print >> sys.stderr, 'emcc: autodebug'
1078-
execute(shared.ENV_PREFIX + ['python2', shared.AUTODEBUGGER, final, final + '.ad.ll'])
1078+
execute([shared.PYTHON, shared.AUTODEBUGGER, final, final + '.ad.ll'])
10791079
final += '.ad.ll'
10801080
if DEBUG: save_intermediate('autodebug', 'll')
10811081

@@ -1098,7 +1098,7 @@ try:
10981098
file_args += embed_files
10991099
if Compression.on:
11001100
file_args += ['--compress', Compression.encoder, Compression.decoder, Compression.js_name]
1101-
code = execute(shared.ENV_PREFIX + ['python2', shared.FILE_PACKAGER, unsuffixed(target) + '.data'] + file_args, stdout=PIPE)[0]
1101+
code = execute([shared.PYTHON, shared.FILE_PACKAGER, unsuffixed(target) + '.data'] + file_args, stdout=PIPE)[0]
11021102
src = open(final).read().replace('// {{PRE_RUN_ADDITIONS}}', '// {{PRE_RUN_ADDITIONS}}\n' + code)
11031103
final += '.files.js'
11041104
open(final, 'w').write(src)

tools/emmakenxx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ def path_from_root(*pathelems):
1414

1515
emmaken = path_from_root('tools', 'emmaken.py')
1616
os.environ['EMMAKEN_CXX'] = '1'
17-
exit(subprocess.call(['python2', emmaken] + sys.argv[1:]))
17+
exit(subprocess.call([PYTHON, emmaken] + sys.argv[1:]))
1818

tools/shared.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ def clean_temp():
318318
except:
319319
CLOSURE_COMPILER = path_from_root('third_party', 'closure-compiler', 'compiler.jar')
320320

321+
try:
322+
PYTHON
323+
except:
324+
print >> sys.stderr, 'PYTHON not defined in ~/.emscripten, using "python"'
325+
PYTHON = 'python'
326+
321327
try:
322328
JAVA
323329
except:
@@ -378,7 +384,7 @@ def clean_temp():
378384
ENV_PREFIX = []
379385
if not WINDOWS:
380386
try:
381-
assert 'Python' in Popen(['env', 'python2', '-V'], stdout=PIPE, stderr=STDOUT).communicate()[0]
387+
assert 'Python' in Popen(['env', 'python', '-V'], stdout=PIPE, stderr=STDOUT).communicate()[0]
382388
ENV_PREFIX = ['env']
383389
except:
384390
pass
@@ -862,13 +868,13 @@ def emcc(filename, args=[], output_filename=None, stdout=None, stderr=None, env=
862868
if output_filename is None:
863869
output_filename = filename + '.o'
864870
try_delete(output_filename)
865-
Popen(ENV_PREFIX + ['python2', EMCC, filename] + args + ['-o', output_filename], stdout=stdout, stderr=stderr, env=env).communicate()
871+
Popen([PYTHON, EMCC, filename] + args + ['-o', output_filename], stdout=stdout, stderr=stderr, env=env).communicate()
866872
assert os.path.exists(output_filename), 'emcc could not create output file'
867873

868874
@staticmethod
869875
def emar(action, output_filename, filenames, stdout=None, stderr=None, env=None):
870876
try_delete(output_filename)
871-
Popen(ENV_PREFIX + ['python2', EMAR, action, output_filename] + filenames, stdout=stdout, stderr=stderr, env=env).communicate()
877+
Popen([PYTHON, EMAR, action, output_filename] + filenames, stdout=stdout, stderr=stderr, env=env).communicate()
872878
if 'c' in action:
873879
assert os.path.exists(output_filename), 'emar could not create output file'
874880

@@ -879,7 +885,7 @@ def emscripten(filename, append_ext=True, extra_args=[]):
879885

880886
# Run Emscripten
881887
settings = Settings.serialize()
882-
compiler_output = timeout_run(Popen(ENV_PREFIX + ['python2', EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + settings + extra_args, stdout=PIPE), None, 'Compiling')
888+
compiler_output = timeout_run(Popen([PYTHON, EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + settings + extra_args, stdout=PIPE), None, 'Compiling')
883889
#print compiler_output
884890

885891
# Detect compilation crashes and errors

0 commit comments

Comments
 (0)