aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions/MiddlemanFactory.java
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2018-01-16 11:07:51 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-16 11:09:25 -0800
commit1cdcdf9a72458850f8a0f40c7cab1699685ed6cc (patch)
tree888c68cd1fc59cc4608ac178ae633c1f40e22230 /src/main/java/com/google/devtools/build/lib/actions/MiddlemanFactory.java
parent644ada0444a9db285eb4e6c2511fc9581cc69880 (diff)
Rename Root to ArtifactRoot.
This is slightly more descriptive, and we will potentially want to use the name Root for a broader concept shared between ArtifactRoot and RootedPath. PiperOrigin-RevId: 182082367
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/MiddlemanFactory.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/MiddlemanFactory.java88
1 files changed, 50 insertions, 38 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/MiddlemanFactory.java b/src/main/java/com/google/devtools/build/lib/actions/MiddlemanFactory.java
index fbbc10016f..43a9e372dc 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/MiddlemanFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/MiddlemanFactory.java
@@ -45,15 +45,15 @@ public final class MiddlemanFactory {
*
* @param owner the owner of the action that will be created; must not be null
* @param purpose the purpose for which this middleman is created. This should be a string which
- * is suitable for use as a filename. A single rule may have many middlemen with distinct
- * purposes.
+ * is suitable for use as a filename. A single rule may have many middlemen with distinct
+ * purposes.
* @param inputs the set of artifacts for which the created artifact is to be the middleman.
* @param middlemanDir the directory in which to place the middleman.
* @return null iff {@code inputs} is empty; the single element of {@code inputs} if there's only
- * one; a new aggregating middleman for the {@code inputs} otherwise
+ * one; a new aggregating middleman for the {@code inputs} otherwise
*/
public Artifact createAggregatingMiddleman(
- ActionOwner owner, String purpose, Iterable<Artifact> inputs, Root middlemanDir) {
+ ActionOwner owner, String purpose, Iterable<Artifact> inputs, ArtifactRoot middlemanDir) {
if (hasExactlyOneInput(inputs)) { // Optimization: No middleman for just one input.
return Iterables.getOnlyElement(inputs);
}
@@ -64,28 +64,26 @@ public final class MiddlemanFactory {
}
/**
- * Returns <code>null</code> iff inputs is empty. Returns the sole element
- * of inputs iff <code>inputs.size()==1</code>. Otherwise, returns a
- * middleman artifact and creates a middleman action that generates that
- * artifact.
+ * Returns <code>null</code> iff inputs is empty. Returns the sole element of inputs iff <code>
+ * inputs.size()==1</code>. Otherwise, returns a middleman artifact and creates a middleman action
+ * that generates that artifact.
*
* @param owner the owner of the action that will be created.
- * @param owningArtifact the artifact of the file for which the runfiles
- * should be created. There may be at most one set of runfiles for
- * an owning artifact, unless the owning artifact is null. There
- * may be at most one set of runfiles per owner with a null
- * owning artifact.
- * Further, if the owning Artifact is non-null, the owning Artifacts'
- * root-relative path must be unique and the artifact must be part
- * of the runfiles tree for which this middleman is created. Usually
- * this artifact will be an executable program.
- * @param inputs the set of artifacts for which the created artifact is to be
- * the middleman.
+ * @param owningArtifact the artifact of the file for which the runfiles should be created. There
+ * may be at most one set of runfiles for an owning artifact, unless the owning artifact is
+ * null. There may be at most one set of runfiles per owner with a null owning artifact.
+ * Further, if the owning Artifact is non-null, the owning Artifacts' root-relative path must
+ * be unique and the artifact must be part of the runfiles tree for which this middleman is
+ * created. Usually this artifact will be an executable program.
+ * @param inputs the set of artifacts for which the created artifact is to be the middleman.
* @param middlemanDir the directory in which to place the middleman.
*/
public Artifact createRunfilesMiddleman(
- ActionOwner owner, @Nullable Artifact owningArtifact, Iterable<Artifact> inputs,
- Root middlemanDir, String tag) {
+ ActionOwner owner,
+ @Nullable Artifact owningArtifact,
+ Iterable<Artifact> inputs,
+ ArtifactRoot middlemanDir,
+ String tag) {
Preconditions.checkArgument(middlemanDir.isMiddlemanRoot());
if (hasExactlyOneInput(inputs)) { // Optimization: No middleman for just one input.
return Iterables.getOnlyElement(inputs);
@@ -114,19 +112,23 @@ public final class MiddlemanFactory {
*
* @param owner the owner of the action that will be created. May not be null.
* @param middlemanName a unique file name for the middleman artifact in the {@code middlemanDir};
- * in practice this is usually the owning rule's label (so it gets escaped as such)
+ * in practice this is usually the owning rule's label (so it gets escaped as such)
* @param purpose the purpose for which this middleman is created. This should be a string which
- * is suitable for use as a filename. A single rule may have many middlemen with distinct
- * purposes.
+ * is suitable for use as a filename. A single rule may have many middlemen with distinct
+ * purposes.
* @param inputs the set of artifacts for which the created artifact is to be the middleman; must
- * not be null or empty
+ * not be null or empty
* @param middlemanDir the directory in which to place the middleman.
* @return a middleman that enforces scheduling order (just like a scheduling middleman) and
- * propagates errors, but is ignored by the dependency checker
+ * propagates errors, but is ignored by the dependency checker
* @throws IllegalArgumentException if {@code inputs} is null or empty
*/
- public Artifact createErrorPropagatingMiddleman(ActionOwner owner, String middlemanName,
- String purpose, Iterable<Artifact> inputs, Root middlemanDir) {
+ public Artifact createErrorPropagatingMiddleman(
+ ActionOwner owner,
+ String middlemanName,
+ String purpose,
+ Iterable<Artifact> inputs,
+ ArtifactRoot middlemanDir) {
Preconditions.checkArgument(inputs != null);
Preconditions.checkArgument(!Iterables.isEmpty(inputs));
// We must always create this middleman even if there is only one input.
@@ -135,11 +137,11 @@ public final class MiddlemanFactory {
}
/**
- * Returns the same artifact as {@code createErrorPropagatingMiddleman} would return,
- * but doesn't create any action.
+ * Returns the same artifact as {@code createErrorPropagatingMiddleman} would return, but doesn't
+ * create any action.
*/
- public Artifact getErrorPropagatingMiddlemanArtifact(String middlemanName, String purpose,
- Root middlemanDir) {
+ public Artifact getErrorPropagatingMiddlemanArtifact(
+ String middlemanName, String purpose, ArtifactRoot middlemanDir) {
return getStampFileArtifact(middlemanName, purpose, middlemanDir);
}
@@ -150,11 +152,15 @@ public final class MiddlemanFactory {
* another synchronized method (getArtifact()).
*
* @return null iff {@code inputs} is null or empty; the middleman file and the middleman action
- * otherwise
+ * otherwise
*/
private Pair<Artifact, Action> createMiddleman(
- ActionOwner owner, String middlemanName, String purpose, Iterable<Artifact> inputs,
- Root middlemanDir, MiddlemanType middlemanType) {
+ ActionOwner owner,
+ String middlemanName,
+ String purpose,
+ Iterable<Artifact> inputs,
+ ArtifactRoot middlemanDir,
+ MiddlemanType middlemanType) {
if (inputs == null || CollectionUtils.isEmpty(inputs)) {
return null;
}
@@ -175,8 +181,13 @@ public final class MiddlemanFactory {
* <p>Note: there's no need to synchronize this method; the only use of a field is via a call to
* another synchronized method (getArtifact()).
*/
- public Artifact createMiddlemanAllowMultiple(ActionRegistry registry, ActionOwner owner,
- PathFragment packageDirectory, String purpose, Iterable<Artifact> inputs, Root middlemanDir) {
+ public Artifact createMiddlemanAllowMultiple(
+ ActionRegistry registry,
+ ActionOwner owner,
+ PathFragment packageDirectory,
+ String purpose,
+ Iterable<Artifact> inputs,
+ ArtifactRoot middlemanDir) {
String escapedPackageDirectory = Actions.escapedPath(packageDirectory.getPathString());
PathFragment stampName =
PathFragment.create("_middlemen/" + (purpose.startsWith(escapedPackageDirectory)
@@ -188,7 +199,8 @@ public final class MiddlemanFactory {
return stampFile;
}
- private Artifact getStampFileArtifact(String middlemanName, String purpose, Root middlemanDir) {
+ private Artifact getStampFileArtifact(
+ String middlemanName, String purpose, ArtifactRoot middlemanDir) {
String escapedFilename = Actions.escapedPath(middlemanName);
PathFragment stampName = PathFragment.create("_middlemen/" + escapedFilename + "-" + purpose);
Artifact stampFile = artifactFactory.getDerivedArtifact(stampName, middlemanDir,