aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Sergio Campama <kaipi@google.com>2016-07-18 19:48:29 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-07-19 18:09:44 +0000
commitee36dd3f5db8e7ad129b2782a24eb97a0478fc42 (patch)
tree56a53a77b8ac8848f99f65816c2173b305fe21d8 /src
parentd861a005d27d0e95070d0807d8da5f6b6fdb9d2e (diff)
Make the proto bundling behavior the default when using the new library.
-- MOS_MIGRATED_REVID=127747661
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, 148 insertions, 100 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 017d245b81..ff039681f8 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,7 +44,6 @@ 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;
@@ -124,10 +123,10 @@ public class AppleBinary implements RuleConfiguredTargetFactory {
archivesToLipo.add(common.getCompilationArtifacts().get().getArchive().get());
binariesToLipo.add(intermediateArtifacts.strippedSingleArchitectureBinary());
- ObjcConfiguration objcConfiguration = childConfig.getFragment(ObjcConfiguration.class);
- if (objcConfiguration.experimentalAutoTopLevelUnionObjCProtos()) {
- ProtoSupport protoSupport =
- new ProtoSupport(ruleContext, TargetType.LINKING_TARGET).registerActions();
+ ProtoSupport protoSupport =
+ new ProtoSupport(ruleContext, TargetType.LINKING_TARGET, childConfig);
+ if (protoSupport.hasProtos()) {
+ protoSupport.registerActions();
ObjcCommon protoCommon = protoSupport.getCommon();
new CompilationSupport(
@@ -176,13 +175,11 @@ public class AppleBinary implements RuleConfiguredTargetFactory {
CompilationArtifacts compilationArtifacts =
CompilationSupport.compilationArtifacts(ruleContext, intermediateArtifacts);
- Optional<Artifact> protoLib;
- ObjcConfiguration objcConfiguration = buildConfiguration.getFragment(ObjcConfiguration.class);
- if (objcConfiguration.experimentalAutoTopLevelUnionObjCProtos()) {
- ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.LINKING_TARGET);
+ ProtoSupport protoSupport =
+ new ProtoSupport(ruleContext, TargetType.LINKING_TARGET, buildConfiguration);
+ Optional<Artifact> protoLib = Optional.absent();
+ if (protoSupport.hasProtos()) {
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 8579bb4966..516566fddb 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,14 +75,13 @@ 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;
- if (objcConfiguration.experimentalAutoTopLevelUnionObjCProtos()) {
+ ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.LINKING_TARGET);
+ if (protoSupport.hasProtos()) {
XcodeProvider.Builder protosXcodeProviderBuilder = new XcodeProvider.Builder();
- ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.LINKING_TARGET)
+ protoSupport
.registerActions()
.addXcodeProviderOptions(protosXcodeProviderBuilder);
@@ -143,6 +142,7 @@ 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 5e22cd713c..99d5dc7dbb 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,14 +83,13 @@ 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;
- if (objcConfiguration.experimentalAutoTopLevelUnionObjCProtos()) {
+ ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.LINKING_TARGET);
+ if (protoSupport.hasProtos()) {
XcodeProvider.Builder protosXcodeProviderBuilder = new XcodeProvider.Builder();
- ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.LINKING_TARGET)
+ protoSupport
.registerActions()
.addXcodeProviderOptions(protosXcodeProviderBuilder);
@@ -123,7 +122,6 @@ 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;
@@ -167,6 +165,8 @@ 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 36821e9baa..cd49ad6eab 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,7 +25,6 @@ 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;
/**
@@ -184,11 +183,9 @@ public class ObjcCommandLineOptions extends FragmentOptions {
// TODO(b/28451644): Make this option the default behavior.
@Option(
name = "experimental_auto_top_level_union_objc_protos",
- defaultValue = "false",
+ defaultValue = "true",
category = "flags",
- help =
- "Specifies whether to use the experimental proto generation scheme, in which they are all "
- + "generated and linked into the final linking target."
+ help = "This flag is a noop and scheduled for removal."
)
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 fc7d5cfc0d..6888b1ebe4 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,7 +27,6 @@ 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. */
@@ -69,7 +68,6 @@ 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;
@@ -95,8 +93,6 @@ 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;
}
@@ -271,14 +267,6 @@ 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 5239bf43e0..01bea3c0d3 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,7 +37,6 @@ public class ObjcProtoAspect extends NativeAspectClass implements ConfiguredAspe
public AspectDefinition getDefinition(AspectParameters aspectParameters) {
return new AspectDefinition.Builder(NAME)
.attributeAspect("deps", this)
- .requiresConfigurationFragments(ObjcConfiguration.class)
.build();
}
@@ -46,12 +45,6 @@ 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 344d5d3f14..bd4f50e919 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,17 +35,18 @@ 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()
- .addXcodeProviderOptions(xcodeProviderBuilder)
- .addFilesToBuild(filesToBuild)
- .registerActions();
+ ProtoSupport protoSupport = new ProtoSupport(ruleContext, TargetType.PROTO_TARGET)
+ .validate();
if (ruleContext.hasErrors()) {
return null;
}
+ protoSupport
+ .addXcodeProviderOptions(xcodeProviderBuilder)
+ .addFilesToBuild(filesToBuild)
+ .registerActions();
+
ObjcCommon common = protoSupport.getCommon();
filesToBuild.addAll(common.getCompiledArchive().asSet());
@@ -59,14 +60,9 @@ public class ObjcProtoLibrary implements RuleConfiguredTargetFactory {
boolean usesProtobufLibrary = protoSupport.usesProtobufLibrary();
- boolean experimentalAutoUnion =
- ObjcRuleClasses.objcConfiguration(ruleContext).experimentalAutoTopLevelUnionObjCProtos();
-
CompilationSupport compilationSupport = new CompilationSupport(ruleContext);
- // 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) {
+ if (!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 2f57efb8a6..c499a94b4a 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,11 +28,12 @@ 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.PrerequisiteArtifacts;
+import com.google.devtools.build.lib.analysis.FileProvider;
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;
@@ -43,9 +44,7 @@ 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;
/**
@@ -131,8 +130,23 @@ 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);
+ this.attributes = new Attributes(ruleContext, buildConfiguration);
this.targetType = targetType;
if (targetType != TargetType.PROTO_TARGET) {
// Use a a prefixed version of the intermediate artifacts to avoid naming collisions, as
@@ -158,7 +172,7 @@ final class ProtoSupport {
* @return this proto support
*/
public ProtoSupport validate() {
- if (attributes.getProtoFiles().isEmpty()) {
+ if (!hasProtos()) {
ruleContext.ruleError(NO_PROTOS_ERROR);
}
@@ -199,10 +213,8 @@ final class ProtoSupport {
* @return this proto support
*/
public ProtoSupport registerActions() {
- if (!Iterables.isEmpty(getFilteredProtoSources())) {
- registerProtoInputListFileAction();
- registerGenerateProtoFilesAction();
- }
+ registerProtoInputListFileAction();
+ registerGenerateProtoFilesAction();
return this;
}
@@ -217,14 +229,11 @@ final class ProtoSupport {
.setCompilationArtifacts(getCompilationArtifacts());
if (targetType == TargetType.LINKING_TARGET) {
- commonBuilder.addDepObjcProviders(
- ruleContext.getPrerequisites("deps", Mode.TARGET, ObjcProvider.class));
+ commonBuilder.addDepObjcProviders(attributes.getDepsObjcPrerequisites());
} else if (targetType == TargetType.PROTO_TARGET) {
- commonBuilder.addDepObjcProviders(
- ruleContext.getPrerequisites(
- ObjcRuleClasses.PROTO_LIB_ATTR, Mode.TARGET, ObjcProvider.class));
+ commonBuilder.addDepObjcProviders(attributes.getProtoLibObjcPrerequisites());
- if (usesProtobufLibrary() && experimentalAutoUnion()) {
+ if (usesProtobufLibrary()) {
commonBuilder.addDirectDependencyHeaderSearchPaths(getUserHeaderSearchPaths());
} else {
commonBuilder.addUserHeaderSearchPaths(getUserHeaderSearchPaths());
@@ -292,15 +301,9 @@ final class ProtoSupport {
builder.addAdditionalHdrs(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);
- }
+ if ((targetType == TargetType.PROTO_TARGET && !usesProtobufLibrary())
+ || targetType == TargetType.LINKING_TARGET) {
+ builder.addNonArcSrcs(generatedSources);
}
return builder.build();
@@ -334,13 +337,19 @@ 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 (experimentalAutoUnion() && targetType == TargetType.LINKING_TARGET) {
- Iterable<ObjcProtoProvider> objcProtoProviders =
- ruleContext.getPrerequisites("deps", Mode.TARGET, ObjcProtoProvider.class);
- for (ObjcProtoProvider objcProtoProvider : objcProtoProviders) {
+ if (targetType == TargetType.LINKING_TARGET) {
+ Iterable<ObjcProtoProvider> objcProtoPrividers = attributes.getDepsObjcProtoPrerequisites();
+ for (ObjcProtoProvider objcProtoProvider : objcProtoPrividers) {
protos.addTransitive(objcProtoProvider.getProtoSources());
}
}
@@ -380,10 +389,8 @@ final class ProtoSupport {
private NestedSet<Artifact> getPortableProtoFilters() {
NestedSetBuilder<Artifact> portableProtoFilters = NestedSetBuilder.stableOrder();
- if (experimentalAutoUnion() && targetType == TargetType.LINKING_TARGET) {
- Iterable<ObjcProtoProvider> objcProtoProviders =
- ruleContext.getPrerequisites("deps", Mode.TARGET, ObjcProtoProvider.class);
- for (ObjcProtoProvider objcProtoProvider : objcProtoProviders) {
+ if (targetType == TargetType.LINKING_TARGET) {
+ for (ObjcProtoProvider objcProtoProvider : attributes.getDepsObjcProtoPrerequisites()) {
portableProtoFilters.addTransitive(objcProtoProvider.getPortableProtoFilters());
}
}
@@ -392,11 +399,6 @@ final class ProtoSupport {
return portableProtoFilters.build();
}
- private boolean experimentalAutoUnion() {
- ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext);
- return objcConfiguration.experimentalAutoTopLevelUnionObjCProtos();
- }
-
private void registerProtoInputListFileAction() {
ruleContext.registerAction(
new FileWriteAction(
@@ -624,9 +626,78 @@ final class ProtoSupport {
*/
private static class Attributes {
private final RuleContext ruleContext;
+ private final BuildConfiguration buildConfiguration;
- private Attributes(RuleContext ruleContext) {
+ private Attributes(RuleContext ruleContext, BuildConfiguration buildConfiguration) {
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);
}
/**
@@ -741,10 +812,17 @@ 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 ImmutableList<Artifact> getProtoDepsFiles() {
- PrerequisiteArtifacts prerequisiteArtifacts =
- ruleContext.getPrerequisiteArtifacts("deps", Mode.TARGET);
- ImmutableList<Artifact> protos = prerequisiteArtifacts.filter(FileType.of(".proto")).list();
+ 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();
if (!protos.isEmpty()) {
ruleContext.attributeWarning("deps", FILES_DEPRECATED_WARNING);
}
@@ -756,8 +834,7 @@ final class ProtoSupport {
*/
private NestedSet<Artifact> getProtoDepsSources() {
NestedSetBuilder<Artifact> artifacts = NestedSetBuilder.stableOrder();
- Iterable<ProtoSourcesProvider> providers =
- ruleContext.getPrerequisites("deps", Mode.TARGET, ProtoSourcesProvider.class);
+ Iterable<ProtoSourcesProvider> providers = getDepsProtoSourcesPrerequisites();
for (ProtoSourcesProvider provider : providers) {
artifacts.addTransitive(provider.getTransitiveProtoSources());
}