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
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
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)
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)
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)