Skip to content

Commit d995dfa

Browse files
authored
Remove minification from struct_info.json (#12881)
This is extra option that seems to just add complexity and make the output file hard to read. This file is read only at link time and the cost of reading in those extra spaces surly can't be significant.
1 parent 4d97e34 commit d995dfa

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

emscripten.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ def generate_struct_info():
878878
def generate_struct_info():
879879
with ToolchainProfiler.profile_block('gen_struct_info'):
880880
out = shared.Cache.get_path(generated_struct_info_name)
881-
gen_struct_info.main(['-q', '-c', '-o', out])
881+
gen_struct_info.main(['-q', '-o', out])
882882
return out
883883

884884
shared.Settings.STRUCT_INFO = shared.Cache.get(generated_struct_info_name, generate_struct_info)

tools/gen_struct_info.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -459,16 +459,13 @@ def parse_json(path, header_files, structs, defines):
459459
defines[part[1]] = part[0]
460460

461461

462-
def output_json(obj, compressed=True, stream=None):
462+
def output_json(obj, stream=None):
463463
if stream is None:
464464
stream = sys.stdout
465465
elif isinstance(stream, str):
466466
stream = open(stream, 'w')
467467

468-
if compressed:
469-
json.dump(obj, stream, separators=(',', ':'))
470-
else:
471-
json.dump(obj, stream, indent=4, sort_keys=True)
468+
json.dump(obj, stream, indent=4, sort_keys=True)
472469

473470
stream.write('\n')
474471
stream.close()
@@ -497,8 +494,6 @@ def main(args):
497494
help='Don\'t output anything besides error messages.')
498495
parser.add_argument('-f', dest='list_fields', action='store_true', default=False,
499496
help='Output a list of structs and fields for the given headers.')
500-
parser.add_argument('-c', dest='pretty_print', action='store_false', default=True,
501-
help="Compress JSON output (don't pretty print)")
502497
parser.add_argument('-o', dest='output', metavar='path', default=None,
503498
help='Path to the JSON file that will be written. If omitted, the generated data will be printed to stdout.')
504499
parser.add_argument('-I', dest='includes', metavar='dir', action='append', default=[],
@@ -533,7 +528,7 @@ def main(args):
533528
else:
534529
data.append(parse_header(path, cpp_opts))
535530

536-
output_json(data, not args.pretty_print, args.output)
531+
output_json(data, args.output)
537532
return 0
538533

539534
# Look for structs in all passed headers.
@@ -554,7 +549,7 @@ def main(args):
554549

555550
# Inspect all collected structs.
556551
struct_info = inspect_code(header_files, cpp_opts, structs, defines)
557-
output_json(struct_info, not args.pretty_print, args.output)
552+
output_json(struct_info, args.output)
558553
return 0
559554

560555

0 commit comments

Comments
 (0)