예제 #1
0
    def _run(self):
        # Bootstrap options and logging.
        options_bootstrapper = self._options_bootstrapper or OptionsBootstrapper(
            env=self._env, args=self._args)
        options, build_config = OptionsInitializer(
            options_bootstrapper, exiter=self._exiter).setup()

        # Apply exiter options.
        self._exiter.apply_options(options)

        # Option values are usually computed lazily on demand,
        # but command line options are eagerly computed for validation.
        for scope in options.scope_to_flags.keys():
            options.for_scope(scope)

        # Verify the configs here.
        if options.for_global_scope().verify_config:
            options_bootstrapper.verify_configs_against_options(options)

        # Launch RunTracker as early as possible (just after Subsystem options are initialized).
        run_tracker, reporting = ReportingInitializer().setup()

        try:
            # Determine the build root dir.
            root_dir = get_buildroot()

            # Capture a repro of the 'before' state for this build, if needed.
            repro = Reproducer.global_instance().create_repro()
            if repro:
                repro.capture(run_tracker.run_info.get_as_dict())

            # Setup and run GoalRunner.
            goal_runner = GoalRunner.Factory(root_dir,
                                             options,
                                             build_config,
                                             run_tracker,
                                             reporting,
                                             exiter=self._exiter).setup()

            result = goal_runner.run()

            if repro:
                # TODO: Have Repro capture the 'after' state (as a diff) as well?
                repro.log_location_of_repro_file()
        finally:
            run_tracker.end()

        self._exiter.exit(result)
예제 #2
0
파일: commands.py 프로젝트: simudream/pants
def list():
    """Lists all addresses under the current build root subject to `--spec-excludes` constraints."""
    build_root = get_buildroot()

    options, build_config = OptionsInitializer().setup()
    aliases = build_config.registered_aliases()

    symbol_table = {alias: Target for alias in aliases.target_types}

    object_table = aliases.objects

    def per_path_symbol_factory(path, global_symbols):
        per_path_symbols = {}

        symbols = global_symbols.copy()
        for alias, target_macro_factory in aliases.target_macro_factories.items(
        ):
            for target_type in target_macro_factory.target_types:
                symbols[
                    target_type] = lambda *args, **kwargs: per_path_symbols[
                        alias](*args, **kwargs)

        parse_context = ParseContext(rel_path=os.path.relpath(
            os.path.dirname(path), build_root),
                                     type_aliases=symbols)

        for alias, object_factory in aliases.context_aware_object_factories.items(
        ):
            per_path_symbols[alias] = object_factory(parse_context)

        for alias, target_macro_factory in aliases.target_macro_factories.items(
        ):
            target_macro = target_macro_factory.target_macro(parse_context)
            per_path_symbols[alias] = target_macro
            for target_type in target_macro_factory.target_types:
                per_path_symbols[target_type] = target_macro

        return per_path_symbols

    parser = legacy_python_callbacks_parser(
        symbol_table,
        object_table=object_table,
        per_path_symbol_factory=per_path_symbol_factory)
    mapper = AddressMapper(build_root, parser=parser)

    spec_excludes = options.for_global_scope().spec_excludes
    for address, obj in mapper.walk_addressables(path_excludes=spec_excludes):
        print(address.spec)
예제 #3
0
  def _run(self):
    # Bootstrap options and logging.
    options_bootstrapper = self._options_bootstrapper or OptionsBootstrapper(env=self._env,
                                                                             args=self._args)
    options, build_config = OptionsInitializer(options_bootstrapper, exiter=self._exiter).setup()

    # Apply exiter options.
    self._exiter.apply_options(options)

    # Option values are usually computed lazily on demand,
    # but command line options are eagerly computed for validation.
    for scope in options.scope_to_flags.keys():
      options.for_scope(scope)

    # Verify the configs here.
    if options.for_global_scope().verify_config:
      options_bootstrapper.verify_configs_against_options(options)

    # Launch RunTracker as early as possible (just after Subsystem options are initialized).
    run_tracker, reporting = ReportingInitializer().setup()

    try:
      # Determine the build root dir.
      root_dir = get_buildroot()

      # Capture a repro of the 'before' state for this build, if needed.
      repro = Reproducer.global_instance().create_repro()
      if repro:
        repro.capture(run_tracker.run_info.get_as_dict())

      # Setup and run GoalRunner.
      goal_runner = GoalRunner.Factory(root_dir,
                                       options,
                                       build_config,
                                       run_tracker,
                                       reporting,
                                       exiter=self._exiter).setup()

      result = goal_runner.run()

      if repro:
        # TODO: Have Repro capture the 'after' state (as a diff) as well?
        repro.log_location_of_repro_file()
    finally:
      run_tracker.end()

    self._exiter.exit(result)
예제 #4
0
def list():
  """Lists all addresses under the current build root subject to `--spec-excludes` constraints."""
  build_root = get_buildroot()

  options, build_config = OptionsInitializer().setup()
  aliases = build_config.registered_aliases()

  symbol_table = {alias: Target for alias in aliases.target_types}

  object_table = aliases.objects

  def per_path_symbol_factory(path, global_symbols):
    per_path_symbols = {}

    symbols = global_symbols.copy()
    for alias, target_macro_factory in aliases.target_macro_factories.items():
      for target_type in target_macro_factory.target_types:
        symbols[target_type] = lambda *args, **kwargs: per_path_symbols[alias](*args, **kwargs)

    parse_context = ParseContext(rel_path=os.path.relpath(os.path.dirname(path), build_root),
                                 type_aliases=symbols)

    for alias, object_factory in aliases.context_aware_object_factories.items():
      per_path_symbols[alias] = object_factory(parse_context)

    for alias, target_macro_factory in aliases.target_macro_factories.items():
      target_macro = target_macro_factory.target_macro(parse_context)
      per_path_symbols[alias] = target_macro
      for target_type in target_macro_factory.target_types:
        per_path_symbols[target_type] = target_macro

    return per_path_symbols

  parser = legacy_python_callbacks_parser(symbol_table,
                                          object_table=object_table,
                                          per_path_symbol_factory=per_path_symbol_factory)
  mapper = AddressMapper(build_root, parser=parser)

  spec_excludes = options.for_global_scope().spec_excludes
  for address, obj in mapper.walk_addressables(path_excludes=spec_excludes):
    print(address.spec)