(args)
| 600 | |
| 601 | |
| 602 | def main(args): |
| 603 | options = parse_args(args) |
| 604 | |
| 605 | wasm_input = options.wasm |
| 606 | with open(wasm_input, 'rb') as infile: |
| 607 | wasm = infile.read() |
| 608 | |
| 609 | entries, func_ranges = read_dwarf_info(wasm_input, options) |
| 610 | |
| 611 | code_section_offset = get_code_section_offset(wasm) |
| 612 | |
| 613 | logger.debug('Saving to %s' % options.output) |
| 614 | map = build_sourcemap(entries, func_ranges, code_section_offset, options) |
| 615 | with open(options.output, 'w', encoding='utf-8') as outfile: |
| 616 | json.dump(map, outfile, separators=(',', ':'), ensure_ascii=False) |
| 617 | |
| 618 | if options.strip: |
| 619 | wasm = strip_debug_sections(wasm) |
| 620 | |
| 621 | if options.source_map_url: |
| 622 | wasm = append_source_mapping(wasm, options.source_map_url) |
| 623 | |
| 624 | if options.w: |
| 625 | logger.debug('Saving wasm to %s' % options.w) |
| 626 | with open(options.w, 'wb') as outfile: |
| 627 | outfile.write(wasm) |
| 628 | |
| 629 | logger.debug('Done') |
| 630 | return 0 |
| 631 | |
| 632 | |
| 633 | if __name__ == '__main__': |
no test coverage detected