예제 #1
0
파일: graph.py 프로젝트: Gointer/pants
  def _index(self, roots):
    """Index from the given roots into the storage provided by the base class.

    This is an additive operation: any existing connections involving these nodes are preserved.
    """
    addresses = set()
    # Index the ProductGraph.
    # TODO: It's not very common to actually use the dependencies of a Node during a walk... should
    # consider removing those from that API.
    for ((node, state), _) in self._graph.walk(roots=roots):
      # Locate nodes that contain LegacyBuildGraphNode values.
      if type(state) is Throw:
        raise AddressLookupError(
            'Build graph construction failed for {}:\n  {}'.format(node.subject, state.exc))
      elif type(state) is not Return:
        State.raise_unrecognized(state)
      if node.product is not LegacyBuildGraphNode:
        continue
      if type(node) is not SelectNode:
        continue

      # We have a successfully parsed a LegacyBuildGraphNode.
      target_adaptor = state.value.target_adaptor
      address = target_adaptor.address
      addresses.add(address)
      if address not in self._target_by_address:
        self._target_by_address[address] = self._instantiate_target(target_adaptor)
      dependencies = state.value.dependency_addresses
      self._target_dependencies_by_address[address] = dependencies
      for dependency in dependencies:
        self._target_dependees_by_address[dependency].add(address)
    return addresses
예제 #2
0
    def _index(self, roots):
        """Index from the given roots into the storage provided by the base class.

    This is an additive operation: any existing connections involving these nodes are preserved.
    """
        addresses = set()
        # Index the ProductGraph.
        # TODO: It's not very common to actually use the dependencies of a Node during a walk... should
        # consider removing those from that API.
        for ((node, state), _) in self._graph.walk(roots=roots):
            # Locate nodes that contain LegacyBuildGraphNode values.
            if type(state) is Throw:
                raise AddressLookupError(
                    'Build graph construction failed for {}:\n  {}'.format(
                        node.subject, state.exc))
            elif type(state) is not Return:
                State.raise_unrecognized(state)
            if node.product is not LegacyBuildGraphNode:
                continue
            if type(node) is not SelectNode:
                continue

            # We have a successfully parsed a LegacyBuildGraphNode.
            target_adaptor = state.value.target_adaptor
            address = target_adaptor.address
            addresses.add(address)
            if address not in self._target_by_address:
                self._target_by_address[address] = self._instantiate_target(
                    target_adaptor)
            dependencies = state.value.dependency_addresses
            self._target_dependencies_by_address[address] = dependencies
            for dependency in dependencies:
                self._target_dependees_by_address[dependency].add(address)
        return addresses
예제 #3
0
파일: commands.py 프로젝트: cheister/pants
def list():
  """Lists all addresses under the current build root."""

  build_root = get_buildroot()
  symbol_table_cls = LegacyTable
  address_mapper = AddressMapper(symbol_table_cls=symbol_table_cls,
                                 parser_cls=LegacyPythonCallbacksParser)

  # Create a Scheduler containing only the graph tasks, with a single installed goal that
  # requests an Address.
  goal = 'list'
  tasks = create_fs_tasks(build_root) + create_graph_tasks(address_mapper, symbol_table_cls)
  scheduler = LocalScheduler({goal: Address}, symbol_table_cls, tasks)

  # Execute a request for the root.
  build_request = BuildRequest(goals=[goal], subjects=[DescendantAddresses('')])
  result = LocalSerialEngine(scheduler).execute(build_request)
  if result.error:
    raise result.error

  # Render the output.
  for state in result.root_products.values():
    if type(state) is Throw:
      raise state.exc
    elif type(state) is not Return:
      State.raise_unrecognized(dep_state)
    for address in state.value:
      print(address)
예제 #4
0
파일: scheduler.py 프로젝트: Gointer/pants
 def update_state(self, node, state):
   """Updates the Node with the given State."""
   if type(state) in [Return, Throw, Noop]:
     self._set_state(node, state)
   elif type(state) is Waiting:
     self._add_dependencies(node, state.dependencies)
   else:
     raise State.raise_unrecognized(state)
예제 #5
0
파일: scheduler.py 프로젝트: Gointer/pants
 def update_state(self, node, state):
     """Updates the Node with the given State."""
     if type(state) in [Return, Throw, Noop]:
         self._set_state(node, state)
     elif type(state) is Waiting:
         self._add_dependencies(node, state.dependencies)
     else:
         raise State.raise_unrecognized(state)
예제 #6
0
파일: scheduler.py 프로젝트: jayantak/pants
  def update_state(self, node, state):
    """Updates the Node with the given State, creating any Nodes which do not already exist."""
    entry = self._ensure_entry(node)
    if entry.state is not None:
      raise ValueError('Node {} is already completed:\n  {}\n  {}'
                       .format(node, entry.state, state))

    if type(state) in [Return, Throw, Noop]:
      entry.state = state
    elif type(state) is Waiting:
      self._add_dependencies(entry, state.dependencies)
    else:
      raise State.raise_unrecognized(state)