Пример #1
0
def main():
    parser = argparse.ArgumentParser()

    parser.add_argument(
        '-v', '--verbose', action="store_true",
        help='Verbose output')
    parser.add_argument(
        '-f', '--force', action="store_true",
        help=('Forces the installation by overwriting '
              'any pre-existing runtime.'))
    parser.add_argument(
        '--rts-src-descriptor',
        help='The runtime source descriptor file (rts-sources.json)')
    parser.add_argument(
        '--gen-doc', action="store_true",
        help='Generate the documentation')
    parser.add_argument(
        '-o', '--output', default='install',
        help='Where built runtimes will be installed')
    parser.add_argument(
        '-l', '--link', action="store_true",
        help="Use symlinks instead of copies when installing")
    parser.add_argument(
        '-b', '--build', action="store_true",
        help="Build the runtimes")
    parser.add_argument(
        '--build-flags', help="Flags passed to gprbuild")
    parser.add_argument(
        'target', nargs='+',
        help='List of target boards to generate runtimes for')
    args = parser.parse_args()

    if args.verbose:
        FilesHolder.verbose = True
    if args.link:
        FilesHolder.link = True
    if args.force:
        Installer.overwrite = True

    boards = []

    for arg in args.target:
        board = build_configs(arg)
        boards.append(board)

    dest = os.path.abspath(args.output)
    if not os.path.exists(dest):
        os.makedirs(dest)

    # README file generation
    if args.gen_doc:
        # figure out the target
        target = boards[0].target
        for board in boards:
            assert target == board.target, \
                "cannot generate rts doc for different compiler targets"

        doc_dir = os.path.join(dest, 'doc')
        docgen(boards, target, doc_dir)
        # and do nothing else
        return

    if not os.path.exists(dest):
        os.makedirs(dest)

    # Install the runtimes sources
    projects = []
    for board in boards:
        print("install runtime sources for %s" % board.name)
        sys.stdout.flush()
        installer = Installer(board)
        projects += installer.install(
            dest, rts_descriptor=args.rts_src_descriptor)

    # and build them
    if args.build:
        for prj in projects:
            print("building project %s" % prj)
            sys.stdout.flush()
            cmd = ['gprbuild', '-j0', '-p', '-v', '-P', prj]
            if args.build_flags is not None:
                cmd += args.build_flags.split()
            subprocess.check_call(cmd)
            # Post-process: remove build artifacts from obj directory
            cleanup_ext = ('.o', '.ali', '.stdout', '.stderr', '.d', '.lexch')
            obj_dir = os.path.join(os.path.dirname(prj), 'obj')
            for fname in os.listdir(obj_dir):
                _, ext = os.path.splitext(fname)
                if ext in cleanup_ext:
                    os.unlink(os.path.join(obj_dir, fname))

    print("runtimes successfully installed in %s" % dest)
Пример #2
0
    # README file generation
    if gen_doc:
        doc_dir = os.path.join(dest, 'doc')
        docgen(boards, target, doc_dir)
        # and do nothing else
        return

    # default paths in case not specified from the command-line:
    if dest_bsps is None:
        dest_bsps = os.path.join(dest, 'BSPs')
    if not os.path.exists(dest_bsps):
        os.makedirs(dest_bsps)

    # Install the BSPs
    for board in boards:
        install = Installer(board)
        install.install(dest_bsps, prefix)

    # post-processing, install ada_object_path and ada_source_path to be
    # installed in all runtimes by gprinstall
    bsp_support = os.path.join(dest_bsps, 'support')
    if not os.path.exists(bsp_support):
        os.mkdir(bsp_support)
        with open(os.path.join(bsp_support, 'ada_source_path'), 'w') as fp:
            fp.write('gnat\ngnarl\n')
        with open(os.path.join(bsp_support, 'ada_object_path'), 'w') as fp:
            fp.write('adalib\n')

    if gen_rts_srcs:
        assert target is not None, \
            "cannot generate rts sources for mixed cross compilers"
