示例#1
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()
示例#2
0
                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()


if __name__ == '__main__':
    main()
示例#3
0
def main():
    # global link, gccdir, gnatdir, verbose, create_common

    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-v', '--verbose', action="store_true",
        help="verbose output")
    parser.add_argument(
        '-l', '--link', action="store_true",
        help="use symlinks when installing files")
    parser.add_argument(
        '--gcc-dir', help='gcc sources dir')
    parser.add_argument(
        '--gnat-dir', help='gnat sources dir')
    parser.add_argument(
        '--output', help=(
            'installation location. By default the runtime descriptor is '
            'installed in <output>/lib/gnat while the sources are installed '
            'in <output>/include/rts-sources'))
    parser.add_argument(
        '--output-descriptor',
        help='installation location for the runtime sources descriptor')
    parser.add_argument(
        '--output-sources',
        help='installation location for the runtime sources tree')
    parser.add_argument(
        '--rts-profile', choices=['light', 'light-tasking', 'embedded'],
        required=True,  help='supported profiles')
    parser.add_argument(
        '--source-profile', choices=['bb', 'pikeos', 'vx7r2cert', 'qnx'],
        default='bb', help='platform specific source selections')

    args = parser.parse_args()

    if args.verbose:
        FilesHolder.verbose = True
    if args.link:
        FilesHolder.link = True
    if args.gcc_dir is not None:
        FilesHolder.gccdir = os.path.abspath(args.gcc_dir)
    if args.gnat_dir is not None:
        FilesHolder.gnatdir = os.path.abspath(args.gnat_dir)

    if args.output is not None:
        dest = os.path.abspath(args.output)
    else:
        dest = os.path.abspath('install')

    if args.output_descriptor is not None:
        dest_json = os.path.abspath(args.output_descriptor)
    else:
        dest_json = os.path.join(dest, 'lib', 'gnat', 'rts-sources.json')

    if args.output_sources is not None:
        dest_srcs = os.path.abspath(args.output_sources)
    else:
        dest_srcs = os.path.join(dest, 'include', 'rts-sources')

    if not os.path.exists(os.path.dirname(dest_json)):
        os.makedirs(os.path.dirname(dest_json))
    if not os.path.exists(dest_srcs):
        os.makedirs(dest_srcs)

    # Install the shared runtime sources
    SourceTree.dest_sources = dest_srcs

    # create the rts sources object. This uses a slightly different set
    # on pikeos.
    rts_srcs = SourceTree(
        sources=args.source_profile + "_srcs", profile=args.rts_profile,
        rts_sources=sources, rts_scenarios=all_scenarios)
    rts_srcs.install_tree(dest_json=dest_json, dest_sources=dest_srcs)