Exemplo n.º 1
0
  def _init_graph(self, use_engine, pants_ignore_patterns, build_ignore_patterns,
                  exclude_target_regexps, target_specs, graph_helper=None):
    """Determines the BuildGraph, AddressMapper and spec_roots for a given run.

    :param bool use_engine: Whether or not to use the v2 engine to construct the BuildGraph.
    :param list pants_ignore_patterns: The pants ignore patterns from '--pants-ignore'.
    :param list build_ignore_patterns: The build ignore patterns from '--build-ignore',
                                       applied during BUILD file searching.
    :param list exclude_target_regexps: Regular expressions for targets to be excluded.
    :param list target_specs: The original target specs.
    :param LegacyGraphHelper graph_helper: A LegacyGraphHelper to use for graph construction,
                                           if available. This would usually come from the daemon.
    :returns: A tuple of (BuildGraph, AddressMapper, spec_roots).
    """
    # N.B. Use of the daemon implies use of the v2 engine.
    if graph_helper or use_engine:
      # The daemon may provide a `graph_helper`. If that's present, use it for graph construction.
      graph_helper = graph_helper or EngineInitializer.setup_legacy_graph(
        pants_ignore_patterns,
        build_ignore_patterns=build_ignore_patterns,
        exclude_target_regexps=exclude_target_regexps)
      target_roots = TargetRoots.create(options=self._options,
                                        build_root=self._root_dir,
                                        change_calculator=graph_helper.change_calculator)
      return graph_helper.create_build_graph(target_roots, self._root_dir)
    else:
      address_mapper = BuildFileAddressMapper(
        self._build_file_parser,
        get_project_tree(self._global_options),
        build_ignore_patterns,
        exclude_target_regexps)
      return MutableBuildGraph(address_mapper), address_mapper, target_specs
Exemplo n.º 2
0
 def open_scheduler(self, specs, symbol_table_cls=None):
   path_ignore_patterns = ['.*']
   target_roots = TargetRoots.create(options=self._make_setup_args(specs))
   graph_helper = EngineInitializer.setup_legacy_graph(path_ignore_patterns,
                                                       symbol_table_cls=symbol_table_cls,
                                                       native=self._native)
   try:
     graph = graph_helper.create_build_graph(target_roots)[0]
     addresses = tuple(graph.inject_specs_closure(target_roots.as_specs()))
     yield graph, addresses, graph_helper.scheduler
   finally:
     graph_helper.engine.close()
Exemplo n.º 3
0
 def open_scheduler(self, specs, symbol_table_cls=None):
     path_ignore_patterns = ['.*']
     target_roots = TargetRoots.create(options=self._make_setup_args(specs))
     graph_helper = EngineInitializer.setup_legacy_graph(
         path_ignore_patterns,
         symbol_table_cls=symbol_table_cls,
         native=self._native)
     try:
         graph = graph_helper.create_build_graph(target_roots)[0]
         addresses = tuple(
             graph.inject_specs_closure(target_roots.as_specs()))
         yield graph, addresses, graph_helper.scheduler
     finally:
         graph_helper.engine.close()
Exemplo n.º 4
0
    def _init_graph(self,
                    use_engine,
                    pants_ignore_patterns,
                    build_ignore_patterns,
                    exclude_target_regexps,
                    target_specs,
                    graph_helper=None):
        """Determine the BuildGraph, AddressMapper and spec_roots for a given run.

    :param bool use_engine: Whether or not to use the v2 engine to construct the BuildGraph.
    :param list pants_ignore_patterns: The pants ignore patterns from '--pants-ignore'.
    :param list build_ignore_patterns: The build ignore patterns from '--build-ignore',
                                       applied during BUILD file searching.
    :param list exclude_target_regexps: Regular expressions for targets to be excluded.
    :param list target_specs: The original target specs.
    :param LegacyGraphHelper graph_helper: A LegacyGraphHelper to use for graph construction,
                                           if available. This would usually come from the daemon.
    :returns: A tuple of (BuildGraph, AddressMapper, spec_roots).
    """
        # N.B. Use of the daemon implies use of the v2 engine.
        if graph_helper or use_engine:
            # The daemon may provide a `graph_helper`. If that's present, use it for graph construction.
            graph_helper = graph_helper or EngineInitializer.setup_legacy_graph(
                pants_ignore_patterns,
                build_ignore_patterns=build_ignore_patterns,
                exclude_target_regexps=exclude_target_regexps)
            target_roots = TargetRoots.create(
                options=self._options,
                build_root=self._root_dir,
                change_calculator=graph_helper.change_calculator)
            graph, address_mapper = graph_helper.create_build_graph(
                target_roots, self._root_dir)
            return graph, address_mapper, target_roots.as_specs()
        else:
            spec_roots = TargetRoots.parse_specs(target_specs, self._root_dir)
            address_mapper = BuildFileAddressMapper(
                self._build_file_parser,
                get_project_tree(self._global_options), build_ignore_patterns,
                exclude_target_regexps)
            return MutableBuildGraph(
                address_mapper), address_mapper, spec_roots
Exemplo n.º 5
0
def open_legacy_graph(options=None,
                      path_ignore_patterns=None,
                      symbol_table_cls=None):
    """A context manager that yields a usable, legacy LegacyBuildGraph by way of the v2 scheduler.

  :param Options options: An Options object to use for this run.
  :param list path_ignore_patterns: A list of path ignore patterns for FileSystemProjectTree,
                                    usually taken from the `--pants-ignore` global option.
                                    Defaults to: ['.*']
  :param SymbolTable symbol_table_cls: A SymbolTable class to use for build file parsing, or
                                       None to use the default.
  :yields: A tuple of (graph, addresses, scheduler).
  """
    path_ignore_patterns = path_ignore_patterns or ['.*']
    target_roots = TargetRoots.create(options=options)
    graph_helper = EngineInitializer.setup_legacy_graph(
        path_ignore_patterns, symbol_table_cls=symbol_table_cls)
    try:
        graph = graph_helper.create_build_graph(target_roots)[0]
        addresses = tuple(graph.inject_specs_closure(target_roots.as_specs()))
        yield graph, addresses, graph_helper.scheduler
    finally:
        graph_helper.engine.close()