aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Carmi Grushko <carmi@google.com>2016-11-03 18:34:58 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2016-11-03 18:45:43 +0000
commitf2ad683c0873991fd1cbca0fe32b7c81fdc9d26a (patch)
tree09384cff419bb2cddc0ebf268f426b820038cfbc
parent33998a50f2266eab5d10dc32bb560a22dd77a389 (diff)
Make ProtoSourceFileBlacklist take an explicit list of .proto files to blacklist.
This is intead of taking an attribute name and reading it inside of the class. Motivation: using proto_lang_toolchain() rules means there's no longer an attribute that points at the blacklist. Instead, we have an attribute that points at the toolchain, which itself points at the blacklist. -- MOS_MIGRATED_REVID=138096096
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ProtoAttributes.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourceFileBlacklist.java15
4 files changed, 15 insertions, 16 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
index b4bcb8bada..daa56daa12 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
@@ -252,7 +252,11 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe
}
ProtoSourceFileBlacklist protoBlackList =
- new ProtoSourceFileBlacklist(ruleContext, PROTO_SOURCE_FILE_BLACKLIST_ATTR);
+ new ProtoSourceFileBlacklist(
+ ruleContext,
+ ruleContext
+ .getPrerequisiteArtifacts(PROTO_SOURCE_FILE_BLACKLIST_ATTR, Mode.HOST)
+ .list());
return protoBlackList.checkSrcs(supportData.getDirectProtoSources(), "java_proto_library");
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java
index 0c80f2779a..560051505f 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java
@@ -132,7 +132,11 @@ public abstract class AbstractJ2ObjcProtoAspect extends NativeAspectClass
// Avoid pulling in any generated files from blacklisted protos.
ProtoSourceFileBlacklist protoBlacklist =
- new ProtoSourceFileBlacklist(ruleContext, PROTO_SOURCE_FILE_BLACKLIST_ATTR);
+ new ProtoSourceFileBlacklist(
+ ruleContext,
+ ruleContext
+ .getPrerequisiteArtifacts(PROTO_SOURCE_FILE_BLACKLIST_ATTR, Mode.HOST)
+ .list());
ImmutableList<Artifact> filteredProtoSources = ImmutableList.copyOf(
protoBlacklist.filter(protoSources));
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoAttributes.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoAttributes.java
index 6b5c42101a..25f1469dbf 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoAttributes.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoAttributes.java
@@ -228,14 +228,14 @@ final class ProtoAttributes {
*/
Iterable<Artifact> filterWellKnownProtos(Iterable<Artifact> protoFiles) {
ProtoSourceFileBlacklist wellKnownProtoBlacklist =
- new ProtoSourceFileBlacklist(ruleContext, ObjcRuleClasses.PROTOBUF_WELL_KNOWN_TYPES);
+ new ProtoSourceFileBlacklist(ruleContext, getWellKnownTypeProtos());
return wellKnownProtoBlacklist.filter(protoFiles);
}
/** Returns whether the given proto is a well known proto or not. */
boolean isProtoWellKnown(Artifact protoFile) {
ProtoSourceFileBlacklist wellKnownProtoBlacklist =
- new ProtoSourceFileBlacklist(ruleContext, ObjcRuleClasses.PROTOBUF_WELL_KNOWN_TYPES);
+ new ProtoSourceFileBlacklist(ruleContext, getWellKnownTypeProtos());
return wellKnownProtoBlacklist.isBlacklisted(protoFile);
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourceFileBlacklist.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourceFileBlacklist.java
index f324ce5fb3..6ba951753d 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourceFileBlacklist.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourceFileBlacklist.java
@@ -25,7 +25,6 @@ import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.packages.Attribute;
@@ -56,14 +55,13 @@ public class ProtoSourceFileBlacklist {
/**
* Creates a proto source file blacklist.
+ *
* @param ruleContext the proto rule context.
- * @param blacklistAttribute the attribute that points to a filegroup containing the blacklisted
+ * @param blacklistProtoFiles a list of blacklisted .proto files. The list will be iterated.
* protos.
*/
- public ProtoSourceFileBlacklist(RuleContext ruleContext, String blacklistAttribute) {
+ public ProtoSourceFileBlacklist(RuleContext ruleContext, Iterable<Artifact> blacklistProtoFiles) {
this.ruleContext = ruleContext;
- Iterable<Artifact> blacklistProtoFiles =
- ruleContext.getPrerequisiteArtifacts(blacklistAttribute, Mode.HOST).list();
ImmutableSet.Builder<PathFragment> blacklistProtoFilePathsBuilder =
new ImmutableSet.Builder<>();
for (Artifact blacklistProtoFile : blacklistProtoFiles) {
@@ -119,13 +117,6 @@ public class ProtoSourceFileBlacklist {
}
/**
- * Returns blacklisted protos from the given protos.
- */
- private Iterable<Artifact> blacklisted(Iterable<Artifact> protoFiles) {
- return ImmutableSet.copyOf(Iterables.filter(protoFiles, isBlacklistProto));
- }
-
- /**
* Returns whether the given proto file is blacklisted.
*/
public boolean isBlacklisted(Artifact protoFile) {