aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/config/BuildOptions.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/config/DefaultsPackage.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/config/FragmentOptions.java13
3 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildOptions.java
index 8b44f65470..cee3ceb0e1 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildOptions.java
@@ -156,6 +156,15 @@ public final class BuildOptions implements Cloneable, Serializable {
return result.build();
}
+ ImmutableList<String> getDefaultsRules() {
+ ImmutableList.Builder<String> result = ImmutableList.builder();
+ for (FragmentOptions fragment : fragmentOptionsMap.values()) {
+ result.addAll(fragment.getDefaultsRules());
+ }
+
+ return result.build();
+ }
+
/**
* The cache key for the options collection. Recomputes cache key every time it's called.
*/
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/DefaultsPackage.java b/src/main/java/com/google/devtools/build/lib/analysis/config/DefaultsPackage.java
index 7d92bcedd7..e04633011f 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/DefaultsPackage.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/DefaultsPackage.java
@@ -15,6 +15,7 @@
package com.google.devtools.build.lib.analysis.config;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.syntax.Label;
@@ -93,9 +94,11 @@ public final class DefaultsPackage {
* The map from entries to their values.
*/
private ImmutableMap<String, ImmutableSet<Label>> values;
+ private ImmutableList<String> rules;
private DefaultsPackage(BuildOptions buildOptions) {
values = buildOptions.getDefaultsLabels();
+ rules = buildOptions.getDefaultsRules();
}
private String labelsToString(Set<Label> labels) {
@@ -122,6 +125,11 @@ public final class DefaultsPackage {
.append(" srcs = [")
.append(labelsToString(entry.getValue())).append("])\n");
}
+
+ for (String rule : rules) {
+ result.append(rule).append("\n");
+ }
+
return result.toString();
}
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/FragmentOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/config/FragmentOptions.java
index ce4b2d2689..c7b8c47206 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/FragmentOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/FragmentOptions.java
@@ -57,6 +57,19 @@ public abstract class FragmentOptions extends OptionsBase implements Cloneable,
}
/**
+ * Returns the extra rules contributed to the default package by this fragment.
+ *
+ * <p>The return value should be a list of strings, which are merged into the BUILD files of the
+ * defaults package.
+ *
+ * <p><strong>WARNING;</strong> this method should only be used when absolutely necessary. Always
+ * prefer {@code getDefaultsLabels()} to this.
+ */
+ public ImmutableList<String> getDefaultsRules() {
+ return ImmutableList.of();
+ }
+
+ /**
* Returns a list of potential split configuration transitions for this fragment. Split
* configurations usually need to be explicitly enabled by passing in an option.
*/