From 2f57b4b2ceca89c1558864891c58d553bc1f9270 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sun, 28 Sep 2014 17:56:24 -0700 Subject: [PATCH] fix warning on EXPORTED_FUNCTIONS, and improve test --- emscripten.py | 4 +++- tests/test_core.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/emscripten.py b/emscripten.py index 0112bea13..0ea37f706 100755 --- a/emscripten.py +++ b/emscripten.py @@ -932,7 +932,9 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None, exported_implemented_functions.add(key) implemented_functions = set(metadata['implementedFunctions']) if settings['ASSERTIONS'] and settings.get('ORIGINAL_EXPORTED_FUNCTIONS'): - for requested in settings['ORIGINAL_EXPORTED_FUNCTIONS']: + original_exports = settings['ORIGINAL_EXPORTED_FUNCTIONS'] + if original_exports[0] == '@': original_exports = json.loads(open(original_exports[1:]).read()) + for requested in original_exports: if requested not in all_implemented and \ requested != '_malloc': # special-case malloc, EXPORTED by default for internal use, but we bake in a trivial allocator and warn at runtime if used in ASSERTIONS logging.warning('function requested to be exported, but not implemented: "%s"', requested) diff --git a/tests/test_core.py b/tests/test_core.py index 550198a99..f42b0f67e 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -5982,20 +5982,22 @@ def process(filename): src = r''' #include #include + #include extern "C" { int other_function() { return 5; } } int main() { - printf("waka!\n"); + int x = EM_ASM_INT_V({ return Module._other_function() }); + printf("waka %d!\n", x); return 0; } ''' open('exps', 'w').write('["_main","_other_function"]') self.emcc_args += ['-s', 'EXPORTED_FUNCTIONS=@exps'] - self.do_run(src, '''waka!''') + self.do_run(src, '''waka 5!''') assert 'other_function' in open('src.cpp.o.js').read() def test_add_function(self):