Skip to content

Commit

Permalink
Read --enable_apple_binary_native_protos to check whether to link Obj…
Browse files Browse the repository at this point in the history
…C protos into apple_static_library outputs.

RELNOTES: None
PiperOrigin-RevId: 252659365
  • Loading branch information
sergiocampama authored and copybara-github committed Jun 11, 2019
1 parent 25d2748 commit 5aae664
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,26 @@ public final ConfiguredTarget create(RuleContext ruleContext)
BuildConfiguration childToolchainConfig = entry.getKey();
String childCpu = entry.getKey().getCpu();
CcToolchainProvider childToolchain = entry.getValue();
Iterable<ObjcProtoProvider> objcProtoProviders = objcProtoProvidersMap.get(childCpu);
ProtobufSupport protoSupport =
new ProtobufSupport(
ruleContext,
childToolchainConfig,
protosToAvoid,
ImmutableList.<ProtoInfo>of(),
objcProtoProviders,
ProtobufSupport.getTransitivePortableProtoFilters(objcProtoProviders),
childToolchain)
.registerGenerationActions()
.registerCompilationActions();

Optional<ObjcProvider> protosObjcProvider = protoSupport.getObjcProvider();

Optional<ObjcProvider> protosObjcProvider;
if (ObjcRuleClasses.objcConfiguration(ruleContext).enableAppleBinaryNativeProtos()) {
Iterable<ObjcProtoProvider> objcProtoProviders = objcProtoProvidersMap.get(childCpu);
ProtobufSupport protoSupport =
new ProtobufSupport(
ruleContext,
childToolchainConfig,
protosToAvoid,
ImmutableList.<ProtoInfo>of(),
objcProtoProviders,
ProtobufSupport.getTransitivePortableProtoFilters(objcProtoProviders),
childToolchain)
.registerGenerationActions()
.registerCompilationActions();

protosObjcProvider = protoSupport.getObjcProvider();
} else {
protosObjcProvider = Optional.absent();
}

IntermediateArtifacts intermediateArtifacts =
ObjcRuleClasses.intermediateArtifacts(ruleContext, childToolchainConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,4 +702,15 @@ public void testAppleStaticLibraryProvider_invalidArgs() throws Exception {
.hasMessageThat()
.contains("unexpected keyword 'foo', for call to function AppleStaticLibrary");
}

@Test
public void testProtoBundlingWithTargetsWithNoDeps() throws Exception {
checkProtoBundlingWithTargetsWithNoDeps(RULE_TYPE);
}

@Test
public void testProtoBundlingDoesNotHappen() throws Exception {
useConfiguration("--noenable_apple_binary_native_protos");
checkProtoBundlingDoesNotHappen(RULE_TYPE);
}
}

0 comments on commit 5aae664

Please sign in to comment.