MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / main

Function main

tools/empath-split.py:303–360  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

301
302
303def main():
304 args, forwarded_args = parse_args()
305 check_errors(args)
306
307 sourcemap = get_sourceMappingURL(args.wasm, args.sourcemap)
308 if args.print_sources:
309 print_sources(sourcemap)
310 return
311
312 content = utils.read_file(args.paths_file)
313 module_to_paths = parse_paths_file(content)
314
315 # Compute {path: list of functions} map
316 all_paths = []
317 for paths in module_to_paths.values():
318 all_paths.extend(paths)
319 path_to_funcs = get_path_to_functions_map(args.wasm, sourcemap, all_paths)
320
321 # Write .manifest file
322 f = tempfile.NamedTemporaryFile(suffix=".manifest", mode='w', encoding='utf-8', delete=False)
323 manifest = f.name
324 try:
325 for i, (module, paths) in enumerate(module_to_paths.items()):
326 if i != 0: # Unless we are the first entry add a newline separator
327 f.write('\n')
328 funcs = []
329 for path in paths:
330 if not path_to_funcs[path]:
331 diagnostics.warn(f'{path} does not match any functions')
332 funcs += path_to_funcs[path]
333 if not funcs:
334 diagnostics.warn(f"Module '{module}' does not match any functions")
335
336 if args.verbose:
337 print(f'{module}: {len(funcs)} functions')
338 for path in paths:
339 if path in path_to_funcs:
340 print(f' {path}: {len(path_to_funcs[path])} functions')
341 for func in path_to_funcs[path]:
342 print(' ' + func)
343 print()
344
345 f.write(f'{module}:\n')
346 for func in funcs:
347 f.write(func + '\n')
348 f.close()
349
350 cmd = [args.wasm_split, '--multi-split', args.wasm, '--manifest', manifest]
351 if args.verbose:
352 # This option is used both in this script and wasm-split
353 cmd.append('-v')
354 cmd += forwarded_args
355 if args.verbose:
356 print('\n' + ' '.join(cmd))
357 utils.run_process(cmd)
358 finally:
359 if not args.preserve_manifest:
360 os.remove(manifest)

Callers 1

empath-split.pyFile · 0.70

Calls 14

check_errorsFunction · 0.85
get_sourceMappingURLFunction · 0.85
print_sourcesFunction · 0.85
parse_paths_fileFunction · 0.85
extendMethod · 0.80
appendMethod · 0.80
run_processMethod · 0.80
parse_argsFunction · 0.70
printFunction · 0.70
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected