コード例 #1
0
    def _project_from_path(path='.', name_hint=None):
        path = os.path.abspath(path)
        project_config = None
        project_config_file = os.path.join(path, "builder.json")
        if os.path.exists(project_config_file):
            import json
            with open(project_config_file, 'r') as config_fp:
                try:
                    project_config = json.load(config_fp)
                except Exception as e:
                    print("Failed to parse config file", project_config_file,
                          e)
                    sys.exit(1)

                if name_hint == None or project_config.get('name',
                                                           None) == name_hint:
                    print('    Found project: {} at {}'.format(
                        project_config['name'], path))
                    project = Project._create_project(**project_config,
                                                      path=path)
                    return Project._cache_project(project)

        # load any builder scripts and check them
        Scripts.load()
        # only construct a new instance of the class if there isn't one already in the cache
        if name_hint and name_hint.lower() not in Project._projects:
            project_cls = Project._find_project_class(name_hint)
            if project_cls:
                project = project_cls(
                    name=name_hint,
                    path=path if os.path.basename(path) == name_hint else None)
                return Project._cache_project(project)

        return None
コード例 #2
0
    def find_import(name, hints=[]):
        imp = Project._projects.get(name.lower(), None)
        if imp and imp.resolved():
            return imp

        for h in hints:
            Scripts.load(h)
        imp_cls = Project._find_import_class(name)
        if imp_cls:
            return Project._cache_project(imp_cls())
        return Import(name=name, resolved=False)
コード例 #3
0
    def _cache_project(project):
        Project._projects[project.name.lower()] = project
        if getattr(project, 'path', None):
            Scripts.load(project.path)

        return project
コード例 #4
0
    if spec.target == current_os() and spec.arch == current_arch():
        inspect_host(spec)
    if args.command == 'inspect':
        sys.exit(0)

    # set up environment
    env = Env({
        'dryrun': args.dry_run,
        'args': args,
        'project': args.project,
        'branch': args.branch,
        'spec': spec,
    })

    Scripts.load()

    if not env.project and args.command != 'mirror':
        print('No project specified and no project found in current directory')
        sys.exit(1)

    print('Using Spec:')
    print('  Host: {} {}'.format(spec.host, current_arch()))
    print('  Target: {} {}'.format(spec.target, spec.arch))
    print('  Compiler: {} {}'.format(spec.compiler, spec.compiler_version))

    if not env.config.get('enabled', True):
        raise Exception("The project is disabled in this configuration")

    if env.config.get('needs_compiler', True):
        env.toolchain = Toolchain(spec=env.spec)