Skip to content

Commit

Permalink
Merge pull request #4800 from juj/validate_binaryen_method
Browse files Browse the repository at this point in the history
validate_binaryen_method
  • Loading branch information
juj committed Dec 16, 2016
2 parents 9a648a8 + 79fd452 commit 39a3d6d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2008,6 +2008,14 @@ def do_minify(): # minifies the code. this is also when we do certain optimizati
print jsrun.run_js(shared.path_from_root('tools', 'js-optimizer.js'), shared.NODE_JS, args=[asm_target, 'eliminateDeadGlobals', 'last', 'asm'], stdout=open(temp, 'w'))
shutil.move(temp, asm_target)

if shared.Settings.BINARYEN_METHOD:
methods = shared.Settings.BINARYEN_METHOD.split(',')
valid_methods = ['asmjs', 'native-wasm', 'interpret-s-expr', 'interpret-binary', 'interpret-asm2wasm']
for m in methods:
if not m.strip() in valid_methods:
logging.error('Unrecognized BINARYEN_METHOD "' + m.strip() + '" specified! Please pass a comma-delimited list containing one or more of: ' + ','.join(valid_methods))
sys.exit(1)

if shared.Settings.BINARYEN:
logging.debug('using binaryen, with method: ' + shared.Settings.BINARYEN_METHOD)
binaryen_bin = os.path.join(shared.Settings.BINARYEN_ROOT, 'bin')
Expand Down
5 changes: 5 additions & 0 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -7012,6 +7012,11 @@ def test_binaryen_warn_mem(self):
subprocess.check_call([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp'), '-s', 'WASM=1', '-s', 'BINARYEN_METHOD="native-wasm"', '-s', 'TOTAL_MEMORY=' + str(16*1024*1024), '--pre-js', 'pre.js', '-s', 'ALLOW_MEMORY_GROWTH=1'])
self.assertContained('hello, world!', run_js('a.out.js', engine=SPIDERMONKEY_ENGINE))

def test_binaryen_invalid_method(self):
proc = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp'), '-o', 'test.js', '-s', "BINARYEN_METHOD='invalid'"])
proc.communicate()
assert proc.returncode != 0

def test_binaryen_default_method(self):
if SPIDERMONKEY_ENGINE not in JS_ENGINES: return self.skip('cannot run without spidermonkey')
subprocess.check_call([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp'), '-s', 'WASM=1'])
Expand Down

0 comments on commit 39a3d6d

Please sign in to comment.