aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Sergio Campama <kaipi@google.com>2016-07-22 23:58:42 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-07-25 11:40:13 +0000
commit5a7b28c6e6e5cc1e3049a94719fd2ab16b8215dc (patch)
treef1fc7ac6a80b685ac56368fc86b1536121536649 /src
parent69a712046cf25a0f4be374ba1a780945d1a26b60 (diff)
*** Reason for rollback *** Prevent [] from burning up *** Original change description *** Make the proto bundling behavior the default when using the new library. -- MOS_MIGRATED_REVID=128226570
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java19
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java12
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspect.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibrary.java20
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ProtoSupport.java165
8 files changed, 100 insertions, 148 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java
index ff039681f8..017d245b81 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java
@@ -44,6 +44,7 @@ import com.google.devtools.build.lib.rules.cpp.CcToolchainProvider;
import com.google.devtools.build.lib.rules.objc.CompilationSupport.ExtraLinkArgs;
import com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes;
import com.google.devtools.build.lib.rules.objc.ProtoSupport.TargetType;
+
import java.util.List;
import java.util.Set;
@@ -123,10 +124,10 @@ public class AppleBinary implements RuleConfiguredTargetFactory {
archivesToLipo.add(common.getCompilationArtifacts().get().getArchive().get());
binariesToLipo.add(intermediateArtifacts.strippedSingleArchitectureBinary());
- ProtoSupport protoSupport =
- new ProtoSupport(ruleContext, TargetType.LINKING_TARGET, childConfig);
- if (protoSupport.hasProtos()) {
- protoSupport.registerActions();
+ ObjcConfiguration objcConfiguration = childConfig.getFragment(ObjcConfiguration.class);
+ if (objcConfiguration.experimentalAutoTopLevelUnionObjCProtos()) {
+ ProtoSupport protoSupport =
+ new ProtoSupport(ruleContext, TargetType.LINKING_TARGET).registerActions();
ObjcCommon protoCommon = protoSupport.getCommon();
new CompilationSupport(
@@ -175,11 +176,13 @@ public class AppleBinary implements RuleConfiguredTargetFactory {
CompilationArtifacts compilationArtifacts =
CompilationSupport.compilationArtifacts(ruleContext, intermediateArtifacts);
- ProtoSupport protoSupport =
- new ProtoSupport(ruleContext, TargetType.LINKING_TARGET, buildConfiguration);
- Optional<Artifact> protoLib = Optional.absent();
- if (protoSupport.hasProtos()) {
+ Optional<Artifact> protoLib;
+ ObjcConfiguration objcConfiguration = buildConfiguration.getFragment(ObjcConfiguration.class);
+ if (objcConfiguration.experimentalAutoTopLevelUnionObjCProtos()) {
+ ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.LINKING_TARGET);
protoLib = protoSupport.getCommon().getCompiledArchive();
+ } else {
+ protoLib = Optional.absent();
}
return new ObjcCommon.Builder(ruleContext, buildConfiguration)
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java b/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java
index 516566fddb..8579bb4966 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java
@@ -75,13 +75,14 @@ abstract class BinaryLinkingTargetFactory implements RuleConfiguredTargetFactory
@Override
public final ConfiguredTarget create(RuleContext ruleContext)
throws InterruptedException, RuleErrorException {
+ ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext);
+
ObjcProvider protosObjcProvider = null;
XcodeProvider protosXcodeProvider = null;
- ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.LINKING_TARGET);
- if (protoSupport.hasProtos()) {
+ if (objcConfiguration.experimentalAutoTopLevelUnionObjCProtos()) {
XcodeProvider.Builder protosXcodeProviderBuilder = new XcodeProvider.Builder();
- protoSupport
+ ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.LINKING_TARGET)
.registerActions()
.addXcodeProviderOptions(protosXcodeProviderBuilder);
@@ -142,7 +143,6 @@ abstract class BinaryLinkingTargetFactory implements RuleConfiguredTargetFactory
DsymOutputType.APP)
.validateAttributes();
- ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext);
Optional<XcTestAppProvider> xcTestAppProvider;
Optional<RunfilesSupport> maybeRunfilesSupport = Optional.absent();
switch (hasReleaseBundlingSupport) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java
index 99d5dc7dbb..5e22cd713c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java
@@ -83,13 +83,14 @@ public final class IosTest implements RuleConfiguredTargetFactory {
@Override
public final ConfiguredTarget create(RuleContext ruleContext)
throws InterruptedException, RuleErrorException {
+ ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext);
+
ObjcProvider protosObjcProvider = null;
XcodeProvider protosXcodeProvider = null;
- ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.LINKING_TARGET);
- if (protoSupport.hasProtos()) {
+ if (objcConfiguration.experimentalAutoTopLevelUnionObjCProtos()) {
XcodeProvider.Builder protosXcodeProviderBuilder = new XcodeProvider.Builder();
- protoSupport
+ ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.LINKING_TARGET)
.registerActions()
.addXcodeProviderOptions(protosXcodeProviderBuilder);
@@ -122,6 +123,7 @@ public final class IosTest implements RuleConfiguredTargetFactory {
}
NestedSetBuilder<Artifact> filesToBuild = NestedSetBuilder.stableOrder();
addResourceFilesToBuild(ruleContext, common.getObjcProvider(), filesToBuild);
+
XcodeProductType productType = getProductType(ruleContext);
ExtraLinkArgs extraLinkArgs;
Iterable<Artifact> extraLinkInputs;
@@ -165,8 +167,6 @@ public final class IosTest implements RuleConfiguredTargetFactory {
ruleContext.getPrerequisites("deps", Mode.TARGET, J2ObjcEntryClassProvider.class))
.build();
- ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext);
-
new CompilationSupport(ruleContext)
.registerLinkActions(
common.getObjcProvider(),
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java
index cd49ad6eab..36821e9baa 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java
@@ -25,6 +25,7 @@ import com.google.devtools.build.lib.rules.apple.DottedVersion;
import com.google.devtools.build.lib.rules.apple.DottedVersionConverter;
import com.google.devtools.common.options.Converters.CommaSeparatedOptionListConverter;
import com.google.devtools.common.options.Option;
+
import java.util.List;
/**
@@ -183,9 +184,11 @@ public class ObjcCommandLineOptions extends FragmentOptions {
// TODO(b/28451644): Make this option the default behavior.
@Option(
name = "experimental_auto_top_level_union_objc_protos",
- defaultValue = "true",
+ defaultValue = "false",
category = "flags",
- help = "This flag is a noop and scheduled for removal."
+ help =
+ "Specifies whether to use the experimental proto generation scheme, in which they are all "
+ + "generated and linked into the final linking target."
)
public boolean experimentalAutoTopLevelUnionObjCProtos;
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java
index 6888b1ebe4..fc7d5cfc0d 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java
@@ -27,6 +27,7 @@ import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.lib.vfs.Path;
+
import javax.annotation.Nullable;
/** A compiler configuration containing flags required for Objective-C compilation. */
@@ -68,6 +69,7 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment {
private final boolean useAbsolutePathsForActions;
private final boolean prioritizeStaticLibs;
private final boolean debugWithGlibcxx;
+ private final boolean experimentalAutoTopLevelUnionObjCProtos;
@Nullable private final Label extraEntitlements;
private final boolean deviceDebugEntitlements;
@@ -93,6 +95,8 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment {
this.prioritizeStaticLibs = objcOptions.prioritizeStaticLibs;
this.debugWithGlibcxx = objcOptions.debugWithGlibcxx;
this.extraEntitlements = objcOptions.extraEntitlements;
+ this.experimentalAutoTopLevelUnionObjCProtos =
+ objcOptions.experimentalAutoTopLevelUnionObjCProtos;
this.deviceDebugEntitlements = objcOptions.deviceDebugEntitlements;
}
@@ -267,6 +271,14 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment {
}
/**
+ * Whether the experimental feature of only generating proto sources at the linking target is
+ * enabled or not.
+ */
+ public boolean experimentalAutoTopLevelUnionObjCProtos() {
+ return experimentalAutoTopLevelUnionObjCProtos;
+ }
+
+ /**
* Returns whether device debug entitlements should be included when signing an application.
*
* <p>Note that debug entitlements should not be included in compilation mode {@code opt}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspect.java
index 01bea3c0d3..5239bf43e0 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspect.java
@@ -37,6 +37,7 @@ public class ObjcProtoAspect extends NativeAspectClass implements ConfiguredAspe
public AspectDefinition getDefinition(AspectParameters aspectParameters) {
return new AspectDefinition.Builder(NAME)
.attributeAspect("deps", this)
+ .requiresConfigurationFragments(ObjcConfiguration.class)
.build();
}
@@ -45,6 +46,12 @@ public class ObjcProtoAspect extends NativeAspectClass implements ConfiguredAspe
ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters)
throws InterruptedException {
ConfiguredAspect.Builder aspectBuilder = new ConfiguredAspect.Builder(NAME, ruleContext);
+ ObjcConfiguration objcConfiguration = ruleContext.getFragment(ObjcConfiguration.class);
+
+ if (!objcConfiguration.experimentalAutoTopLevelUnionObjCProtos()) {
+ // Only process the aspect if the experimental flag is set.
+ return aspectBuilder.build();
+ }
ObjcProtoProvider.Builder aspectObjcProtoProvider = new ObjcProtoProvider.Builder();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibrary.java
index bd4f50e919..344d5d3f14 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibrary.java
@@ -35,18 +35,17 @@ public class ObjcProtoLibrary implements RuleConfiguredTargetFactory {
XcodeProvider.Builder xcodeProviderBuilder = new XcodeProvider.Builder();
NestedSetBuilder<Artifact> filesToBuild = NestedSetBuilder.stableOrder();
- ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.PROTO_TARGET)
- .validate();
+ ProtoSupport protoSupport =
+ new ProtoSupport(ruleContext, TargetType.PROTO_TARGET)
+ .validate()
+ .addXcodeProviderOptions(xcodeProviderBuilder)
+ .addFilesToBuild(filesToBuild)
+ .registerActions();
if (ruleContext.hasErrors()) {
return null;
}
- protoSupport
- .addXcodeProviderOptions(xcodeProviderBuilder)
- .addFilesToBuild(filesToBuild)
- .registerActions();
-
ObjcCommon common = protoSupport.getCommon();
filesToBuild.addAll(common.getCompiledArchive().asSet());
@@ -60,9 +59,14 @@ public class ObjcProtoLibrary implements RuleConfiguredTargetFactory {
boolean usesProtobufLibrary = protoSupport.usesProtobufLibrary();
+ boolean experimentalAutoUnion =
+ ObjcRuleClasses.objcConfiguration(ruleContext).experimentalAutoTopLevelUnionObjCProtos();
+
CompilationSupport compilationSupport = new CompilationSupport(ruleContext);
- if (!usesProtobufLibrary) {
+ // If the experimental flag is not set, or if it's set and doesn't use the protobuf library,
+ // register the compilation actions, as the output needs to be linked in the final binary.
+ if (!experimentalAutoUnion || !usesProtobufLibrary) {
compilationSupport.registerCompileAndArchiveActions(common);
} else {
// Even though there is nothing to compile, still generate a module map based on this target
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoSupport.java
index c499a94b4a..2f57efb8a6 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtoSupport.java
@@ -28,12 +28,11 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Ordering;
import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.analysis.FileProvider;
+import com.google.devtools.build.lib.analysis.PrerequisiteArtifacts;
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
import com.google.devtools.build.lib.analysis.actions.FileWriteAction;
-import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
@@ -44,7 +43,9 @@ import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.util.FileType;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.PathFragment;
+
import java.util.ArrayList;
+
import javax.annotation.Nullable;
/**
@@ -130,23 +131,8 @@ final class ProtoSupport {
* @param targetType the type of target generating the protos
*/
public ProtoSupport(RuleContext ruleContext, TargetType targetType) {
- this(ruleContext, targetType, null);
- }
-
- /**
- * Creates a new proto support.
- *
- * @param ruleContext context this proto library is constructed in
- * @param targetType the type of target generating the protos
- * @param buildConfiguration the configuration from which to get prerequisites when building proto
- * targets in a split configuration
- */
- public ProtoSupport(
- RuleContext ruleContext,
- TargetType targetType,
- BuildConfiguration buildConfiguration) {
this.ruleContext = ruleContext;
- this.attributes = new Attributes(ruleContext, buildConfiguration);
+ this.attributes = new Attributes(ruleContext);
this.targetType = targetType;
if (targetType != TargetType.PROTO_TARGET) {
// Use a a prefixed version of the intermediate artifacts to avoid naming collisions, as
@@ -172,7 +158,7 @@ final class ProtoSupport {
* @return this proto support
*/
public ProtoSupport validate() {
- if (!hasProtos()) {
+ if (attributes.getProtoFiles().isEmpty()) {
ruleContext.ruleError(NO_PROTOS_ERROR);
}
@@ -213,8 +199,10 @@ final class ProtoSupport {
* @return this proto support
*/
public ProtoSupport registerActions() {
- registerProtoInputListFileAction();
- registerGenerateProtoFilesAction();
+ if (!Iterables.isEmpty(getFilteredProtoSources())) {
+ registerProtoInputListFileAction();
+ registerGenerateProtoFilesAction();
+ }
return this;
}
@@ -229,11 +217,14 @@ final class ProtoSupport {
.setCompilationArtifacts(getCompilationArtifacts());
if (targetType == TargetType.LINKING_TARGET) {
- commonBuilder.addDepObjcProviders(attributes.getDepsObjcPrerequisites());
+ commonBuilder.addDepObjcProviders(
+ ruleContext.getPrerequisites("deps", Mode.TARGET, ObjcProvider.class));
} else if (targetType == TargetType.PROTO_TARGET) {
- commonBuilder.addDepObjcProviders(attributes.getProtoLibObjcPrerequisites());
+ commonBuilder.addDepObjcProviders(
+ ruleContext.getPrerequisites(
+ ObjcRuleClasses.PROTO_LIB_ATTR, Mode.TARGET, ObjcProvider.class));
- if (usesProtobufLibrary()) {
+ if (usesProtobufLibrary() && experimentalAutoUnion()) {
commonBuilder.addDirectDependencyHeaderSearchPaths(getUserHeaderSearchPaths());
} else {
commonBuilder.addUserHeaderSearchPaths(getUserHeaderSearchPaths());
@@ -301,9 +292,15 @@ final class ProtoSupport {
builder.addAdditionalHdrs(generatedSources);
}
- if ((targetType == TargetType.PROTO_TARGET && !usesProtobufLibrary())
- || targetType == TargetType.LINKING_TARGET) {
- builder.addNonArcSrcs(generatedSources);
+ if (experimentalAutoUnion()) {
+ if ((targetType == TargetType.PROTO_TARGET && !usesProtobufLibrary())
+ || targetType == TargetType.LINKING_TARGET) {
+ builder.addNonArcSrcs(generatedSources);
+ }
+ } else {
+ if (targetType == TargetType.PROTO_TARGET) {
+ builder.addNonArcSrcs(generatedSources);
+ }
}
return builder.build();
@@ -337,19 +334,13 @@ final class ProtoSupport {
return attributes.hasPortableProtoFilters() || targetType == TargetType.LINKING_TARGET;
}
- /**
- * Returns whether there are protos to be compiled.
- */
- public boolean hasProtos() {
- return !Iterables.isEmpty(getFilteredProtoSources());
- }
-
private Iterable<Artifact> getAllProtoSources() {
NestedSetBuilder<Artifact> protos = NestedSetBuilder.stableOrder();
- if (targetType == TargetType.LINKING_TARGET) {
- Iterable<ObjcProtoProvider> objcProtoPrividers = attributes.getDepsObjcProtoPrerequisites();
- for (ObjcProtoProvider objcProtoProvider : objcProtoPrividers) {
+ if (experimentalAutoUnion() && targetType == TargetType.LINKING_TARGET) {
+ Iterable<ObjcProtoProvider> objcProtoProviders =
+ ruleContext.getPrerequisites("deps", Mode.TARGET, ObjcProtoProvider.class);
+ for (ObjcProtoProvider objcProtoProvider : objcProtoProviders) {
protos.addTransitive(objcProtoProvider.getProtoSources());
}
}
@@ -389,8 +380,10 @@ final class ProtoSupport {
private NestedSet<Artifact> getPortableProtoFilters() {
NestedSetBuilder<Artifact> portableProtoFilters = NestedSetBuilder.stableOrder();
- if (targetType == TargetType.LINKING_TARGET) {
- for (ObjcProtoProvider objcProtoProvider : attributes.getDepsObjcProtoPrerequisites()) {
+ if (experimentalAutoUnion() && targetType == TargetType.LINKING_TARGET) {
+ Iterable<ObjcProtoProvider> objcProtoProviders =
+ ruleContext.getPrerequisites("deps", Mode.TARGET, ObjcProtoProvider.class);
+ for (ObjcProtoProvider objcProtoProvider : objcProtoProviders) {
portableProtoFilters.addTransitive(objcProtoProvider.getPortableProtoFilters());
}
}
@@ -399,6 +392,11 @@ final class ProtoSupport {
return portableProtoFilters.build();
}
+ private boolean experimentalAutoUnion() {
+ ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext);
+ return objcConfiguration.experimentalAutoTopLevelUnionObjCProtos();
+ }
+
private void registerProtoInputListFileAction() {
ruleContext.registerAction(
new FileWriteAction(
@@ -626,78 +624,9 @@ final class ProtoSupport {
*/
private static class Attributes {
private final RuleContext ruleContext;
- private final BuildConfiguration buildConfiguration;
- private Attributes(RuleContext ruleContext, BuildConfiguration buildConfiguration) {
+ private Attributes(RuleContext ruleContext) {
this.ruleContext = ruleContext;
- this.buildConfiguration = buildConfiguration;
- }
-
- /**
- * Returns the FileProviders for the deps attribute, using the split build configuration
- * if one is available.
- */
- Iterable<FileProvider> getDepsFilePrerequisites() {
- if (buildConfiguration != null) {
- return ruleContext
- .getPrerequisitesByConfiguration("deps", Mode.SPLIT, FileProvider.class)
- .get(buildConfiguration);
- }
- return ruleContext.getPrerequisites("deps", Mode.TARGET, FileProvider.class);
- }
-
- /**
- * Returns the ProtoSourcesProviders for the deps attribute, using the split build configuration
- * if one is available.
- */
- Iterable<ProtoSourcesProvider> getDepsProtoSourcesPrerequisites() {
- if (buildConfiguration != null) {
- return ruleContext
- .getPrerequisitesByConfiguration("deps", Mode.SPLIT, ProtoSourcesProvider.class)
- .get(buildConfiguration);
- }
- return ruleContext.getPrerequisites("deps", Mode.TARGET, ProtoSourcesProvider.class);
- }
-
- /**
- * Returns the ObjcProtoProviders for the deps attribute, using the split build configuration
- * if one is available.
- */
- Iterable<ObjcProtoProvider> getDepsObjcProtoPrerequisites() {
- if (buildConfiguration != null) {
- return ruleContext
- .getPrerequisitesByConfiguration("deps", Mode.SPLIT, ObjcProtoProvider.class)
- .get(buildConfiguration);
- }
- return ruleContext.getPrerequisites("deps", Mode.TARGET, ObjcProtoProvider.class);
- }
-
- /**
- * Returns the ObjcProviders for the deps attribute, using the split build configuration
- * if one is available.
- */
- Iterable<ObjcProvider> getDepsObjcPrerequisites() {
- if (buildConfiguration != null) {
- return ruleContext
- .getPrerequisitesByConfiguration("deps", Mode.SPLIT, ObjcProvider.class)
- .get(buildConfiguration);
- }
- return ruleContext.getPrerequisites("deps", Mode.TARGET, ObjcProvider.class);
- }
-
- /**
- * Returns the ObjcProviders for the internal proto library dependency attribute, using the
- * split build configuration if one is available.
- */
- Iterable<ObjcProvider> getProtoLibObjcPrerequisites() {
- if (buildConfiguration != null) {
- return ruleContext
- .getPrerequisitesByConfiguration(ObjcRuleClasses.PROTO_LIB_ATTR,
- Mode.SPLIT, ObjcProvider.class)
- .get(buildConfiguration);
- }
- return ruleContext.getPrerequisites(ObjcRuleClasses.PROTO_LIB_ATTR,
- Mode.TARGET, ObjcProvider.class);
}
/**
@@ -812,17 +741,10 @@ final class ProtoSupport {
* Returns the list of proto files that were added directly into the deps attributes. This way
* of specifying the protos is deprecated, and displays a warning when the target does so.
*/
- private Iterable<Artifact> getProtoDepsFiles() {
- ImmutableSet.Builder<Artifact> protoFiles = new ImmutableSet.Builder<>();
- for (FileProvider target : getDepsFilePrerequisites()) {
- for (Artifact file : target.getFilesToBuild()) {
- if (file.getFilename().endsWith(".proto")) {
- protoFiles.add(file);
- }
- }
- }
-
- ImmutableSet<Artifact> protos = protoFiles.build();
+ private ImmutableList<Artifact> getProtoDepsFiles() {
+ PrerequisiteArtifacts prerequisiteArtifacts =
+ ruleContext.getPrerequisiteArtifacts("deps", Mode.TARGET);
+ ImmutableList<Artifact> protos = prerequisiteArtifacts.filter(FileType.of(".proto")).list();
if (!protos.isEmpty()) {
ruleContext.attributeWarning("deps", FILES_DEPRECATED_WARNING);
}
@@ -834,7 +756,8 @@ final class ProtoSupport {
*/
private NestedSet<Artifact> getProtoDepsSources() {
NestedSetBuilder<Artifact> artifacts = NestedSetBuilder.stableOrder();
- Iterable<ProtoSourcesProvider> providers = getDepsProtoSourcesPrerequisites();
+ Iterable<ProtoSourcesProvider> providers =
+ ruleContext.getPrerequisites("deps", Mode.TARGET, ProtoSourcesProvider.class);
for (ProtoSourcesProvider provider : providers) {
artifacts.addTransitive(provider.getTransitiveProtoSources());
}