예제 #1
0
파일: paths.py 프로젝트: codealchemy/pants
async def paths(console: Console,
                paths_subsystem: PathsSubsystem) -> PathsGoal:

    path_from = paths_subsystem.path_from
    path_to = paths_subsystem.path_to

    if path_from is None:
        raise ValueError("Must set --from")

    if path_to is None:
        raise ValueError("Must set --to")

    specs_parser = SpecsParser()

    from_tgts, to_tgts = await MultiGet([
        Get(Targets, Specs, specs_parser.parse_specs([path_from])),
        Get(Targets, Specs, specs_parser.parse_specs([path_to])),
    ])
    root = from_tgts.expect_single()
    destination = to_tgts.expect_single()

    transitive_targets = await Get(
        TransitiveTargets,
        TransitiveTargetsRequest([root.address],
                                 include_special_cased_deps=True))

    adjacent_targets_per_target = await MultiGet(
        Get(
            Targets,
            DependenciesRequest(tgt.get(Dependencies),
                                include_special_cased_deps=True),
        ) for tgt in transitive_targets.closure)

    transitive_targets_closure_addresses = (
        t.address for t in transitive_targets.closure)
    adjacency_lists = dict(
        zip(transitive_targets_closure_addresses, adjacent_targets_per_target))

    spec_paths = []
    for path in find_paths_breadth_first(adjacency_lists, root.address,
                                         destination.address):
        spec_path = [address.spec for address in path]
        spec_paths.append(spec_path)

    with paths_subsystem.output(console) as write_stdout:
        write_stdout(json.dumps(spec_paths, indent=2))

    return PathsGoal(exit_code=0)
예제 #2
0
async def parse_one_bsp_mapping(
        request: _ParseOneBSPMappingRequest) -> BSPBuildTargetInternal:
    specs_parser = SpecsParser()
    specs = specs_parser.parse_specs(
        request.definition.addresses,
        description_of_origin=f"the BSP mapping {request.name}",
        convert_dir_literal_to_address_literal=False,
    ).includes
    return BSPBuildTargetInternal(request.name, specs, request.definition)
예제 #3
0
async def paths(
    console: Console, paths_subsystem: PathsSubsystem, global_options: GlobalOptions
) -> PathsGoal:

    path_from = paths_subsystem.path_from
    path_to = paths_subsystem.path_to

    if path_from is None:
        raise ValueError("Must set --from")

    if path_to is None:
        raise ValueError("Must set --to")

    specs_parser = SpecsParser()

    convert_dir_literals = global_options.use_deprecated_directory_cli_args_semantics
    from_tgts, to_tgts = await MultiGet(
        Get(
            Targets,
            Specs,
            specs_parser.parse_specs(
                [path_from],
                description_of_origin="the option `--paths-from`",
                convert_dir_literal_to_address_literal=convert_dir_literals,
            ),
        ),
        Get(
            Targets,
            Specs,
            specs_parser.parse_specs(
                [path_to],
                description_of_origin="the option `--paths-to`",
                convert_dir_literal_to_address_literal=convert_dir_literals,
            ),
        ),
    )
    root = from_tgts.expect_single()
    destination = to_tgts.expect_single()

    transitive_targets = await Get(
        TransitiveTargets, TransitiveTargetsRequest([root.address], include_special_cased_deps=True)
    )

    adjacent_targets_per_target = await MultiGet(
        Get(
            Targets,
            DependenciesRequest(tgt.get(Dependencies), include_special_cased_deps=True),
        )
        for tgt in transitive_targets.closure
    )

    transitive_targets_closure_addresses = (t.address for t in transitive_targets.closure)
    adjacency_lists = dict(zip(transitive_targets_closure_addresses, adjacent_targets_per_target))

    spec_paths = []
    for path in find_paths_breadth_first(adjacency_lists, root.address, destination.address):
        spec_path = [address.spec for address in path]
        spec_paths.append(spec_path)

    with paths_subsystem.output(console) as write_stdout:
        write_stdout(json.dumps(spec_paths, indent=2))

    return PathsGoal(exit_code=0)
예제 #4
0
async def parse_one_bsp_mapping(
        request: _ParseOneBSPMappingRequest) -> BSPBuildTargetInternal:
    specs_parser = SpecsParser()
    specs = specs_parser.parse_specs(request.raw_specs)
    return BSPBuildTargetInternal(request.name, specs)