diff options
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/proto/BUILD | 20 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java | 15 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibrary.java | 47 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryOutputGroupProvider.java | 34 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryProviders.java (renamed from src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryFilesToBuilderProvider.java) | 9 |
5 files changed, 30 insertions, 95 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/BUILD b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/BUILD index e81fe72905..c93e0c29a1 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/BUILD +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/BUILD @@ -15,8 +15,7 @@ java_library( "CcProtoLibraryRule.java", ], deps = [ - ":CcProtoLibraryFilesToBuilderProvider", - ":CcProtoLibraryOutputGroupProvider", + ":CcProtoLibraryProviders", ":ProtoCcHeaderProvider", "//src/main/java/com/google/devtools/build/lib:build-base", "//src/main/java/com/google/devtools/build/lib:collect", @@ -32,25 +31,14 @@ java_library( ) java_library( - name = "CcProtoLibraryFilesToBuilderProvider", - srcs = ["CcProtoLibraryFilesToBuilderProvider.java"], - deps = [ - "//src/main/java/com/google/devtools/build/lib:collect", - "//src/main/java/com/google/devtools/build/lib:concurrent", - "//src/main/java/com/google/devtools/build/lib:transitive-info-provider", - "//src/main/java/com/google/devtools/build/lib/actions", - ], -) - -java_library( - name = "CcProtoLibraryOutputGroupProvider", - srcs = ["CcProtoLibraryOutputGroupProvider.java"], + name = "CcProtoLibraryProviders", + srcs = ["CcProtoLibraryProviders.java"], deps = [ + "//src/main/java/com/google/devtools/build/lib:build-base", "//src/main/java/com/google/devtools/build/lib:collect", "//src/main/java/com/google/devtools/build/lib:concurrent", "//src/main/java/com/google/devtools/build/lib:transitive-info-provider", "//src/main/java/com/google/devtools/build/lib/actions", - "//third_party:guava", ], ) diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java index de5e8b9796..a0aaa5a2ce 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java @@ -26,6 +26,7 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.ConfiguredAspect; import com.google.devtools.build.lib.analysis.ConfiguredAspectFactory; import com.google.devtools.build.lib.analysis.ConfiguredTarget; +import com.google.devtools.build.lib.analysis.OutputGroupProvider; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; @@ -177,11 +178,11 @@ public class CcProtoAspect extends NativeAspectClass implements ConfiguredAspect // proto_library pretends to not generate them either. boolean hasDepWithoutPbH = false; NestedSetBuilder<Artifact> transitiveHeaders = NestedSetBuilder.stableOrder(); - for (ProtoCcHeaderProvider headerProvider : + for (ProtoCcHeaderProvider provider : ruleContext.getPrerequisites("deps", TARGET, ProtoCcHeaderProvider.class)) { - helper.addPublicTextualHeaders(headerProvider.getHeaders()); - transitiveHeaders.addTransitive(headerProvider.getHeaders()); - hasDepWithoutPbH = hasDepWithoutPbH || !headerProvider.getGeneratesPbH(); + helper.addPublicTextualHeaders(provider.getHeaders()); + transitiveHeaders.addTransitive(provider.getHeaders()); + hasDepWithoutPbH = hasDepWithoutPbH || !provider.getGeneratesPbH(); } headerProvider = new ProtoCcHeaderProvider(transitiveHeaders.build(), !hasDepWithoutPbH); } @@ -297,9 +298,11 @@ public class CcProtoAspect extends NativeAspectClass implements ConfiguredAspect } public void addProviders(ConfiguredAspect.Builder builder) { + builder.addProvider( + new CcProtoLibraryProviders( + filesBuilder.build(), + ccLibraryProviders.toBuilder().add(new OutputGroupProvider(outputGroups)).build())); builder.addProviders(ccLibraryProviders); - builder.addProvider(new CcProtoLibraryFilesToBuilderProvider(filesBuilder.build())); - builder.addProvider(new CcProtoLibraryOutputGroupProvider(outputGroups)); if (headerProvider != null) { builder.addProvider(headerProvider); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibrary.java index b92501be5c..1f03ef16d0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibrary.java @@ -22,14 +22,8 @@ import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.Runfiles; import com.google.devtools.build.lib.analysis.RunfilesProvider; -import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; -import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory; -import com.google.devtools.build.lib.rules.cpp.CcExecutionDynamicLibrariesProvider; -import com.google.devtools.build.lib.rules.cpp.CcLinkParamsProvider; -import com.google.devtools.build.lib.rules.cpp.CcNativeLibraryProvider; import com.google.devtools.build.lib.rules.cpp.CcSkylarkApiProvider; -import com.google.devtools.build.lib.rules.cpp.CcSpecificLinkParamsProvider; /** Part of the implementation of cc_proto_library. */ public class CcProtoLibrary implements RuleConfiguredTargetFactory { @@ -47,35 +41,16 @@ public class CcProtoLibrary implements RuleConfiguredTargetFactory { + "to remove unused deps."); } - TransitiveInfoCollection dep = checkNotNull(ruleContext.getPrerequisite("deps", TARGET)); - - RuleConfiguredTargetBuilder result = - new RuleConfiguredTargetBuilder(ruleContext) - .setFilesToBuild( - dep.getProvider(CcProtoLibraryFilesToBuilderProvider.class).filesBuilder) - .addProvider( - RunfilesProvider.class, RunfilesProvider.withData(Runfiles.EMPTY, Runfiles.EMPTY)); - - addProviderIfNotNull(result, dep.getProvider(CcLinkParamsProvider.class)); - addProviderIfNotNull(result, dep.getProvider(CcNativeLibraryProvider.class)); - addProviderIfNotNull(result, dep.getProvider(CcExecutionDynamicLibrariesProvider.class)); - addProviderIfNotNull(result, dep.getProvider(CcSpecificLinkParamsProvider.class)); - addProviderIfNotNull(result, dep.getProvider(ProtoCcHeaderProvider.class)); - - result.addSkylarkTransitiveInfo(CcSkylarkApiProvider.NAME, new CcSkylarkApiProvider()); - - CcProtoLibraryOutputGroupProvider outputGroups = - dep.getProvider(CcProtoLibraryOutputGroupProvider.class); - if (outputGroups != null) { - result.addOutputGroups(outputGroups.outputGroups); - } - return result.build(); - } - - private void addProviderIfNotNull( - RuleConfiguredTargetBuilder result, TransitiveInfoProvider provider) { - if (provider != null) { - result.addProvider(provider); - } + CcProtoLibraryProviders depProviders = + checkNotNull(ruleContext.getPrerequisite("deps", TARGET)) + .getProvider(CcProtoLibraryProviders.class); + + return new RuleConfiguredTargetBuilder(ruleContext) + .setFilesToBuild(depProviders.filesBuilder) + .addProvider( + RunfilesProvider.class, RunfilesProvider.withData(Runfiles.EMPTY, Runfiles.EMPTY)) + .addProviders(depProviders.providerMap) + .addSkylarkTransitiveInfo(CcSkylarkApiProvider.NAME, new CcSkylarkApiProvider()) + .build(); } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryOutputGroupProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryOutputGroupProvider.java deleted file mode 100644 index 49fe3ece15..0000000000 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryOutputGroupProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.devtools.build.lib.rules.cpp.proto; - -import com.google.common.collect.ImmutableMap; -import com.google.devtools.build.lib.actions.Artifact; -import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; -import com.google.devtools.build.lib.collect.nestedset.NestedSet; -import com.google.devtools.build.lib.concurrent.ThreadSafety; - -/** - * Used by CcProtoAspect to propagate output groups to CcProtoLibrary, where it is exposed via - * setOutputGroups(). - */ -@ThreadSafety.Immutable -final class CcProtoLibraryOutputGroupProvider implements TransitiveInfoProvider { - final ImmutableMap<String, NestedSet<Artifact>> outputGroups; - - CcProtoLibraryOutputGroupProvider(ImmutableMap<String, NestedSet<Artifact>> outputGroups) { - this.outputGroups = outputGroups; - } -} diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryFilesToBuilderProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryProviders.java index 8170cd470d..35b53d8894 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryFilesToBuilderProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoLibraryProviders.java @@ -16,18 +16,21 @@ package com.google.devtools.build.lib.rules.cpp.proto; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; +import com.google.devtools.build.lib.analysis.TransitiveInfoProviderMap; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.concurrent.ThreadSafety; /** - * Used by CcProtoAspect to propagate files-to-build to CcProtoLibrary, where it is exposed via + * Used by CcProtoAspect to propagate providers to CcProtoLibrary, where it is exposed via * setFilesToBuild(). */ @ThreadSafety.Immutable -final class CcProtoLibraryFilesToBuilderProvider implements TransitiveInfoProvider { +final class CcProtoLibraryProviders implements TransitiveInfoProvider { final NestedSet<Artifact> filesBuilder; + final TransitiveInfoProviderMap providerMap; - CcProtoLibraryFilesToBuilderProvider(NestedSet<Artifact> filesBuilder) { + CcProtoLibraryProviders(NestedSet<Artifact> filesBuilder, TransitiveInfoProviderMap providerMap) { this.filesBuilder = filesBuilder; + this.providerMap = providerMap; } } |