def _init_graph(self, use_engine, pants_ignore_patterns, build_ignore_patterns, exclude_target_regexps, target_specs, workdir, graph_helper=None, subproject_build_roots=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 str workdir: The pants workdir. :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, opt Scheduler, 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. if not graph_helper: native = Native.create(self._global_options) native.set_panic_handler() graph_helper = EngineInitializer.setup_legacy_graph( pants_ignore_patterns, workdir, self._global_options.build_file_imports, native=native, build_file_aliases=self._build_config.registered_aliases(), build_ignore_patterns=build_ignore_patterns, exclude_target_regexps=exclude_target_regexps, subproject_roots=subproject_build_roots, include_trace_on_error=self._options.for_global_scope( ).print_exception_stacktrace) 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, graph_helper.scheduler, 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, subproject_build_roots) return MutableBuildGraph( address_mapper), address_mapper, None, spec_roots
def _init_graph(self, use_engine, pants_ignore_patterns, build_ignore_patterns, exclude_target_regexps, target_specs, workdir, graph_helper=None, subproject_build_roots=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 str workdir: The pants workdir. :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. if not graph_helper: native = Native.Factory.global_instance().create() native.set_panic_handler() graph_helper = EngineInitializer.setup_legacy_graph( pants_ignore_patterns, workdir, native=native, build_ignore_patterns=build_ignore_patterns, exclude_target_regexps=exclude_target_regexps, subproject_roots=subproject_build_roots, include_trace_on_error=self._options.for_global_scope().print_exception_stacktrace ) 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, include_trace_on_error=self._global_options.print_exception_stacktrace) 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, subproject_build_roots) return MutableBuildGraph(address_mapper), address_mapper, spec_roots
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) 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
def _init_graph(self, pants_ignore_patterns, build_ignore_patterns, exclude_target_regexps, target_specs, workdir, graph_helper=None, subproject_build_roots=None): """Determine the BuildGraph, AddressMapper and spec_roots for a given run. :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 str workdir: The pants workdir. :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, opt Scheduler, spec_roots). """ # The daemon may provide a `graph_helper`. If that's present, use it for graph construction. if not graph_helper: native = Native.create(self._global_options) native.set_panic_handler() graph_helper = EngineInitializer.setup_legacy_graph( pants_ignore_patterns, workdir, self._global_options.build_file_imports, native=native, build_file_aliases=self._build_config.registered_aliases(), build_ignore_patterns=build_ignore_patterns, exclude_target_regexps=exclude_target_regexps, subproject_roots=subproject_build_roots, include_trace_on_error=self._options.for_global_scope().print_exception_stacktrace ) 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, graph_helper.scheduler, target_roots.as_specs()
def create_target_roots(self, specs): return TargetRoots.create(options=self._make_setup_args(specs))