aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Carmi Grushko <carmi@google.com>2016-06-23 20:35:27 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-06-24 08:12:26 +0000
commitf414b4ed04b23b4744f65cb1c9b129b44206679c (patch)
treecb7c171ee22adb2a69a44dcfd881b0c0166f788d /src/main/java/com
parent2cdc802c6c3d577f10ec42fce83253935378df08 (diff)
--
MOS_MIGRATED_REVID=125712280
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java18
-rw-r--r--src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetBuilder.java18
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationArgs.java2
3 files changed, 36 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
index 9c0c47426d..5025906295 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
@@ -531,6 +531,24 @@ public final class RuleContext extends TargetContext
}
/**
+ * Creates an artifact in a directory that is unique to the package that contains the rule, thus
+ * guaranteeing that it never clashes with artifacts created by rules in other packages.
+ */
+ public Artifact getBinArtifact(String relative) {
+ return getPackageRelativeArtifact(
+ new PathFragment(relative), getConfiguration().getBinDirectory());
+ }
+
+ /**
+ * Creates an artifact in a directory that is unique to the package that contains the rule, thus
+ * guaranteeing that it never clashes with artifacts created by rules in other packages.
+ */
+ public Artifact getGenfilesArtifact(String relative) {
+ return getPackageRelativeArtifact(
+ new PathFragment(relative), getConfiguration().getGenfilesDirectory());
+ }
+
+ /**
* Returns an artifact that can be an output of shared actions. Only use when there is no other
* option.
*
diff --git a/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetBuilder.java b/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetBuilder.java
index e767789a04..b2a4f16678 100644
--- a/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetBuilder.java
@@ -14,6 +14,7 @@
package com.google.devtools.build.lib.collect.nestedset;
import static com.google.common.collect.Iterables.getOnlyElement;
+import static com.google.common.collect.Iterables.isEmpty;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -227,4 +228,21 @@ public final class NestedSetBuilder<E> {
public static <E> NestedSetBuilder<E> fromNestedSet(NestedSet<E> set) {
return new NestedSetBuilder<E>(set.getOrder()).addTransitive(set);
}
+
+ /**
+ * Creates a Builder with the contents of 'sets'.
+ *
+ * <p>If 'sets' is empty, a stable-order empty NestedSet is returned.
+ */
+ public static <E> NestedSetBuilder<E> fromNestedSets(Iterable<NestedSet<E>> sets) {
+ NestedSet<?> firstSet = Iterables.getFirst(sets, null /* defaultValue */);
+ if (firstSet == null) {
+ return stableOrder();
+ }
+ NestedSetBuilder<E> result = new NestedSetBuilder<>(firstSet.getOrder());
+ for (NestedSet<E> set : sets) {
+ result.addTransitive(set);
+ }
+ return result;
+ }
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationArgs.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationArgs.java
index 6cc52a6b81..64229d5ec8 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationArgs.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationArgs.java
@@ -86,8 +86,6 @@ public final class JavaCompilationArgs {
/**
* Builder for {@link JavaCompilationArgs}.
- *
- *
*/
public static final class Builder {
private final NestedSetBuilder<Artifact> runtimeJarsBuilder =