Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
0
def get_default_options_parser(add_clean=True,
                               add_options=True,
                               add_app_config=False):
    """Create a new options parser with the default compiler options added

    Keyword arguments:
    add_clean - add the clean argument?
    add_options - add the options argument?
    """
    parser = ArgumentParser()

    targetnames = TARGET_NAMES
    targetnames.sort()
    toolchainlist = list(TOOLCHAINS)
    toolchainlist.sort()

    parser.add_argument(
        "-m",
        "--mcu",
        help=("build for the given MCU (%s)" % ', '.join(targetnames)),
        metavar="MCU",
        type=argparse_many(argparse_force_uppercase_type(targetnames, "MCU")))

    parser.add_argument("-t",
                        "--tool",
                        help=("build using the given TOOLCHAIN (%s)" %
                              ', '.join(toolchainlist)),
                        metavar="TOOLCHAIN",
                        type=argparse_many(
                            argparse_force_uppercase_type(
                                toolchainlist, "toolchain")))

    parser.add_argument("--color",
                        help="print Warnings, and Errors in color",
                        action="store_true",
                        default=False)

    parser.add_argument("--cflags",
                        default=[],
                        action="append",
                        help="Extra flags to provide to the C compiler")

    parser.add_argument("--asmflags",
                        default=[],
                        action="append",
                        help="Extra flags to provide to the assembler")

    parser.add_argument("--ldflags",
                        default=[],
                        action="append",
                        help="Extra flags to provide to the linker")

    if add_clean:
        parser.add_argument("-c",
                            "--clean",
                            action="store_true",
                            default=False,
                            help="clean the build directory")

    if add_options:
        parser.add_argument(
            "-o",
            "--options",
            action="append",
            help=('Add a build argument ("save-asm": save the '
                  'asm generated by the compiler, "debug-info":'
                  ' generate debugging information, "analyze": '
                  'run Goanna static code analyzer")'),
            type=argparse_lowercase_hyphen_type(
                ['save-asm', 'debug-info', 'analyze', 'small-lib', 'std-lib'],
                "build option"))

    if add_app_config:
        parser.add_argument(
            "--app-config",
            default=None,
            dest="app_config",
            type=argparse_filestring_type,
            help=
            "Path of an app configuration file (Default is to look for 'mbed_app.json')"
        )

    return parser
Esempio n. 5
0
def get_default_options_parser(add_clean=True, add_options=True):
    """Create a new options parser with the default compiler options added

    Keyword arguments:
    add_clean - add the clean argument?
    add_options - add the options argument?
    """
    parser = ArgumentParser()

    targetnames = TARGET_NAMES
    targetnames.sort()
    toolchainlist = list(TOOLCHAINS)
    toolchainlist.sort()

    parser.add_argument("-m", "--mcu",
                        help=("build for the given MCU (%s)" %
                              ', '.join(targetnames)),
                        metavar="MCU",
                        type=argparse_many(
                            argparse_force_uppercase_type(
                                targetnames, "MCU")))

    parser.add_argument("-t", "--tool",
                        help=("build using the given TOOLCHAIN (%s)" %
                              ', '.join(toolchainlist)),
                        metavar="TOOLCHAIN",
                        type=argparse_many(
                            argparse_force_uppercase_type(
                                toolchainlist, "toolchain")))

    parser.add_argument("--color",
                        help="print Warnings, and Errors in color",
                        action="store_true", default=False)

    parser.add_argument("--cflags", default=[], action="append",
                        help="Extra flags to provide to the C compiler")

    parser.add_argument("--asmflags", default=[], action="append",
                        help="Extra flags to provide to the assembler")

    parser.add_argument("--ldflags", default=[], action="append",
                        help="Extra flags to provide to the linker")

    if add_clean:
        parser.add_argument("-c", "--clean", action="store_true", default=False,
                            help="clean the build directory")

    if add_options:
        parser.add_argument("-o", "--options", action="append",
                            help=('Add a build argument ("save-asm": save the '
                                  'asm generated by the compiler, "debug-info":'
                                  ' generate debugging information, "analyze": '
                                  'run Goanna static code analyzer")'),
                            type=argparse_lowercase_hyphen_type(['save-asm',
                                                                 'debug-info',
                                                                 'analyze',
                                                                 'small-lib',
                                                                 'std-lib'],
                                                                "build option"))

    return parser