Skip to content

Commit 46c95dc

Browse files
lberkicopybara-github
authored andcommitted
Make proto blacklisting work when virtual import directories are present.
This fixes the fallout from ce65de4 . Afterparty for #7157. RELNOTES: None. PiperOrigin-RevId: 257573726
1 parent e9521d3 commit 46c95dc

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ private static class Impl {
269269
private boolean areSrcsBlacklisted() {
270270
return !new ProtoSourceFileBlacklist(
271271
ruleContext, getProtoToolchainProvider().blacklistedProtos())
272-
.checkSrcs(protoInfo.getDirectProtoSources(), "cc_proto_library");
272+
.checkSrcs(protoInfo.getOriginalDirectProtoSources(), "cc_proto_library");
273273
}
274274

275275
private FeatureConfiguration getFeatureConfiguration() {

src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCommon.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ public static ProtoInfo createProtoInfo(
511511
ProtoInfo protoInfo =
512512
new ProtoInfo(
513513
library.getSources(),
514+
directProtoSources,
514515
library.getSourceRoot(),
515516
transitiveProtoSources,
516517
transitiveProtoSourceRoots,

src/main/java/com/google/devtools/build/lib/rules/proto/ProtoInfo.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public Provider() {
5252
public static final String LEGACY_SKYLARK_NAME = "proto";
5353

5454
private final ImmutableList<Artifact> directProtoSources;
55+
private final ImmutableList<Artifact> originalDirectProtoSources;
5556
private final String directProtoSourceRoot;
5657
private final NestedSet<Artifact> transitiveProtoSources;
5758
private final NestedSet<String> transitiveProtoSourceRoots;
@@ -68,6 +69,7 @@ public Provider() {
6869
@AutoCodec.Instantiator
6970
public ProtoInfo(
7071
ImmutableList<Artifact> directProtoSources,
72+
ImmutableList<Artifact> originalDirectProtoSources,
7173
String directProtoSourceRoot,
7274
NestedSet<Artifact> transitiveProtoSources,
7375
NestedSet<String> transitiveProtoSourceRoots,
@@ -82,6 +84,7 @@ public ProtoInfo(
8284
Location location) {
8385
super(PROVIDER, location);
8486
this.directProtoSources = directProtoSources;
87+
this.originalDirectProtoSources = originalDirectProtoSources;
8588
this.directProtoSourceRoot = directProtoSourceRoot;
8689
this.transitiveProtoSources = transitiveProtoSources;
8790
this.transitiveProtoSourceRoots = transitiveProtoSourceRoots;
@@ -96,12 +99,21 @@ public ProtoInfo(
9699
this.transitiveDescriptorSets = transitiveDescriptorSets;
97100
}
98101

99-
/** The proto sources of the {@code proto_library} declaring this provider. */
102+
/**
103+
* The proto source files that are used in compiling this {@code proto_library}.
104+
*
105+
* <p>Different from {@link #getOriginalDirectProtoSources()} when a virtual import root is used.
106+
*/
100107
@Override
101108
public ImmutableList<Artifact> getDirectProtoSources() {
102109
return directProtoSources;
103110
}
104111

112+
/** The proto sources of the {@code proto_library} declaring this provider. */
113+
public ImmutableList<Artifact> getOriginalDirectProtoSources() {
114+
return originalDirectProtoSources;
115+
}
116+
105117
/** The source root of the current library. */
106118
@Override
107119
public String getDirectProtoSourceRoot() {

src/test/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilderTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ private ProtoInfo protoInfo(
6464
NestedSet<Pair<Artifact, String>> strictImportableProtos,
6565
NestedSet<Pair<Artifact, String>> exportedProtos) {
6666
return new ProtoInfo(
67+
directProtos,
6768
directProtos,
6869
"",
6970
transitiveProtos,

0 commit comments

Comments
 (0)