Beispiel #1
0
  def __init__(self,
               work_dir,
               goals,
               rules,
               project_tree,
               native,
               graph_lock=None):
    """
    :param goals: A dict from a goal name to a product type. A goal is just an alias for a
           particular (possibly synthetic) product.
    :param rules: A set of Rules which is used to compute values in the product graph.
    :param project_tree: An instance of ProjectTree for the current build root.
    :param work_dir: The pants work dir.
    :param native: An instance of engine.subsystem.native.Native.
    :param graph_lock: A re-entrant lock to use for guarding access to the internal product Graph
                       instance. Defaults to creating a new threading.RLock().
    """
    self._products_by_goal = goals
    self._project_tree = project_tree
    self._product_graph_lock = graph_lock or threading.RLock()
    self._run_count = 0

    # Create the ExternContext, and the native Scheduler.
    self._execution_request = None


    # Validate and register all provided and intrinsic tasks.
    # TODO: This bounding of input Subject types allows for closed-world validation, but is not
    # strictly necessary for execution. We might eventually be able to remove it by only executing
    # validation below the execution roots (and thus not considering paths that aren't in use).

    root_subject_types = {
      Address,
      BuildFileAddress,
      AscendantAddresses,
      DescendantAddresses,
      PathGlobs,
      SiblingAddresses,
      SingleAddress,
    }
    rules = list(rules) + create_snapshot_rules()
    rule_index = RuleIndex.create(rules)
    self._scheduler = WrappedNativeScheduler(native,
                                             project_tree.build_root,
                                             work_dir,
                                             project_tree.ignore_patterns,
                                             rule_index,
                                             root_subject_types)

    # If configured, visualize the rule graph before asserting that it is valid.
    if self._scheduler.visualize_to_dir() is not None:
      rule_graph_name = 'rule_graph.dot'
      self.visualize_rule_graph_to_file(os.path.join(self._scheduler.visualize_to_dir(), rule_graph_name))

    self._scheduler.assert_ruleset_valid()
Beispiel #2
0
    def __init__(self,
                 work_dir,
                 goals,
                 rules,
                 project_tree,
                 native,
                 graph_lock=None):
        """
    :param goals: A dict from a goal name to a product type. A goal is just an alias for a
           particular (possibly synthetic) product.
    :param rules: A set of Rules which is used to compute values in the product graph.
    :param project_tree: An instance of ProjectTree for the current build root.
    :param work_dir: The pants work dir.
    :param native: An instance of engine.subsystem.native.Native.
    :param graph_lock: A re-entrant lock to use for guarding access to the internal product Graph
                       instance. Defaults to creating a new threading.RLock().
    """
        self._products_by_goal = goals
        self._project_tree = project_tree
        self._product_graph_lock = graph_lock or threading.RLock()
        self._run_count = 0

        # Create the ExternContext, and the native Scheduler.
        self._execution_request = None

        # Validate and register all provided and intrinsic tasks.
        # TODO: This bounding of input Subject types allows for closed-world validation, but is not
        # strictly necessary for execution. We might eventually be able to remove it by only executing
        # validation below the execution roots (and thus not considering paths that aren't in use).

        root_subject_types = {
            Address,
            BuildFileAddress,
            AscendantAddresses,
            DescendantAddresses,
            PathGlobs,
            SiblingAddresses,
            SingleAddress,
        }
        rules = list(rules) + create_snapshot_rules()
        rule_index = RuleIndex.create(rules)
        self._scheduler = WrappedNativeScheduler(
            native, project_tree.build_root, work_dir,
            project_tree.ignore_patterns, rule_index, root_subject_types)

        # If configured, visualize the rule graph before asserting that it is valid.
        if self._scheduler.visualize_to_dir() is not None:
            rule_graph_name = 'rule_graph.dot'
            self.visualize_rule_graph_to_file(
                os.path.join(self._scheduler.visualize_to_dir(),
                             rule_graph_name))

        self._scheduler.assert_ruleset_valid()
Beispiel #3
0
    def __init__(self,
                 work_dir,
                 goals,
                 rules,
                 project_tree,
                 native,
                 include_trace_on_error=True,
                 graph_lock=None):
        """
    :param goals: A dict from a goal name to a product type. A goal is just an alias for a
           particular (possibly synthetic) product.
    :param rules: A set of Rules which is used to compute values in the product graph.
    :param project_tree: An instance of ProjectTree for the current build root.
    :param work_dir: The pants work dir.
    :param native: An instance of engine.subsystem.native.Native.
    :param include_trace_on_error: Include the trace through the graph upon encountering errors.
    :type include_trace_on_error: bool
    :param graph_lock: A re-entrant lock to use for guarding access to the internal product Graph
                       instance. Defaults to creating a new threading.RLock().
    """
        self._products_by_goal = goals
        self._project_tree = project_tree
        self._include_trace_on_error = include_trace_on_error
        self._product_graph_lock = graph_lock or threading.RLock()
        self._run_count = 0

        # Create the ExternContext, and the native Scheduler.
        self._execution_request = None

        # Validate and register all provided and intrinsic tasks.
        rules = list(rules) + create_snapshot_rules()
        rule_index = RuleIndex.create(rules)
        self._scheduler = WrappedNativeScheduler(native,
                                                 project_tree.build_root,
                                                 work_dir,
                                                 project_tree.ignore_patterns,
                                                 rule_index)

        # If configured, visualize the rule graph before asserting that it is valid.
        if self._scheduler.visualize_to_dir() is not None:
            rule_graph_name = 'rule_graph.dot'
            self.visualize_rule_graph_to_file(
                os.path.join(self._scheduler.visualize_to_dir(),
                             rule_graph_name))

        self._scheduler.assert_ruleset_valid()
Beispiel #4
0
  def __init__(self,
               work_dir,
               goals,
               rules,
               project_tree,
               native,
               include_trace_on_error=True,
               graph_lock=None):
    """
    :param goals: A dict from a goal name to a product type. A goal is just an alias for a
           particular (possibly synthetic) product.
    :param rules: A set of Rules which is used to compute values in the product graph.
    :param project_tree: An instance of ProjectTree for the current build root.
    :param work_dir: The pants work dir.
    :param native: An instance of engine.native.Native.
    :param include_trace_on_error: Include the trace through the graph upon encountering errors.
    :type include_trace_on_error: bool
    :param graph_lock: A re-entrant lock to use for guarding access to the internal product Graph
                       instance. Defaults to creating a new threading.RLock().
    """
    self._products_by_goal = goals
    self._project_tree = project_tree
    self._include_trace_on_error = include_trace_on_error
    self._product_graph_lock = graph_lock or threading.RLock()
    self._run_count = 0

    # Create the ExternContext, and the native Scheduler.
    self._execution_request = None

    # Validate and register all provided and intrinsic tasks.
    rules = list(rules) + create_snapshot_rules()
    rule_index = RuleIndex.create(rules)
    self._scheduler = WrappedNativeScheduler(native,
                                             project_tree.build_root,
                                             work_dir,
                                             project_tree.ignore_patterns,
                                             rule_index)

    # If configured, visualize the rule graph before asserting that it is valid.
    if self._scheduler.visualize_to_dir() is not None:
      rule_graph_name = 'rule_graph.dot'
      self.visualize_rule_graph_to_file(os.path.join(self._scheduler.visualize_to_dir(), rule_graph_name))

    self._scheduler.assert_ruleset_valid()