@@ -689,19 +689,20 @@ def test_js_transform(self):
689689 self.assertIn('transformed!', read_file('a.out.js'))
690690
691691 @crossplatform
692+ @also_with_wasm64
692693 def test_emcc_cflags(self):
693- output = self.run_process([EMCC, '--cflags'], stdout=PIPE)
694+ output = self.run_process([EMCC, '--cflags'] + self.get_cflags() , stdout=PIPE)
694695 flags = output.stdout.strip()
695- self.assertContained('-target wasm32 -unknown-emscripten', flags)
696+ self.assertContained(r '-target wasm\d\d -unknown-emscripten', flags, regex=True )
696697 self.assertContained('--sysroot=', flags)
697- output = self.run_process([EMXX, '--cflags'], stdout=PIPE)
698+ output = self.run_process([EMXX, '--cflags'] + self.get_cflags() , stdout=PIPE)
698699 flags = output.stdout.strip()
699- self.assertContained('-target wasm32 -unknown-emscripten', flags)
700+ self.assertContained(r '-target wasm\d\d -unknown-emscripten', flags, regex=True )
700701 self.assertContained('--sysroot=', flags)
701702 # check they work
702703 cmd = [CLANG_CC, test_file('hello_world.c')] + shlex.split(flags.replace('\\', '\\\\')) + ['-c', '-o', 'out.o']
703704 self.run_process(cmd)
704- self.run_process([EMCC, 'out.o'])
705+ self.run_process([EMCC, 'out.o'] + self.get_cflags() )
705706 self.assertContained('hello, world!', self.run_js('a.out.js'))
706707
707708 @crossplatform
@@ -4947,6 +4948,35 @@ def test_jslib_aliases(self, args):
49474948'''
49484949 self.do_runf('main.c', expected, cflags=['--js-library', 'foo.js'] + args)
49494950
4951+ @parameterized({
4952+ '': ([],),
4953+ 'closure': (['--closure=1'],),
4954+ })
4955+ def test_jslib_export_alias(self, args):
4956+ create_file('lib.js', '''
4957+ addToLibrary({
4958+ $foo: 'main',
4959+ $bar: '__indirect_function_table',
4960+ $baz: 'memory',
4961+ });
4962+ ''')
4963+ create_file('extern_pre.js', r'''
4964+ Module = {
4965+ onRuntimeInitialized: () => {
4966+ const assert = require('assert');
4967+ console.log("onRuntimeInitialized");
4968+ console.log('foo:', typeof Module.foo)
4969+ console.log('bar:', typeof Module.bar)
4970+ console.log('baz:', typeof Module.baz)
4971+ assert(Module.foo instanceof Function);
4972+ assert(Module.bar instanceof WebAssembly.Table);
4973+ assert(Module.baz instanceof WebAssembly.Memory);
4974+ console.log('done');
4975+ }
4976+ };
4977+ ''')
4978+ self.do_runf('hello_world.c', 'done\n', cflags=['--js-library=lib.js', '--extern-pre-js=extern_pre.js', '-sEXPORTED_RUNTIME_METHODS=foo,bar,baz'] + args)
4979+
49504980 def test_postjs_errors(self):
49514981 create_file('post.js', '#preprocess\n#error This is an error')
49524982 err = self.expect_fail([EMCC, test_file('hello_world.c'), '--post-js', 'post.js'])
0 commit comments