aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/Builder.java
blob: 2985a2c0353a3e73687f899848cbd77252a87805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.devtools.build.lib.skyframe;

import com.google.common.collect.Range;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.BuildFailedException;
import com.google.devtools.build.lib.actions.Executor;
import com.google.devtools.build.lib.actions.TestExecException;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadCompatible;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.util.AbruptExitException;

import java.util.Collection;
import java.util.Set;

import javax.annotation.Nullable;

/**
 * A Builder consumes top-level artifacts, targets, and tests,, and executes them in some
 * topological order, possibly concurrently, using some dependency-checking policy.
 *
 * <p> The methods of the Builder interface are typically long-running, but honor the
 * {@link java.lang.Thread#interrupt} contract: if an interrupt is delivered to the thread in which
 * a call to buildTargets or buildArtifacts is active, the Builder attempts to terminate the call
 * prematurely, throwing InterruptedException.  No guarantee is made about the timeliness of such
 * termination, as it depends on the ability of the Actions being executed to be interrupted, but
 * typically any running subprocesses will be quickly killed.
 */
public interface Builder {

  /**
   * Transitively build all given artifacts, targets, and tests, and all necessary prerequisites
   * thereof. For sequential implementations of this interface, the top-level requests will be
   * built in the iteration order of the Set provided; for concurrent implementations, the order
   * is undefined.
   *
   * <p>This method should not be invoked more than once concurrently on the same Builder instance.
   *
   * @param artifacts the set of Artifacts to build
   * @param parallelTests tests to execute in parallel with the other top-level targetsToBuild and
   *        artifacts.
   * @param exclusiveTests are executed one at a time, only after all other tasks have completed
   * @param targetsToBuild Set of targets which will be built
   * @param aspects Set of aspects that will be built
   * @param executor an opaque application-specific value that will be
   *        passed down to the execute() method of any Action executed during
   *        this call
   * @param builtTargets (out) set of successfully built subset of targetsToBuild. This set is
   *        populated immediately upon confirmation that artifact is built so it will be
   *        valid even if a future action throws ActionExecutionException
   * @param lastExecutionTimeRange If not null, the start/finish time of the last build that
   *        run the execution phase.
   * @throws BuildFailedException if there were problems establishing the action execution
   *         environment, if the the metadata of any file  during the build could not be obtained,
   *         if any input files are missing, or if an action fails during execution
   * @throws InterruptedException if there was an asynchronous stop request
   * @throws TestExecException if any test fails
   */
  @ThreadCompatible
  void buildArtifacts(
      EventHandler eventHandler,
      Set<Artifact> artifacts,
      Set<ConfiguredTarget> parallelTests,
      Set<ConfiguredTarget> exclusiveTests,
      Collection<ConfiguredTarget> targetsToBuild,
      Collection<AspectValue> aspects,
      Executor executor,
      Set<ConfiguredTarget> builtTargets,
      boolean explain,
      @Nullable Range<Long> lastExecutionTimeRange)
      throws BuildFailedException, AbruptExitException, InterruptedException, TestExecException;
}