Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe97790

Browse filesBrowse files
committed
handle closured code in separate_asm
1 parent 590df4e commit fe97790
Copy full SHA for fe97790

2 files changed

+14-4Lines changed: 14 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tests/test_browser.py‎

Copy file name to clipboardExpand all lines: tests/test_browser.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,10 +2868,10 @@ def test_canvas_size_proxy(self):
28682868
self.btest(path_from_root('tests', 'canvas_size_proxy.c'), expected='0', args=['--proxy-to-worker'])
28692869

28702870
def test_separate_asm(self):
2871-
for opts in [0, 1, 2]:
2871+
for opts in [['-O0'], ['-O1'], ['-O2'], ['-O2', '--closure', '1']]:
28722872
print opts
28732873
open('src.cpp', 'w').write(self.with_report_result(open(path_from_root('tests', 'browser_test_hello_world.c')).read()))
2874-
Popen([PYTHON, EMCC, 'src.cpp', '-o', 'test.html', '-O' + str(opts)]).communicate()
2874+
Popen([PYTHON, EMCC, 'src.cpp', '-o', 'test.html'] + opts).communicate()
28752875
self.run_browser('test.html', None, '/report_result?0')
28762876

28772877
open('one.html', 'w').write('<script src="test.js"></script>')
@@ -2889,7 +2889,7 @@ def test_separate_asm(self):
28892889

28902890
self.clear()
28912891
assert not os.path.exists('tests.asm.js')
2892-
self.btest('browser_test_hello_world.c', expected='0', args=['-O' + str(opts), '--separate-asm'])
2892+
self.btest('browser_test_hello_world.c', expected='0', args=opts + ['--separate-asm'])
28932893
assert os.path.exists('test.asm.js')
28942894
os.unlink('test.asm.js')
28952895
self.run_browser('test.html', None, '[no http server activity]', timeout=5) # fail without the asm
Collapse file

‎tools/separate_asm.py‎

Copy file name to clipboardExpand all lines: tools/separate_asm.py
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@
1515
module = asm_module.AsmModule(infile).asm_js
1616

1717
module = module[module.find('=')+1:] # strip the initial "var asm =" bit, leave just the raw module as a function
18-
everything = everything.replace(module, 'Module["asm"]')
18+
if 'var Module' in everything:
19+
everything = everything.replace(module, 'Module["asm"]')
20+
else:
21+
# closure compiler removes |var Module|, we need to find the closured name
22+
evil = everything.find('eval(')
23+
evil = everything.rfind('=', 0, evil)
24+
start = evil
25+
while everything[start] in [' ', '=']: start -= 1
26+
while everything[start] not in [' ', ',', '(']: start -= 1
27+
closured_name = everything[start+1:evil].strip()
28+
everything = everything.replace(module, closured_name + '["asm"]')
1929

2030
o = open(asmfile, 'w')
2131
o.write('Module["asm"] = ')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.