Add a ServerBuilder, and use that in the module API.
This change is similar to a previous change that introduced WorkspaceBuilder.
--
MOS_MIGRATED_REVID=126799657
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
index 0c8dd59..42c935e 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
@@ -18,6 +18,7 @@
import static com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType.ABSTRACT;
import static com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType.TEST;
+import com.google.common.base.Preconditions;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@@ -55,6 +56,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
+
+import javax.annotation.Nullable;
/**
* Knows about every rule Blaze supports and the associated configuration options.
@@ -108,6 +112,7 @@
ImmutableList.<Class<?>>builder().addAll(SkylarkModules.MODULES);
private ImmutableBiMap.Builder<String, Class<? extends TransitiveInfoProvider>>
registeredSkylarkProviders = ImmutableBiMap.builder();
+ private Map<String, String> platformRegexps = new TreeMap<>();
public void addWorkspaceFilePrefix(String contents) {
defaultWorkspaceFilePrefix.append(contents);
@@ -211,6 +216,26 @@
return this;
}
+ /**
+ * Do not use - this only exists for backwards compatibility! Platform regexps are part of a
+ * legacy mechanism - {@code vardef} - that is not exposed in Bazel.
+ *
+ * <p>{@code vardef} needs explicit support in the rule implementations, and cannot express
+ * conditional dependencies, only conditional attribute values. This mechanism will be
+ * supplanted by configuration dependent attributes, and its effect can usually also be achieved
+ * with select().
+ *
+ * <p>This is a map of platform names to regexps. When a name is used as the third argument to
+ * {@code vardef}, the corresponding regexp is used to match on the C++ abi, and the variable is
+ * only set to that value if the regexp matches. For example, the entry
+ * {@code "oldlinux": "i[34]86-libc[345]-linux"} might define a set of platforms representing
+ * certain older linux releases.
+ */
+ public Builder addPlatformRegexps(Map<String, String> platformRegexps) {
+ this.platformRegexps.putAll(Preconditions.checkNotNull(platformRegexps));
+ return this;
+ }
+
private RuleConfiguredTargetFactory createFactory(
Class<? extends RuleConfiguredTargetFactory> factoryClass) {
try {
@@ -304,6 +329,11 @@
public String getToolsRepository() {
return toolsRepository;
}
+
+ @Nullable
+ public Map<String, String> getPlatformRegexps() {
+ return platformRegexps.isEmpty() ? null : ImmutableMap.copyOf(platformRegexps);
+ }
}
/**