Skip to content

Commit

Permalink
Propagate through info that comes from the BuildConfiguration.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuhood committed Jun 5, 2018
1 parent 015e9a1 commit 7175dd8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/python/pants/bin/goal_runner.py
Expand Up @@ -89,7 +89,8 @@ def _init_graph(self, target_roots, graph_helper):
native = Native.create(self._global_options)
native.set_panic_handler()
graph_scheduler_helper = EngineInitializer.setup_legacy_graph(native,
self._global_options)
self._global_options,
self._build_config)
graph_helper = graph_scheduler_helper.new_session()

target_roots = target_roots or TargetRootsCalculator.create(
Expand Down
18 changes: 6 additions & 12 deletions src/python/pants/init/engine_initializer.py
Expand Up @@ -26,9 +26,7 @@
from pants.engine.parser import SymbolTable
from pants.engine.rules import SingletonRule
from pants.engine.scheduler import Scheduler
from pants.init.options_initializer import OptionsInitializer
from pants.option.global_options import GlobMatchErrorBehavior
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.scm.change_calculator import EngineChangeCalculator
from pants.util.objects import datatype

Expand Down Expand Up @@ -122,21 +120,20 @@ class EngineInitializer(object):
"""Constructs the components necessary to run the v2 engine with v1 BuildGraph compatibility."""

@staticmethod
def get_default_build_file_aliases():
_, build_config = OptionsInitializer(OptionsBootstrapper()).setup(init_logging=False)
return build_config.registered_aliases()

@staticmethod
def setup_legacy_graph(native, bootstrap_options):
def setup_legacy_graph(native, bootstrap_options, build_config):
"""Construct and return the components necessary for LegacyBuildGraph construction."""
return EngineInitializer.setup_legacy_graph_extended(
bootstrap_options.pants_ignore,
bootstrap_options.pants_workdir,
bootstrap_options.build_file_imports,
build_config.registered_aliases(),
native=native,
glob_match_error_behavior=bootstrap_options.glob_expansion_failure,
rules=build_config.rules(),
build_ignore_patterns=bootstrap_options.build_ignore,
exclude_target_regexps=bootstrap_options.exclude_target_regexp,
subproject_roots=bootstrap_options.subproject_roots,
include_trace_on_error=bootstrap_options.print_exception_stacktrace,
remote_store_server=bootstrap_options.remote_store_server,
remote_execution_server=bootstrap_options.remote_execution_server,
)
Expand All @@ -146,9 +143,9 @@ def setup_legacy_graph_extended(
pants_ignore_patterns,
workdir,
build_file_imports_behavior,
build_file_aliases,
build_root=None,
native=None,
build_file_aliases=None,
glob_match_error_behavior=None,
rules=None,
build_ignore_patterns=None,
Expand Down Expand Up @@ -185,9 +182,6 @@ def setup_legacy_graph_extended(

build_root = build_root or get_buildroot()

if not build_file_aliases:
build_file_aliases = EngineInitializer.get_default_build_file_aliases()

if not rules:
rules = []

Expand Down
19 changes: 9 additions & 10 deletions src/python/pants/option/global_options.py
Expand Up @@ -163,6 +163,7 @@ def register_bootstrap_options(cls, register):
help='Read additional specs from this file, one per line')
register('--verify-config', type=bool, default=True, daemon=False,
help='Verify that all config file values correspond to known options.')

register('--build-ignore', advanced=True, type=list, fromfile=True,
default=['.*/', default_rel_distdir, 'bower_components/',
'node_modules/', '*.egg-info/'],
Expand All @@ -174,6 +175,12 @@ def register_bootstrap_options(cls, register):
help='Paths to ignore for all filesystem operations performed by pants '
'(e.g. BUILD file scanning, glob matching, etc). '
'Patterns use the gitignore syntax (https://git-scm.com/docs/gitignore).')
register('--glob-expansion-failure', type=str,
choices=GlobMatchErrorBehavior.allowed_values,
default=GlobMatchErrorBehavior.default_option_value,
help="Raise an exception if any targets declaring source files "
"fail to match any glob provided in the 'sources' argument.")

register('--exclude-target-regexp', advanced=True, type=list, default=[], daemon=False,
metavar='<regexp>', help='Exclude target roots that match these regexes.')
register('--subproject-roots', type=list, advanced=True, fromfile=True, default=[],
Expand All @@ -195,6 +202,8 @@ def register_bootstrap_options(cls, register):
register('--native-engine-visualize-to', advanced=True, default=None, type=dir_option, daemon=False,
help='A directory to write execution and rule graphs to as `dot` files. The contents '
'of the directory will be overwritten if any filenames collide.')
register('--print-exception-stacktrace', advanced=True, type=bool,
help='Print to console the full exception stack trace if encountered.')

# BinaryUtil options.
register('--binaries-baseurls', type=list, advanced=True,
Expand Down Expand Up @@ -283,16 +292,6 @@ def register_options(cls, register):
register('--max-subprocess-args', advanced=True, type=int, default=100, recursive=True,
help='Used to limit the number of arguments passed to some subprocesses by breaking '
'the command up into multiple invocations.')
register('--print-exception-stacktrace', advanced=True, type=bool,
help='Print to console the full exception stack trace if encountered.')
register('--lock', advanced=True, type=bool, default=True,
help='Use a global lock to exclude other versions of pants from running during '
'critical operations.')
# TODO: Make a custom type abstract class (or something) to automate the production of an option
# with specific allowed values from a datatype (ideally using singletons for the allowed
# values).
register('--glob-expansion-failure', type=str,
choices=GlobMatchErrorBehavior.allowed_values,
default=GlobMatchErrorBehavior.default_option_value,
help="Raise an exception if any targets declaring source files "
"fail to match any glob provided in the 'sources' argument.")
5 changes: 4 additions & 1 deletion src/python/pants/pantsd/pants_daemon.py
Expand Up @@ -18,6 +18,7 @@
from pants.bin.daemon_pants_runner import DaemonExiter, DaemonPantsRunner
from pants.engine.native import Native
from pants.init.engine_initializer import EngineInitializer
from pants.init.options_initializer import OptionsInitializer
from pants.init.target_roots_calculator import TargetRootsCalculator
from pants.logging.setup import setup_logging
from pants.option.arg_splitter import GLOBAL_SCOPE
Expand Down Expand Up @@ -115,8 +116,10 @@ def create(cls, bootstrap_options=None, full_init=True):
if full_init:
build_root = get_buildroot()
native = Native.create(bootstrap_options_values)
_, build_config = OptionsInitializer(OptionsBootstrapper()).setup(init_logging=False)
legacy_graph_scheduler = EngineInitializer.setup_legacy_graph(native,
bootstrap_options_values)
bootstrap_options_values,
build_config)
services, port_map = cls._setup_services(
build_root,
bootstrap_options_values,
Expand Down

0 comments on commit 7175dd8

Please sign in to comment.