@@ -445,6 +445,17 @@ def __str__(self):
445445 def benchmark_methods (self ):
446446 return benchmark_methods
447447
448+ def test_methods (self , opts_path ):
449+ if not os .path .isfile (opts_path ):
450+ return []
451+ with open (opts_path ) as opts_file :
452+ for line in opts_file :
453+ line = line .strip ()
454+ if line .startswith ("entry-point" ):
455+ _ , value = line .split ("=" , 1 )
456+ return ['_' + value .strip ()]
457+ return []
458+
448459 def build (self ):
449460 source_dir = self .subject .getSourceDir ()
450461 output_dir = self .subject .getOutputDir ()
@@ -469,8 +480,6 @@ def build(self):
469480 if hasattr (self .project , "includeset" ):
470481 include_flags = ["-I" , os .path .join (_suite .dir , "includes" , self .project .includeset )]
471482 emcc_flags = ["-s" , "STANDALONE_WASM" , "-s" , "WASM_BIGINT" ] + cc_flags
472- if self .project .isBenchmarkProject ():
473- emcc_flags = emcc_flags + ["-s" , "EXPORTED_FUNCTIONS=" + str (self .benchmark_methods ()).replace ("'" , "\" " ) + "" ]
474483 subdir_program_names = defaultdict (lambda : [])
475484 for root , filename in self .subject .getProgramSources ():
476485 if filename .startswith ("_" ):
@@ -502,9 +511,13 @@ def build(self):
502511 # Step 1: build the .wasm binary.
503512 if mustRebuild :
504513 if filename .endswith (".c" ):
514+ if self .project .isBenchmarkProject ():
515+ emcc_export_flags = ["-s" , "EXPORTED_FUNCTIONS=" + str (self .benchmark_methods ()).replace ("'" , "\" " ) + "" ]
516+ else :
517+ emcc_export_flags = ["-s" , "EXPORTED_FUNCTIONS=" + str (self .test_methods (os .path .join (root , basename + ".opts" ))).replace ("'" , "\" " ) + "" ]
505518 # This generates both a js file and a wasm file.
506519 # See https://github.com/emscripten-core/emscripten/wiki/WebAssembly-Standalone
507- build_cmd_line = [emcc_cmd ] + emcc_flags + source_cc_flags + [source_path , "-o" , output_js_path ] + include_flags
520+ build_cmd_line = [emcc_cmd ] + emcc_flags + emcc_export_flags + source_cc_flags + [source_path , "-o" , output_js_path ] + include_flags
508521 if mx .run (build_cmd_line , nonZeroIsFatal = False ) != 0 :
509522 mx .abort ("Could not build the wasm-only output of " + filename + " with emcc." )
510523 elif filename .endswith (".wat" ):
0 commit comments