Exemplo n.º 1
0
    def do(cls, ws, args):
        '''Executes the build subcmd.'''
        ws_config = get_ws_config(get_ws_dir(args.root, ws))
        d = parse_manifest(args.root)

        # Validate.
        for project in args.projects:
            if project not in d:
                raise WSError('unknown project %s' % project)

        if len(args.projects) == 0:
            projects = d.keys()
        else:
            projects = args.projects

        # Build in reverse-dependency order.
        order = dependency_closure(d, projects)

        # Get all checksums; since this is a nop build bottle-neck, do it in
        # parallel. On my machine, this produces a ~20% speedup on a nop
        # "build-all".
        pool = multiprocessing.Pool(multiprocessing.cpu_count())
        src_dirs = [get_source_dir(args.root, d, proj) for proj in order]
        checksums = pool.map(calculate_checksum, src_dirs)

        for i, proj in enumerate(order):
            log('building %s' % proj)
            checksum = checksums[i]
            success = _build(args.root, ws, proj, d, checksum, ws_config,
                             args.force)
            if not success:
                raise WSError('%s build failed' % proj)
Exemplo n.º 2
0
def _force_clean(ws, proj):
    '''Performs a force-clean of a project, removing all files instead of
    politely calling the clean function of the underlying build system.'''
    build_dir = get_build_dir(ws, proj)
    log('removing %s' % build_dir)
    if dry_run():
        return
    try:
        rmtree(build_dir)
    except OSError as e:
        if e.errno == errno.ENOENT:
            log('%s already removed' % build_dir)
        else:
            raise

    config = get_ws_config(ws)
    config['projects'][proj]['taint'] = False
Exemplo n.º 3
0
Arquivo: config.py Projeto: rfrowe/ws
    def do(cls, ws, args):
        '''Executes the config command.'''
        config = get_ws_config(ws)
        if args.list:
            print(yaml.dump(config, default_flow_style=False), end='')
            return

        for arg in args.options:
            split = arg.split('=')
            split_len = len(split)
            key = split[0]
            if split_len == 1:
                val = None
            elif split_len == 2:
                val = split[1]
            else:
                val = '='.join(split[1:])

            project = args.project
            if project is not None:
                # Project-specific option.
                d = parse_manifest(args.root)
                if project not in d:
                    raise WSError('project "%s" not found' % project)

                can_taint = False
                if key == 'enable':
                    val = parse_bool_val(val)
                    can_taint = True
                elif key == 'args':
                    val = parse_build_args(val)
                    if val is None:
                        raise WSError('build args are not in the right format '
                                      '("args=key=val")')
                    can_taint = True
                else:
                    raise WSError('project key "%s" not found' % key)

                try:
                    proj_config = config['projects'][project]
                except KeyError:
                    proj_config = {}
                    config['projects'][project] = proj_config

                if can_taint and proj_config[key] != val:
                    log('tainting project %s' % project)
                    proj_config['taint'] = True

                proj_config[key] = val

            else:
                # Global option.
                if key == 'type':
                    if val is None or val not in BUILD_TYPES:
                        raise WSError('"type" key must be one of %s' %
                                      str(BUILD_TYPES))
                    if config[key] != val:
                        for proj_config in config['projects'].values():
                            proj_config['taint'] = True

                config[key] = val