From 179124c4276c9ad2032a577d8ec739f291c905eb Mon Sep 17 00:00:00 2001 From: cparsons Date: Mon, 5 Jun 2017 18:25:07 -0400 Subject: apple_binary provides information about its dylibs' symbols in its nested ObjcProvider This facilitates app->dylib->dylib dependencies, as the app needs to avoid linking in symbols contained in any *transitive* dylibs, not just in any direct dylibs. This also removes a test which verified the previous, incorrect functionality (not propagating information about dylibs up the tree). RELNOTES: None. PiperOrigin-RevId: 158070381 --- .../devtools/build/lib/rules/objc/AppleBinary.java | 3 +- .../lib/rules/objc/MultiArchBinarySupport.java | 36 +++++++++++++++++----- 2 files changed, 30 insertions(+), 9 deletions(-) (limited to 'src/main/java/com/google/devtools') 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 23ad482171..0f954a49eb 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 @@ -158,7 +158,8 @@ public class AppleBinary implements RuleConfiguredTargetFactory { ObjcProvider.Builder objcProviderBuilder = new ObjcProvider.Builder(); for (DependencySpecificConfiguration dependencySpecificConfiguration : dependencySpecificConfigurations) { - objcProviderBuilder.addTransitiveAndPropagate(dependencySpecificConfiguration.objcProvider()); + objcProviderBuilder.addTransitiveAndPropagate( + dependencySpecificConfiguration.objcProviderWithDylibSymbols()); } objcProviderBuilder.add(MULTI_ARCH_LINKED_BINARIES, outputArtifact); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java index a2cd8439ae..1b3d53f89e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/MultiArchBinarySupport.java @@ -68,22 +68,38 @@ public class MultiArchBinarySupport { } /** - * Configuration, toolchain, and provider for for single-arch dependency configurations of a - * multi-arch target. + * A tuple of values about dependency trees in a specific child configuration. */ @AutoValue abstract static class DependencySpecificConfiguration { static DependencySpecificConfiguration create( - BuildConfiguration config, CcToolchainProvider toolchain, ObjcProvider objcProvider) { + BuildConfiguration config, CcToolchainProvider toolchain, ObjcProvider objcLinkProvider, + ObjcProvider objcPropagateProvider) { return new AutoValue_MultiArchBinarySupport_DependencySpecificConfiguration( - config, toolchain, objcProvider); + config, toolchain, objcLinkProvider, objcPropagateProvider); } + /** + * Returns the child configuration for this tuple. + */ abstract BuildConfiguration config(); + /** + * Returns the cc toolchain for this configuration. + */ abstract CcToolchainProvider toolchain(); - abstract ObjcProvider objcProvider(); + /** + * Returns the {@link ObjcProvider} to use as input to the support controlling link actoins; + * dylib symbols should be subtracted from this provider. + */ + abstract ObjcProvider objcLinkProvider(); + + /** + * Returns the {@link ObjcProvider} to propagate up to dependers; this will not have dylib + * symbols subtracted, thus signaling that this target is still responsible for those symbols. + */ + abstract ObjcProvider objcProviderWithDylibSymbols(); } @@ -149,7 +165,7 @@ public class MultiArchBinarySupport { binariesToLipo.add(intermediateArtifacts.strippedSingleArchitectureBinary()); - ObjcProvider objcProvider = dependencySpecificConfiguration.objcProvider(); + ObjcProvider objcProvider = dependencySpecificConfiguration.objcLinkProvider(); CompilationArtifacts compilationArtifacts = CompilationSupport.compilationArtifacts( ruleContext, @@ -253,12 +269,16 @@ public class MultiArchBinarySupport { nullToEmptyList(configToDepsCollectionMap.get(childConfig)), nullToEmptyList(configurationToNonPropagatedObjcMap.get(childConfig)), additionalDepProviders); - ObjcProvider objcProvider = common.getObjcProvider().subtractSubtrees(dylibObjcProviders, + ObjcProvider objcProviderWithDylibSymbols = common.getObjcProvider(); + ObjcProvider objcProvider = objcProviderWithDylibSymbols.subtractSubtrees(dylibObjcProviders, ImmutableList.of()); childInfoBuilder.add( DependencySpecificConfiguration.create( - childConfig, childConfigurationsAndToolchains.get(childConfig), objcProvider)); + childConfig, + childConfigurationsAndToolchains.get(childConfig), + objcProvider, + objcProviderWithDylibSymbols)); } return childInfoBuilder.build(); -- cgit v1.2.3