diff options
-rwxr-xr-x | tests/runner.py | 22 | ||||
-rw-r--r-- | tools/shared.py | 7 |
2 files changed, 28 insertions, 1 deletions
diff --git a/tests/runner.py b/tests/runner.py index a6b90f8d..335d7d4b 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -8620,6 +8620,28 @@ def process(filename): shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgoed2.js')) assert open('pgoed.js').read() == open('pgoed2.js').read() + def test_exported_response(self): + if self.emcc_args is None: return self.skip('requires emcc') + + src = r''' + #include <stdio.h> + #include <stdlib.h> + + extern "C" { + int other_function() { return 5; } + } + + int main() { + printf("waka!\n"); + return 0; + } + ''' + open('exps', 'w').write('["_main","_other_function"]') + + self.emcc_args += ['-s', 'EXPORTED_FUNCTIONS=@exps'] + self.do_run(src, '''waka!''') + assert 'other_function' in open('src.cpp.o.js').read() + def test_add_function(self): if self.emcc_args is None: return self.skip('requires emcc') diff --git a/tools/shared.py b/tools/shared.py index 321fa073..dd448b31 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -631,6 +631,11 @@ def unique_ordered(values): # return a list of unique values in an input list, w return True return filter(check, values) +def expand_response(data): + if type(data) == str and data[0] == '@': + return json.loads(open(data[1:]).read()) + return data + # Settings. A global singleton. Not pretty, but nicer than passing |, settings| everywhere class Settings: @@ -1097,7 +1102,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e @staticmethod def get_safe_internalize(): - exports = ','.join(map(lambda exp: exp[1:], Settings.EXPORTED_FUNCTIONS)) + exports = ','.join(map(lambda exp: exp[1:], expand_response(Settings.EXPORTED_FUNCTIONS))) # internalize carefully, llvm 3.2 will remove even main if not told not to return ['-internalize', '-internalize-public-api-list=' + exports] |