@@ -445,6 +445,17 @@ def __str__(self):
445
445
def benchmark_methods (self ):
446
446
return benchmark_methods
447
447
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
+
448
459
def build (self ):
449
460
source_dir = self .subject .getSourceDir ()
450
461
output_dir = self .subject .getOutputDir ()
@@ -469,8 +480,6 @@ def build(self):
469
480
if hasattr (self .project , "includeset" ):
470
481
include_flags = ["-I" , os .path .join (_suite .dir , "includes" , self .project .includeset )]
471
482
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 ("'" , "\" " ) + "" ]
474
483
subdir_program_names = defaultdict (lambda : [])
475
484
for root , filename in self .subject .getProgramSources ():
476
485
if filename .startswith ("_" ):
@@ -502,9 +511,13 @@ def build(self):
502
511
# Step 1: build the .wasm binary.
503
512
if mustRebuild :
504
513
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 ("'" , "\" " ) + "" ]
505
518
# This generates both a js file and a wasm file.
506
519
# 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
508
521
if mx .run (build_cmd_line , nonZeroIsFatal = False ) != 0 :
509
522
mx .abort ("Could not build the wasm-only output of " + filename + " with emcc." )
510
523
elif filename .endswith (".wat" ):
0 commit comments