Пример #3
0
def main():
    # global link, gccdir, gnatdir, verbose, create_common

    dest = "install"
    dest_bsps = None
    dest_prjs = None
    dest_srcs = None
    prefix = None
    gen_rts_srcs = True
    gen_doc = False

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hvl", [
            "help", "verbose", "bsps-only", "gen-doc", "output=",
            "output-bsps=", "output-prjs=", "output-srcs=", "prefix=",
            "gcc-dir=", "gnat-dir=", "link"
        ])
    except getopt.GetoptError as e:
        print("error: " + str(e))
        print("")
        usage()
        sys.exit(2)
    for opt, arg in opts:
        if opt in ("-v", "--verbose"):
            FilesHolder.verbose = True
        elif opt in ("-h", "--help"):
            usage()
            sys.exit()
        elif opt in ("-l", "--link"):
            FilesHolder.link = True
        elif opt == "--output":
            dest = arg
        elif opt == "--output-bsps":
            dest_bsps = arg
        elif opt == "--output-prjs":
            dest_prjs = arg
        elif opt == "--output-srcs":
            dest_srcs = arg
        elif opt == "--gcc-dir":
            FilesHolder.gccdir = arg
        elif opt == "--gnat-dir":
            FilesHolder.gnatdir = arg
        elif opt == "--prefix":
            prefix = arg
        elif opt == "--bsps-only":
            gen_rts_srcs = False
        elif opt == "--gen-doc":
            gen_doc = True
        else:
            print("unexpected switch: %s" % opt)
            sys.exit(2)

    if len(args) < 1:
        print("error: missing configuration")
        print("")
        usage()
        sys.exit(2)

    boards = []

    for arg in args:
        board = build_configs(arg)
        boards.append(board)

    # figure out the target
    target = boards[0].target
    if target is None:
        target = "native"
    for board in boards:
        if board.target is None and target == "native":
            continue
        if board.target != target:
            target = None

    dest = os.path.abspath(dest)
    if not os.path.exists(dest):
        os.makedirs(dest)

    # README file generation
    if gen_doc:
        doc_dir = os.path.join(dest, 'doc')
        docgen(boards, target, doc_dir)
        # and do nothing else
        return

    # default paths in case not specified from the command-line:
    if dest_bsps is None:
        dest_bsps = os.path.join(dest, 'BSPs')
    if not os.path.exists(dest_bsps):
        os.makedirs(dest_bsps)

    # Install the BSPs
    for board in boards:
        install = Installer(board)
        install.install(dest_bsps, prefix)

    # post-processing, install ada_object_path and ada_source_path to be
    # installed in all runtimes by gprinstall
    bsp_support = os.path.join(dest_bsps, 'support')
    if not os.path.exists(bsp_support):
        os.mkdir(bsp_support)
        with open(os.path.join(bsp_support, 'ada_source_path'), 'w') as fp:
            fp.write('gnat\ngnarl\n')
        with open(os.path.join(bsp_support, 'ada_object_path'), 'w') as fp:
            fp.write('adalib\n')

    if gen_rts_srcs:
        assert target is not None, \
            "cannot generate rts sources for mixed cross compilers"
        is_pikeos = target is not None and 'pikeos' in target

        # determining what runtime sources we need:
        # - 'pikeos': all profiles, and a specific rts sources organisation
        # - 'ravenscar-full': all profiles support
        # - 'ravenscar-sfp': sfp + zfp profiles support
        # - 'zfp': just zfp support

        if is_pikeos:
            rts_profile = 'ravenscar-full'
        else:
            rts_profile = 'zfp'

            for board in boards:
                if 'ravenscar-full' in board.system_ads:
                    # install everything
                    rts_profile = 'ravenscar-full'
                    break
                else:
                    for rts in board.system_ads:
                        if 'ravenscar-' in rts:
                            rts_profile = 'ravenscar-sfp'

        # Compute rts sources subdirectories

        if dest_prjs is None:
            dest_prjs = os.path.join(dest, 'lib', 'gnat')
        if dest_srcs is None:
            dest_srcs = os.path.join(dest, 'include', 'rts-sources')
        if not os.path.exists(dest_prjs):
            os.makedirs(dest_prjs)
        if not os.path.exists(dest_srcs):
            os.makedirs(dest_srcs)

        # Install the shared runtime sources
        SourceTree.dest_sources = dest_srcs
        SourceTree.dest_prjs = dest_prjs

        # create the rts sources object. This uses a slightly different set
        # on pikeos.
        rts_srcs = SourceTree(is_bb=not is_pikeos,
                              profile=rts_profile,
                              rts_sources=sources,
                              rts_scenarios=all_scenarios)
        rts_srcs.install()