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

Function parse_args

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

Source from the content-addressed store, hash-verified

74
75
76def parse_args():
77 parser = argparse.ArgumentParser(
78 description='Split a wasm file based on user paths',
79 epilog="""
80This is a wrapper for 'wasm-split --multi-split' functionality, so you should
81add wasm-split's command line options as well. You should or may want to add
82wasm-split options like -o (--output), --out-prefix, -g, and feature
83enabling/disabling options. Run 'wasm-split -h' for the list of options. But you
84should NOT add --manifest, because this will be generated from this script.
85""")
86 parser.add_argument('wasm', nargs='?', help='Path to the input wasm file')
87 parser.add_argument('paths_file', nargs='?', help='Path to the input file containing paths')
88 parser.add_argument('-s', '--sourcemap', help='Force source map file')
89 parser.add_argument('-v', '--verbose', action='store_true',
90 help='Print verbose info for debugging this script')
91 parser.add_argument('--wasm-split', help='Path to wasm-split executable')
92 parser.add_argument('--preserve-manifest', action='store_true',
93 help='Preserve generated manifest file. This sets --verbose too.')
94 parser.add_argument('--print-sources', action='store_true',
95 help='Print the list of sources in the source map to help figure out splitting boundaries. Does NOT perform the splitting.')
96
97 args, forwarded_args = parser.parse_known_args()
98 if args.preserve_manifest:
99 args.verbose = True
100 if not args.wasm_split:
101 args.wasm_split = utils.find_exe(building.get_binaryen_bin(), 'wasm-split')
102
103 if '--manifest' in forwarded_args:
104 parser.error('manifest file will be generated by this script and should not be given')
105
106 if args.print_sources:
107 if not args.wasm and not args.sourcemap:
108 parser.error('--print-sources requires either wasm or --sourcemap')
109 return args, forwarded_args
110
111 if not args.wasm and not args.paths_file:
112 parser.error("the following arguments are required: wasm, paths_file")
113 if not args.paths_file:
114 parser.error("the following arguments are required: paths_file")
115 if '-o' not in forwarded_args and '--output' not in forwarded_args:
116 parser.error('-o (--output) is required')
117 return args, forwarded_args
118
119
120def check_errors(args):

Callers 1

mainFunction · 0.70

Calls 1

errorMethod · 0.45

Tested by

no test coverage detected