diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java index 26cf539a15..c60ecdeb5b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java @@ -123,6 +123,7 @@ public final class ReleaseBundlingSupport { private final LinkedBinary linkedBinary; private final IntermediateArtifacts intermediateArtifacts; private final ReleaseBundling releaseBundling; + private final Platform platform; /** * Indicator as to whether this rule generates a binary directly or whether only dependencies @@ -142,7 +143,7 @@ public final class ReleaseBundlingSupport { } /** - * Creates a new application support within the given rule context. + * Creates a new release bundling support within the given rule context. * * @param ruleContext context for the application-generating rule * @param objcProvider provider containing all dependencies' information as well as some of this @@ -157,6 +158,7 @@ public final class ReleaseBundlingSupport { * through the configuration) * @param releaseBundling the {@link ReleaseBundling} containing information for creating a * releaseable bundle. + * @param platform the platform that bundles will be created for using this support */ ReleaseBundlingSupport( RuleContext ruleContext, @@ -165,7 +167,9 @@ public final class ReleaseBundlingSupport { String bundleDirFormat, String bundleName, DottedVersion bundleMinimumOsVersion, - ReleaseBundling releaseBundling) { + ReleaseBundling releaseBundling, + Platform platform) { + this.platform = platform; this.linkedBinary = linkedBinary; this.attributes = new Attributes(ruleContext); this.ruleContext = ruleContext; @@ -188,6 +192,7 @@ public final class ReleaseBundlingSupport { * @param bundleDirFormat format string representing the bundle's directory with a single * placeholder for the target name (e.g. {@code "Payload/%s.app"}) * @param bundleName name of the bundle, used with bundleDirFormat + * @param platform the platform that bundles will be created for using this support */ ReleaseBundlingSupport( RuleContext ruleContext, @@ -195,7 +200,8 @@ public final class ReleaseBundlingSupport { LinkedBinary linkedBinary, String bundleDirFormat, String bundleName, - DottedVersion bundleMinimumOsVersion) throws InterruptedException { + DottedVersion bundleMinimumOsVersion, + Platform platform) throws InterruptedException { this( ruleContext, objcProvider, @@ -203,7 +209,8 @@ public final class ReleaseBundlingSupport { bundleDirFormat, bundleName, bundleMinimumOsVersion, - ReleaseBundling.releaseBundling(ruleContext)); + ReleaseBundling.releaseBundling(ruleContext), + platform); } /** @@ -221,6 +228,7 @@ public final class ReleaseBundlingSupport { * @param bundleMinimumOsVersion the minimum OS version this bundle's plist should be generated * for (<b>not</b> the minimum OS version its binary is compiled with, that needs to be set * through the configuration) + * @param platform the platform that bundles will be created for using this support * @throws InterruptedException */ ReleaseBundlingSupport( @@ -228,9 +236,10 @@ public final class ReleaseBundlingSupport { ObjcProvider objcProvider, LinkedBinary linkedBinary, String bundleDirFormat, - DottedVersion bundleMinimumOsVersion) throws InterruptedException { + DottedVersion bundleMinimumOsVersion, + Platform platform) throws InterruptedException { this(ruleContext, objcProvider, linkedBinary, bundleDirFormat, ruleContext.getLabel().getName(), - bundleMinimumOsVersion); + bundleMinimumOsVersion, platform); } /** @@ -255,9 +264,7 @@ public final class ReleaseBundlingSupport { } } - AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); - if (releaseBundling.getProvisioningProfile() == null - && appleConfiguration.getMultiArchPlatform(PlatformType.IOS) != Platform.IOS_SIMULATOR) { + if (releaseBundling.getProvisioningProfile() == null && platform.isDevice()) { ruleContext.attributeError(releaseBundling.getProvisioningProfileAttrName(), DEVICE_NO_PROVISIONING_PROFILE); } @@ -369,8 +376,8 @@ public final class ReleaseBundlingSupport { String platformWithVersion = String.format( "%s%s", - configuration.getMultiArchPlatform(PlatformType.IOS).getLowerCaseNameInPlist(), - configuration.getIosSdkVersion()); + platform.getLowerCaseNameInPlist(), + configuration.getSdkVersionForPlatform(platform)); ruleContext.registerAction( ObjcRuleClasses.spawnAppleEnvActionBuilder(ruleContext) .setMnemonic("EnvironmentPlist") @@ -398,7 +405,6 @@ public final class ReleaseBundlingSupport { List<Integer> uiDeviceFamily = TargetDeviceFamily.UI_DEVICE_FAMILY_VALUES.get(bundleSupport.targetDeviceFamilies()); AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); - Platform platform = appleConfiguration.getMultiArchPlatform(PlatformType.IOS); NSDictionary result = new NSDictionary(); @@ -408,7 +414,7 @@ public final class ReleaseBundlingSupport { result.put("DTPlatformName", platform.getLowerCaseNameInPlist()); result.put( "DTSDKName", - platform.getLowerCaseNameInPlist() + appleConfiguration.getIosSdkVersion()); + platform.getLowerCaseNameInPlist() + appleConfiguration.getSdkVersionForPlatform(platform)); result.put("CFBundleSupportedPlatforms", new NSArray(NSObject.wrap(platform.getNameInPlist()))); result.put("MinimumOSVersion", bundling.getMinimumOsVersion().toString()); @@ -426,7 +432,7 @@ public final class ReleaseBundlingSupport { * <p>Note that multiple "actions" on the IPA contents may be run in a single blaze action to * avoid excessive zipping/unzipping of IPA contents. */ - private void registerPostProcessAndSigningActions() throws InterruptedException { + private void registerPostProcessAndSigningActions() { Artifact processedIpa = releaseBundling.getIpaArtifact(); Artifact unprocessedIpa = intermediateArtifacts.unprocessedIpa(); @@ -453,7 +459,7 @@ public final class ReleaseBundlingSupport { } AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); - if (appleConfiguration.getMultiArchPlatform(PlatformType.IOS) == Platform.IOS_DEVICE) { + if (platform.isDevice()) { processingNeeded = true; registerEntitlementsActions(); actionCommandLine += signingCommandLine(); @@ -466,10 +472,8 @@ public final class ReleaseBundlingSupport { if (processingNeeded) { SpawnAction.Builder processAction = ObjcRuleClasses.spawnBashOnDarwinActionBuilder(actionCommandLine) - // TODO(cparsons): This bundling support is used for other platform types, as well. - // The platform type should be passed from the caller. - .setEnvironment(ObjcRuleClasses.appleToolchainEnvironment(appleConfiguration, - appleConfiguration.getMultiArchPlatform(PlatformType.IOS))) + .setEnvironment( + ObjcRuleClasses.appleToolchainEnvironment(appleConfiguration, platform)) .setMnemonic("ObjcProcessIpa") .setProgressMessage("Processing iOS IPA: " + ruleContext.getLabel()) .addTransitiveInputs(inputs.build()) @@ -616,8 +620,7 @@ public final class ReleaseBundlingSupport { * @return this application support */ ReleaseBundlingSupport addFilesToBuild( - NestedSetBuilder<Artifact> filesToBuild, DsymOutputType dsymOutputType) - throws InterruptedException { + NestedSetBuilder<Artifact> filesToBuild, DsymOutputType dsymOutputType) { NestedSetBuilder<Artifact> debugSymbolBuilder = NestedSetBuilder.<Artifact>stableOrder(); for (Artifact linkmapFile : getLinkmapFiles().values()) { @@ -672,7 +675,7 @@ public final class ReleaseBundlingSupport { * Creates the {@link XcTestAppProvider} that can be used if this application is used as an * {@code xctest_app}. */ - XcTestAppProvider xcTestAppProvider() throws InterruptedException { + XcTestAppProvider xcTestAppProvider() { // We want access to #import-able things from our test rig's dependency graph, but we don't // want to link anything since that stuff is shared automatically by way of the // -bundle_loader linker flag. @@ -726,7 +729,7 @@ public final class ReleaseBundlingSupport { /** * Returns a {@link RunfilesSupport} that uses the provided runner script as the executable. */ - RunfilesSupport runfilesSupport(Artifact runnerScript) throws InterruptedException { + RunfilesSupport runfilesSupport(Artifact runnerScript) { Runfiles runfiles = new Runfiles.Builder( ruleContext.getWorkspaceName(), ruleContext.getConfiguration().legacyExternalRunfiles()) .addArtifact(releaseBundling.getIpaArtifact()) @@ -756,7 +759,7 @@ public final class ReleaseBundlingSupport { DottedVersion minimumOsVersion) { ImmutableList<BundleableFile> extraBundleFiles; AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); - if (appleConfiguration.getMultiArchPlatform(PlatformType.IOS) == Platform.IOS_DEVICE) { + if (platform.isDevice()) { extraBundleFiles = ImmutableList.of(new BundleableFile( releaseBundling.getProvisioningProfile(), PROVISIONING_PROFILE_BUNDLE_FILE)); } else { @@ -808,10 +811,9 @@ public final class ReleaseBundlingSupport { } Artifact resultingLinkedBinary = intermediateArtifacts.combinedArchitectureBinary(); - AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); new LipoSupport(ruleContext).registerCombineArchitecturesAction(linkedBinaries(), - resultingLinkedBinary, appleConfiguration.getMultiArchPlatform(PlatformType.IOS)); + resultingLinkedBinary, platform); } private NestedSet<Artifact> linkedBinaries() { |