Skip to content

Commit

Permalink
Fix CMake invocation to support cases when NODE_JS in ~/.emscripten i…
Browse files Browse the repository at this point in the history
…s a list that contains optional parameters to node.js. Fixes emscripten-core#4045.
  • Loading branch information
juj committed Jan 20, 2016
1 parent 45bd04e commit 8814787
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion emconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run():
'''
elif 'cmake' in sys.argv[1]:
node_js = shared.NODE_JS
if type(node_js) is list: node_js = ' '.join(node_js)
if type(node_js) is list: node_js = node_js[0]
node_js = shared.Building.which(node_js)
node_js = node_js.replace('"', '\"')
sys.argv = sys.argv[:2] + ['-DCMAKE_CROSSCOMPILING_EMULATOR="' + node_js +'"'] + sys.argv[2:]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def check_makefile(configuration, dirname):
# Test invoking cmake directly.
cmd = ['cmake', '-DCMAKE_TOOLCHAIN_FILE='+path_from_root('cmake', 'Modules', 'Platform', 'Emscripten.cmake'),
'-DCPP_LIBRARY_TYPE='+cpp_lib_type,
'-DCMAKE_CROSSCOMPILING_EMULATOR="' + Building.which(' '.join(NODE_JS)) + '"',
'-DCMAKE_CROSSCOMPILING_EMULATOR="' + Building.which(NODE_JS[0] if type(NODE_JS) is list else NODE_JS) + '"',
'-DCMAKE_BUILD_TYPE=' + configuration, cmake_arguments[i], '-G', generator, cmakelistsdir]
env = tools.shared.Building.remove_sh_exe_from_path(os.environ)
else:
Expand Down
24 changes: 12 additions & 12 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,24 +1086,24 @@ def which(program):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

if os.path.isabs(program):
if os.path.isfile(program): return program

if WINDOWS:
for suffix in ['.exe', '.cmd', '.bat']:
if is_exe(program + suffix): return program + suffix

fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
if is_exe(program): return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file

if WINDOWS and not '.' in fname:
if is_exe(exe_file + '.exe'):
return exe_file + '.exe'
if is_exe(exe_file + '.cmd'):
return exe_file + '.cmd'
if is_exe(exe_file + '.bat'):
return exe_file + '.bat'
if is_exe(exe_file): return exe_file
if WINDOWS:
for suffix in ['.exe', '.cmd', '.bat']:
if is_exe(exe_file + suffix): return exe_file + suffix

return None

Expand Down

0 comments on commit 8814787

Please sign in to comment.