Construct and return a `BuildGraph` given a set of input specs.

    :param TargetRoots target_roots: The targets root of the request.
    :param string build_root: The build root.
    :returns: A tuple of (BuildGraph, AddressMapper).
779480
def create_build_graph(self, target_roots, build_root=None):
    
    logger.debug('target_roots are: %r', target_roots)
    graph = LegacyBuildGraph.create(self.scheduler_session, self.build_file_aliases)
    logger.debug('build_graph is: %s', graph)
    # Ensure the entire generator is unrolled.
    for _ in graph.inject_roots_closure(target_roots):
      pass

    address_mapper = LegacyAddressMapper(self.scheduler_session, build_root or get_buildroot())
    logger.debug('address_mapper is: %s', address_mapper)
    return graph, address_mapper
1194935
def build_tree(requester)
      root_node = build_root_node(requester)
      # Search out the implementations directory structure for endpoints
      if defined?(self.implementation_root)
        # For each endpoints directory, recurse down it to load the modules
        endpoints_directories.each do |endpoints_directories|
          Dir["#{endpoints_directories}/**/*.rb"].each { |f| require(f) }
        end
        build_node_children(self.endpoints_module, root_node, requester)
      end
      root_node
    end
1348439
def build(self):
        ''''''
        # right now we do not worry about status of nodes
        # connecting the output to the input of other nodes
        #
        # NOTE: This is implemented in the least efficient way just for
        # testing. It has to be re-implemented.
        #
        # refer to http://stackoverflow.com/questions/33494376/networkx-add-edges-to-graph-from-node-attributes
        #
        # several cases triggers dependency.
        if 'DAG' in env.config['SOS_DEBUG'] or 'ALL' in env.config['SOS_DEBUG']:
            env.log_to_file('DAG', 'build DAG')
        for wf in range(self._forward_workflow_id + 1):
            indexed = [x for x in self.nodes() if x._wf_index == wf]
            indexed.sort(key=lambda x: x._node_index)

            for idx, node in enumerate(indexed):
                # 1. if a node changes context (using option alias), all later steps
                # has to rely on it.
                if node._context['__changed_vars__']:
                    for later_node in indexed[idx + 1:]:
                        if node._context['__changed_vars__'] & (
                                later_node._context['__signature_vars__']
                                | later_node._context['__environ_vars__']):
                            self.add_edge(node, later_node)

                # 2. if the input of a step is undetermined, it has to be executed
                # after all its previous steps.
                if not node._input_targets.valid() and idx > 0:
                    # if there is some input specified, it does not use default
                    # input, so the relationship can be further looked before
                    if node._input_targets.undetermined():
                        # if the input is dynamic, has to rely on previous step...
                        if 'dynamic' in node._context['__environ_vars__']:
                            self.add_edge(indexed[idx - 1], node)
                        else:
                            # otherwise let us look back.
                            for prev_node in indexed[idx - 1::-1]:
                                if node._context[
                                        '__environ_vars__'] & prev_node._context[
                                            '__changed_vars__']:
                                    self.add_edge(prev_node, node)
                    else:
                        self.add_edge(indexed[idx - 1], node)
        #
        # 3. if the input of a step depends on the output of another step
        for target, in_node in self._all_depends_files.items():
            if target not in self._all_output_files:
                continue
            # it is possible that multiple nodes satisfy the same target
            out_node = self._all_output_files[target]
            for i in in_node:
                for j in out_node:
                    if j != i:
                        self.add_edge(j, i)
        self.mark_dirty()
839438
def _POInitBuilderWrapper(env, target=None, source=_null, **kw):
  
  if source is _null:
    if 'POTDOMAIN' in kw:
      domain = kw['POTDOMAIN']
    elif 'POTDOMAIN' in env:
      domain = env['POTDOMAIN']
    else:
      domain = 'messages'
    source = [ domain ] # NOTE: Suffix shall be appended automatically
  return env._POInitBuilder(target, source, **kw)
420645
def _buildGraph(self):
        
        for n in self.namespaces:
            self.rdflib_graph.bind(n[0], rdflib.Namespace(n[1]))
        if self.triples:
            for terzetto in self.triples:
                self.rdflib_graph.add(terzetto)
52871
private Collection<Key<?>> getRequiredSourcesTargeting(
      DependencyGraph graph, Iterable<Key<?>> targets) {
    Collection<Key<?>> requiredSources = new LinkedHashSet<Key<?>>();
    for (Key<?> target : targets) {
      for (Dependency edge : graph.getDependenciesTargeting(target)) {
        if (!edge.isOptional()) {
          PrettyPrinter.log(logger, TreeLogger.DEBUG, "Removing the key %s because of %s",
              edge.getSource(), edge);
          requiredSources.add(edge.getSource());
        }
      }
    }
    return requiredSources;
  }
