Skip to content

Commit

Permalink
Automated rollback of commit 618a2bf.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Broke several tests in nightly.

[]

*** Original change description ***

Rollforward #2 of "AppleBinary and AppleStaticLibrary no longer propagate unwrapped ObjcProvider", after changes made to apple bazel rules to be compatible.

RELNOTES: None.
PiperOrigin-RevId: 167312716
  • Loading branch information
c-parsons authored and meteorcloudy committed Sep 4, 2017
1 parent 78e6d51 commit 9308a4f
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ public final ConfiguredTarget create(RuleContext ruleContext)
objcProviderBuilder.add(MULTI_ARCH_LINKED_BINARIES, outputArtifact);

ObjcProvider objcProvider = objcProviderBuilder.build();
// TODO(cparsons): Stop propagating ObjcProvider directly from this rule.
targetBuilder.addNativeDeclaredProvider(objcProvider);

switch (getBinaryType(ruleContext)) {
case EXECUTABLE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ public final ConfiguredTarget create(RuleContext ruleContext)
ObjcProvider objcProvider = objcProviderBuilder.build();

targetBuilder
// TODO(cparsons): Remove ObjcProvider as a direct provider.
.addNativeDeclaredProvider(objcProvider)
.addNativeDeclaredProvider(
new AppleStaticLibraryProvider(
ruleIntermediateArtifacts.combinedArchitectureArchive(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ public void testLoadableBundleBinaryAddsRpathLinkOptWithBundleLoader() throws Ex

@Test
public void testCustomModuleMap() throws Exception {
checkCustomModuleMap(RULE_TYPE, true);
checkCustomModuleMap(RULE_TYPE);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ public void testAvoidDepsProviders() throws Exception {
" resources = [':avoid.png']",
")");

ObjcProvider provider = getConfiguredTarget("//package:test")
.get(AppleStaticLibraryProvider.SKYLARK_CONSTRUCTOR)
.getDepsObjcProvider();
ObjcProvider provider = providerForTarget("//package:test");
// Do not remove SDK_FRAMEWORK values in avoid_deps.
assertThat(provider.get(ObjcProvider.SDK_FRAMEWORK))
.containsAllOf(new SdkFramework("AvoidSDK"), new SdkFramework("BaseSDK"));
Expand Down Expand Up @@ -625,4 +623,4 @@ public void testAvoidDepsObjects_avoidCcLibrary() throws Exception {
assertThat(Artifact.toRootRelativePaths(action.getInputs())).doesNotContain(
"package/libavoidCcLib.a");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1167,22 +1167,7 @@ public void testMultiArchUserHeaderSearchPathsUsed() throws Exception {
// Usually, an ios_test would depend on apple_binary through a skylark_ios_application in its
// 'binary' attribute. Since we don't have skylark_ios_application here, we use the 'deps'
// attribute instead.
scratch.file("skylarkstub/BUILD");
scratch.file("skylarkstub/skylark_stub.bzl",
"def skylark_ios_application_stub_impl(ctx):",
" bin_provider = ctx.attr.binary[apple_common.AppleExecutableBinary]",
" return struct(objc=bin_provider.objc)",
"skylark_ios_application_stub = rule(",
" skylark_ios_application_stub_impl,",
// Both 'binary' and 'deps' are needed because ObjcProtoAspect is applied transitively
// along attribute 'deps' only.
" attrs = {'binary': attr.label(mandatory=True,",
" providers=[apple_common.AppleExecutableBinary])},",
" fragments = ['apple', 'objc'],",
")");

scratch.file("x/BUILD",
"load('//skylarkstub:skylark_stub.bzl', 'skylark_ios_application_stub')",
"genrule(",
" name = 'gen_hdrs',",
" outs = ['generated.h'],",
Expand All @@ -1194,10 +1179,6 @@ public void testMultiArchUserHeaderSearchPathsUsed() throws Exception {
" platform_type = 'ios',",
" hdrs = ['generated.h'],",
")",
"skylark_ios_application_stub(",
" name = 'stub_application',",
" binary = ':apple_bin',",
")",
"objc_binary(",
" name = 'bin',",
" srcs = ['bin.m'],",
Expand All @@ -1211,7 +1192,7 @@ public void testMultiArchUserHeaderSearchPathsUsed() throws Exception {
" srcs = ['test.m'],",
" xctest = 1,",
" xctest_app = ':testApp',",
" deps = [':stub_application']",
" deps = [':apple_bin']",
")");
CommandAction compileAction = compileAction("//x:test", "test.o");
// The genfiles root for child configurations must be present in the compile action so that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ public void testFilesToCompileOutputGroup() throws Exception {

@Test
public void testCustomModuleMap() throws Exception {
checkCustomModuleMap(RULE_TYPE, false);
checkCustomModuleMap(RULE_TYPE);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ public void testDefaultEnabledFeatureIsUsed() throws Exception {

@Test
public void testCustomModuleMap() throws Exception {
checkCustomModuleMap(RULE_TYPE, false);
checkCustomModuleMap(RULE_TYPE);
}

private boolean containsObjcFeature(String srcName) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,12 @@ public void testErrorForUsesProtobufWithOptionsFile() throws Exception {

@Test
public void testModulemapCreatedForNonLinkingTargets() throws Exception {
checkOnlyLibModuleMapsArePresentForTarget("//package:opl_protobuf", false);
checkOnlyLibModuleMapsArePresentForTarget("//package:opl_protobuf");
}

@Test
public void testModulemapNotCreatedForLinkingTargets() throws Exception {
checkOnlyLibModuleMapsArePresentForTarget("//package:opl_binary", true);
checkOnlyLibModuleMapsArePresentForTarget("//package:opl_binary");
}

@Test
Expand Down Expand Up @@ -760,8 +760,7 @@ private static String sortedJoin(Iterable<String> elements) {
return Joiner.on('\n').join(Ordering.natural().immutableSortedCopy(elements));
}

private void checkOnlyLibModuleMapsArePresentForTarget(String target,
boolean fromBinary) throws Exception {
private void checkOnlyLibModuleMapsArePresentForTarget(String target) throws Exception {
Artifact libModuleMap =
getGenfilesArtifact(
"opl_protobuf.modulemaps/module.modulemap",
Expand All @@ -771,11 +770,7 @@ private void checkOnlyLibModuleMapsArePresentForTarget(String target,
"protobuf_lib.modulemaps/module.modulemap",
getConfiguredTarget("//objcproto:protobuf_lib"));

ObjcProvider provider = fromBinary
? getConfiguredTarget(target)
.get(AppleExecutableBinaryProvider.SKYLARK_CONSTRUCTOR)
.getDepsObjcProvider()
: providerForTarget(target);
ObjcProvider provider = providerForTarget(target);
assertThat(Artifact.toRootRelativePaths(provider.get(ObjcProvider.MODULE_MAP).toSet()))
.containsExactlyElementsIn(
Artifact.toRootRelativePaths(ImmutableSet.of(libModuleMap, protolibModuleMap)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4892,7 +4892,7 @@ public void checkFilesToCompileOutputGroup(RuleType ruleType) throws Exception {
.isEqualTo("a.o");
}

protected void checkCustomModuleMap(RuleType ruleType, boolean fromBinary) throws Exception {
protected void checkCustomModuleMap(RuleType ruleType) throws Exception {
useConfiguration("--experimental_objc_enable_module_maps");
ruleType.scratchTarget(scratch, "srcs", "['a.m']", "deps", "['//z:testModuleMap']");
scratch.file("x/a.m");
Expand Down Expand Up @@ -4920,11 +4920,7 @@ protected void checkCustomModuleMap(RuleType ruleType, boolean fromBinary) throw
assertThat(Artifact.toExecPaths(provider.get(MODULE_MAP)))
.containsExactly("y/module.modulemap");

provider = fromBinary
? getConfiguredTarget("//x:x")
.get(AppleExecutableBinaryProvider.SKYLARK_CONSTRUCTOR)
.getDepsObjcProvider()
: providerForTarget("//x:x");
provider = providerForTarget("//x:x");
assertThat(Artifact.toExecPaths(provider.get(MODULE_MAP))).contains("y/module.modulemap");
}

Expand Down

0 comments on commit 9308a4f

Please sign in to comment.