Example #1
0
def _run(exiter):
  # Bootstrap options and logging.
  options, build_config = OptionsInitializer().setup()

  # Apply exiter options.
  exiter.apply_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())

    # Set up and run GoalRunner.
    goal_runner = GoalRunner.Factory(root_dir, options, build_config,
                                     run_tracker, reporting).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()

  exiter.do_exit(result)
Example #2
0
  def _maybe_run_v1(self):
    v1_goals, ambiguous_goals, _ = self._options.goals_by_version
    if not self._global_options.v1:
      if v1_goals:
        HelpPrinter(self._options, UnknownGoalHelp(v1_goals)).print_help()
        return PANTS_FAILED_EXIT_CODE
      return PANTS_SUCCEEDED_EXIT_CODE

    if not v1_goals and not ambiguous_goals:
      return PANTS_SUCCEEDED_EXIT_CODE

    # Setup and run GoalRunner.
    goal_runner_factory = GoalRunner.Factory(
      self._build_root,
      self._options,
      self._build_config,
      self._run_tracker,
      self._reporting,
      self._graph_session,
      self._target_roots,
      self._exiter
    )
    if self._options.help_request:
      return goal_runner_factory.handle_help()

    return goal_runner_factory.create().run()
Example #3
0
    def _maybe_run_v1(self, v1: bool) -> int:
        v1_goals, ambiguous_goals, _ = self.options.goals_by_version
        if not v1:
            if v1_goals:
                HelpPrinter(
                    options=self.options,
                    help_request=UnknownGoalHelp(list(v1_goals)),
                    union_membership=self.union_membership,
                ).print_help()
                return PANTS_FAILED_EXIT_CODE
            return PANTS_SUCCEEDED_EXIT_CODE

        if not v1_goals and not ambiguous_goals:
            return PANTS_SUCCEEDED_EXIT_CODE

        # Setup and run GoalRunner.
        return (GoalRunner.Factory(
            self.build_root,
            self.options_bootstrapper,
            self.options,
            self.build_config,
            self._run_tracker,  # type: ignore
            self._reporting,  # type: ignore
            self.graph_session,
            self.specs,
            self._exiter,
        ).create().run())
Example #4
0
    def _maybe_run_v1(self, run_tracker, reporting):
        if not self._global_options.v1:
            return 0

        # Setup and run GoalRunner.
        goal_runner_factory = GoalRunner.Factory(
            self._build_root, self._options, self._build_config, run_tracker,
            reporting, self._graph_session, self._target_roots, self._exiter)
        return goal_runner_factory.create().run()
Example #5
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()
        global_options = options.for_global_scope()

        # 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 global_options.verify_config:
            options_bootstrapper.verify_configs_against_options(options)

        # Launch RunTracker as early as possible (just after Subsystem options are initialized).
        run_tracker = RunTracker.global_instance()
        reporting = Reporting.global_instance()
        reporting.initialize(run_tracker, self._run_start_time)

        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())

            # Record the preceding product graph size.
            run_tracker.pantsd_stats.set_preceding_graph_size(
                self._preceding_graph_size)

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

            goal_runner_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_result = run_tracker.end()

        # Take the exit code with higher abs value in case of negative values.
        final_exit_code = goal_runner_result if abs(goal_runner_result) > abs(
            run_tracker_result) else run_tracker_result
        self._exiter.exit(final_exit_code)
Example #6
0
    def _maybe_run_v1(self):
        v1_goals, ambiguous_goals, _ = self._options.goals_by_version
        if not v1_goals and (not ambiguous_goals
                             or not self._global_options.v1):
            return PANTS_SUCCEEDED_EXIT_CODE

        # Setup and run GoalRunner.
        goal_runner_factory = GoalRunner.Factory(
            self._build_root, self._options, self._build_config,
            self._run_tracker, self._reporting, self._graph_session,
            self._target_roots, self._exiter)
        return goal_runner_factory.create().run()
Example #7
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)
Example #8
0
    def _maybe_run_v1(self):
        v1_goals, ambiguous_goals, _ = self._options.goals_by_version
        if not self._global_options.v1:
            if v1_goals:
                HelpPrinter(
                    options=self._options,
                    help_request=UnknownGoalHelp(v1_goals),
                    union_membership=self._union_membership,
                ).print_help()
                return PANTS_FAILED_EXIT_CODE
            return PANTS_SUCCEEDED_EXIT_CODE

        if not v1_goals and not ambiguous_goals:
            return PANTS_SUCCEEDED_EXIT_CODE

        # Setup and run GoalRunner.
        return GoalRunner.Factory(self._build_root, self._options_bootstrapper,
                                  self._options, self._build_config,
                                  self._run_tracker, self._reporting,
                                  self._graph_session, self._specs,
                                  self._exiter).create().run()
Example #9
0
def _run(exiter):
  # We want to present warnings to the user, set this up early to ensure all warnings are seen.
  # The "default" action displays a warning for a particular file and line number exactly once.
  # See https://docs.python.org/2/library/warnings.html#the-warnings-filter for the complete action
  # list.
  warnings.simplefilter('default')

  # Bootstrap options and logging.
  options, build_config = OptionsInitializer().setup()

  # Apply exiter options.
  exiter.apply_options(options)

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

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

  # Setup and run GoalRunner.
  goal_runner = GoalRunner.Factory(root_dir, options, build_config, run_tracker, reporting).setup()
  result = goal_runner.run()
  exiter.do_exit(result)
Example #10
0
 def run():
     goal_runner = GoalRunner.Factory(root_dir, options, build_config,
                                      run_tracker, reporting).setup()
     return goal_runner.run()