195524
def _create_edge_by_target(self):
        """"""
        ebt = {}
        for edge_dict in self._edge_by_source.values():
            for edge_id, edge in edge_dict.items():
                target_id = edge['@target']
                edge['@id'] = edge_id
                assert target_id not in ebt
                ebt[target_id] = edge
        # _check_rev_dict(self._tree, ebt)
        return ebt
575002
def build_nodes
      value = _target_column

      for key in _key_chain
        value[key] = {} unless value[key]
        value = value[key]
      end
    end
116909
def target_base(self):
    
    source_root = self._sources_field.source_root
    if not source_root:
      raise TargetDefinitionException(self, 'Not under any configured source root.')
    return source_root.path
936798
def _make_scm(current_target):
    
    # pylint: disable=protected-access
    tool_key = devpipeline_core.toolsupport.choose_tool_key(
        current_target, devpipeline_scm._SCM_TOOL_KEYS
    )

    return devpipeline_core.toolsupport.tool_builder(
        current_target.config, tool_key, devpipeline_scm.SCMS, current_target
    )
1118184
def build_fptree(self, transactions, root_value,
                     root_count, frequent, headers):
        
        root = FPNode(root_value, root_count, None)

        for transaction in transactions:
            sorted_items = [x for x in transaction if x in frequent]
            sorted_items.sort(key=lambda x: frequent[x], reverse=True)
            if len(sorted_items) > 0:
                self.insert_tree(sorted_items, root, headers)

        return root
303843
def createProgBuilder(env):
    

    try:
        program = env['BUILDERS']['Program']
    except KeyError:
        import SCons.Defaults
        program = SCons.Builder.Builder(action = SCons.Defaults.LinkAction,
                                        emitter = '$PROGEMITTER',
                                        prefix = '$PROGPREFIX',
                                        suffix = '$PROGSUFFIX',
                                        src_suffix = '$OBJSUFFIX',
                                        src_builder = 'Object',
                                        target_scanner = ProgramScanner)
        env['BUILDERS']['Program'] = program

    return program
1239794
def cmd_tree(conf: Config):
    """"""
    build_context = BuildContext(conf)
    populate_targets_graph(build_context, conf)

    def print_target_with_deps(target, depth=2):
        print('{: >{}}{}'.format('+-', depth, target.name))
        for dep in sorted(
                build_context.target_graph.neighbors(target.name)):
            print_target_with_deps(build_context.targets[dep], depth + 2)

    if conf.targets:
        for target_name in sorted(parse_target_selectors(conf.targets, conf)):
            mod, name = split(target_name)
            if name == '*':
                for target_name in sorted(
                        build_context.targets_by_module[mod]):
                    print_target_with_deps(build_context.targets[target_name])
            else:
                print_target_with_deps(build_context.targets[target_name])
    else:
        for _, target in sorted(build_context.targets.items()):
            print_target_with_deps(target)
684941
def _getImpliedEdges(roots):
        
        #Get nodes in job graph
        nodes = set()
        for root in roots:
            root._dfs(nodes)

        ##For each follow-on edge calculate the extra implied edges
        #Adjacency list of implied edges, i.e. map of jobs to lists of jobs
        #connected by an implied edge
        extraEdges = dict([(n, []) for n in nodes])
        for job in nodes:
            if len(job._followOns) > 0:
                #Get set of jobs connected by a directed path to job, starting
                #with a child edge
                reacheable = set()
                for child in job._children:
                    child._dfs(reacheable)
                #Now add extra edges
                for descendant in reacheable:
                    extraEdges[descendant] += job._followOns[:]
        return extraEdges
755603
def prepare_for_build(self):
        '''
        '''
        assert(self.target is not None)
        if hasattr(self.target, '_build_prepared'):
            return

        self.info('Preparing build')

        self.info('Check requirements for {0}'.format(self.targetname))
        self.target.check_requirements()

        self.info('Install platform')
        self.target.install_platform()

        self.info('Check application requirements')
        self.check_application_requirements()

        self.info('Check garden requirements')
        self.check_garden_requirements()

        self.info('Compile platform')
        self.target.compile_platform()

        # flag to prevent multiple build
        self.target._build_prepared = True
1306725
def get_buildenv_graph(self):
        """"""
        # This implementation first obtains all subsets of nodes that all
        # buildenvs depend on, and then builds a subgraph induced by the union
        # of these subsets. This can be very non-optimal.
        # TODO(itamar): Reimplement efficient algo, or redesign buildenvs
        buildenvs = set(target.buildenv for target in self.targets.values()
                        if target.buildenv)
        return nx.DiGraph(self.target_graph.subgraph(reduce(
            lambda x, y: x | set(y),
            (get_descendants(self.target_graph, buildenv)
             for buildenv in buildenvs), buildenvs)))
442364
def cmd_build(conf: Config, run_tests: bool=False):
    """"""
    build_context = BuildContext(conf)
    populate_targets_graph(build_context, conf)
    build_context.build_graph(run_tests=run_tests)
    build_context.write_artifacts_metadata()