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

Function normalize_args

tools/cmdline.py:803–823  ·  view source on GitHub ↗

Normalize argument that can be specific as either one or two arguments. In some cases these arguments are simply joined together. For example [`-o` `foo`] becomes `-ofoo` and [`-L` `bar`] becomes `-Lbar`. In other cases they are joined by an equals sign. For example ['--js-library`, `foo.j

(args)

Source from the content-addressed store, hash-verified

801
802
803def normalize_args(args):
804 """Normalize argument that can be specific as either one or two arguments.
805
806 In some cases these arguments are simply joined together. For example
807 [`-o` `foo`] becomes `-ofoo` and [`-L` `bar`] becomes `-Lbar`.
808
809 In other cases they are joined by an equals sign. For example ['--js-library`, `foo.js`]
810 becomes `--js-library=foo.js`.
811 """
812 equals_args = {'--js-library'}
813 join_args = {'-l', '-L', '-I', '-z', '-o', '-x', '-u'} | equals_args
814 for i in range(len(args)):
815 if args[i] in join_args:
816 if args[i] in equals_args:
817 args[i] += '='
818 if len(args) <= i + 1:
819 exit_with_error(f"option '{args[i]}' requires an argument")
820 args[i] += args[i + 1]
821 args[i + 1] = ''
822
823 return [a for a in args if a]
824
825
826@ToolchainProfiler.profile()

Callers 1

parse_argumentsFunction · 0.85

Calls 2

exit_with_errorFunction · 0.90
rangeFunction · 0.50

Tested by

no test coverage detected