Skip to content

Commit

Permalink
Make proto blacklisting work when virtual import directories are pres…
Browse files Browse the repository at this point in the history
…ent.

This fixes the fallout from ce65de4 .

Afterparty for #7157.

RELNOTES: None.
PiperOrigin-RevId: 257573726
  • Loading branch information
lberki authored and copybara-github committed Jul 11, 2019
1 parent e9521d3 commit 46c95dc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private static class Impl {
private boolean areSrcsBlacklisted() {
return !new ProtoSourceFileBlacklist(
ruleContext, getProtoToolchainProvider().blacklistedProtos())
.checkSrcs(protoInfo.getDirectProtoSources(), "cc_proto_library");
.checkSrcs(protoInfo.getOriginalDirectProtoSources(), "cc_proto_library");
}

private FeatureConfiguration getFeatureConfiguration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ public static ProtoInfo createProtoInfo(
ProtoInfo protoInfo =
new ProtoInfo(
library.getSources(),
directProtoSources,
library.getSourceRoot(),
transitiveProtoSources,
transitiveProtoSourceRoots,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public Provider() {
public static final String LEGACY_SKYLARK_NAME = "proto";

private final ImmutableList<Artifact> directProtoSources;
private final ImmutableList<Artifact> originalDirectProtoSources;
private final String directProtoSourceRoot;
private final NestedSet<Artifact> transitiveProtoSources;
private final NestedSet<String> transitiveProtoSourceRoots;
Expand All @@ -68,6 +69,7 @@ public Provider() {
@AutoCodec.Instantiator
public ProtoInfo(
ImmutableList<Artifact> directProtoSources,
ImmutableList<Artifact> originalDirectProtoSources,
String directProtoSourceRoot,
NestedSet<Artifact> transitiveProtoSources,
NestedSet<String> transitiveProtoSourceRoots,
Expand All @@ -82,6 +84,7 @@ public ProtoInfo(
Location location) {
super(PROVIDER, location);
this.directProtoSources = directProtoSources;
this.originalDirectProtoSources = originalDirectProtoSources;
this.directProtoSourceRoot = directProtoSourceRoot;
this.transitiveProtoSources = transitiveProtoSources;
this.transitiveProtoSourceRoots = transitiveProtoSourceRoots;
Expand All @@ -96,12 +99,21 @@ public ProtoInfo(
this.transitiveDescriptorSets = transitiveDescriptorSets;
}

/** The proto sources of the {@code proto_library} declaring this provider. */
/**
* The proto source files that are used in compiling this {@code proto_library}.
*
* <p>Different from {@link #getOriginalDirectProtoSources()} when a virtual import root is used.
*/
@Override
public ImmutableList<Artifact> getDirectProtoSources() {
return directProtoSources;
}

/** The proto sources of the {@code proto_library} declaring this provider. */
public ImmutableList<Artifact> getOriginalDirectProtoSources() {
return originalDirectProtoSources;
}

/** The source root of the current library. */
@Override
public String getDirectProtoSourceRoot() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private ProtoInfo protoInfo(
NestedSet<Pair<Artifact, String>> strictImportableProtos,
NestedSet<Pair<Artifact, String>> exportedProtos) {
return new ProtoInfo(
directProtos,
directProtos,
"",
transitiveProtos,
Expand Down

0 comments on commit 46c95dc

Please sign in to comment.