def main(): """Entry Point""" version = "0.3.11" # Parser handling parser = argparse.ArgumentParser(description="Memory Map File Analyser for ARM mbed\nversion %s" % version) parser.add_argument("file", type=argparse_filestring_type, help="memory map file") parser.add_argument( "-t", "--toolchain", dest="toolchain", help="select a toolchain used to build the memory map file (%s)" % ", ".join(MemapParser.toolchains), required=True, type=argparse_uppercase_type(MemapParser.toolchains, "toolchain"), ) parser.add_argument("-o", "--output", help="output file name", required=False) parser.add_argument( "-e", "--export", dest="export", required=False, default="table", type=argparse_lowercase_hyphen_type(MemapParser.export_formats, "export format"), help="export format (examples: %s: default)" % ", ".join(MemapParser.export_formats), ) parser.add_argument("-v", "--version", action="version", version=version) # Parse/run command if len(sys.argv) <= 1: parser.print_help() sys.exit(1) args = parser.parse_args() # Create memap object memap = MemapParser() # Parse and decode a map file if args.file and args.toolchain: if memap.parse(args.file, args.toolchain) is False: sys.exit(0) # Write output in file if args.output != None: memap.generate_output(args.export, args.output) else: # Write output in screen memap.generate_output(args.export) sys.exit(0)
def main(): """Entry Point""" version = '0.4.0' # Parser handling parser = ArgumentParser( description="Memory Map File Analyser for ARM mbed\nversion %s" % version) parser.add_argument('file', type=argparse_filestring_type, help='memory map file') parser.add_argument( '-t', '--toolchain', dest='toolchain', help='select a toolchain used to build the memory map file (%s)' % ", ".join(MemapParser.toolchains), required=True, type=argparse_uppercase_type(MemapParser.toolchains, "toolchain")) parser.add_argument('-d', '--depth', dest='depth', type=int, help='specify directory depth level to display report', required=False) parser.add_argument('-o', '--output', help='output file name', required=False) parser.add_argument('-e', '--export', dest='export', required=False, default='table', type=argparse_lowercase_hyphen_type( MemapParser.export_formats, 'export format'), help="export format (examples: %s: default)" % ", ".join(MemapParser.export_formats)) parser.add_argument('-v', '--version', action='version', version=version) # Parse/run command if len(argv) <= 1: parser.print_help() exit(1) args = parser.parse_args() # Create memap object memap = MemapParser() # Parse and decode a map file if args.file and args.toolchain: if memap.parse(args.file, args.toolchain) is False: exit(0) if args.depth is None: depth = 2 # default depth level else: depth = args.depth returned_string = None # Write output in file if args.output != None: returned_string = memap.generate_output(args.export, \ depth, args.output) else: # Write output in screen returned_string = memap.generate_output(args.export, depth) if args.export == 'table' and returned_string: print(returned_string) exit(0)
def main(): """Entry Point""" version = '0.3.11' # Parser handling parser = argparse.ArgumentParser( description="Memory Map File Analyser for ARM mbed\nversion %s" % version) parser.add_argument('file', type=argparse_filestring_type, help='memory map file') parser.add_argument( '-t', '--toolchain', dest='toolchain', help='select a toolchain used to build the memory map file (%s)' % ", ".join(MemapParser.toolchains), required=True, type=argparse_uppercase_type(MemapParser.toolchains, "toolchain")) parser.add_argument('-o', '--output', help='output file name', required=False) parser.add_argument('-e', '--export', dest='export', required=False, default='table', type=argparse_lowercase_hyphen_type( MemapParser.export_formats, 'export format'), help="export format (examples: %s: default)" % ", ".join(MemapParser.export_formats)) parser.add_argument('-v', '--version', action='version', version=version) # Parse/run command if len(sys.argv) <= 1: parser.print_help() sys.exit(1) args = parser.parse_args() # Create memap object memap = MemapParser() # Parse and decode a map file if args.file and args.toolchain: if memap.parse(args.file, args.toolchain) is False: sys.exit(0) # Write output in file if args.output != None: memap.generate_output(args.export, args.output) else: # Write output in screen memap.generate_output(args.export) sys.exit(0)