From eb06c40d10652af258bee1a0277916007eccc69a Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Fri, 25 Nov 2016 09:06:18 +0000 Subject: Rollback of commit 2eaa31fade12242b7075c2bbac945aeeedf985e8. *** Reason for rollback *** breaks a couple of iPhone targets in nightly, see [] *** Original change description *** Sign app and frameworks in simulator builds. This has become necessary starting with Xcode 8 although we apply the signature in all cases. Signing is done without entitlements and with signing identity "-". -- MOS_MIGRATED_REVID=140179790 --- .../lib/rules/objc/ReleaseBundlingSupport.java | 74 ++++++++++------------ 1 file changed, 33 insertions(+), 41 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 eb96e5fd15..f3b8d351bc 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 @@ -436,6 +436,7 @@ public final class ReleaseBundlingSupport { Artifact processedIpa = releaseBundling.getIpaArtifact(); Artifact unprocessedIpa = intermediateArtifacts.unprocessedIpa(); + boolean processingNeeded = false; NestedSetBuilder inputs = NestedSetBuilder.stableOrder().add(unprocessedIpa); @@ -453,58 +454,45 @@ public final class ReleaseBundlingSupport { FilesToRunProvider processor = attributes.ipaPostProcessor(); if (processor != null) { + processingNeeded = true; actionCommandLine += processor.getExecutable().getShellEscapedExecPathString() + " ${t} && "; } + AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); if (platform.isDevice()) { - actionCommandLine += deviceSigningCommandLine(); - + processingNeeded = true; registerEntitlementsActions(); - inputs.add(releaseBundling.getProvisioningProfile()) - .add(intermediateArtifacts.entitlements()); - } else { - actionCommandLine += simulatorSigningCommandLine(); + actionCommandLine += signingCommandLine(); + inputs.add(releaseBundling.getProvisioningProfile()).add( + intermediateArtifacts.entitlements()); } actionCommandLine += "cd ${t} && /usr/bin/zip -q -r \"${signed_ipa}\" ."; - AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); - SpawnAction.Builder processAction = - ObjcRuleClasses.spawnBashOnDarwinActionBuilder(actionCommandLine) - .setEnvironment(ObjcRuleClasses.appleToolchainEnvironment(appleConfiguration, platform)) - .setMnemonic("ObjcProcessIpa") - .setProgressMessage("Processing iOS IPA: " + ruleContext.getLabel()) - .disableSandboxing() - .addTransitiveInputs(inputs.build()) - .addOutput(processedIpa); - - if (processor != null) { - processAction.addTool(processor); - } - - ruleContext.registerAction(processAction.build(ruleContext)); - } - - private String deviceSigningCommandLine() { - StringBuilder codesignCommandLineBuilder = new StringBuilder(); - for (String dir : getDirsToSign()) { - codesignCommandLineBuilder.append(deviceCodesignCommand("${t}/" + dir)).append(" && "); - } - return codesignCommandLineBuilder.toString(); - } + if (processingNeeded) { + SpawnAction.Builder processAction = + ObjcRuleClasses.spawnBashOnDarwinActionBuilder(actionCommandLine) + .setEnvironment( + ObjcRuleClasses.appleToolchainEnvironment(appleConfiguration, platform)) + .setMnemonic("ObjcProcessIpa") + .setProgressMessage("Processing iOS IPA: " + ruleContext.getLabel()) + .disableSandboxing() + .addTransitiveInputs(inputs.build()) + .addOutput(processedIpa); + + if (processor != null) { + processAction.addTool(processor); + } - private String simulatorSigningCommandLine() { - StringBuilder codesignCommandLineBuilder = new StringBuilder(); - for (String dir : getDirsToSign()) { - codesignCommandLineBuilder - .append("/usr/bin/codesign --force --sign \"-\" ${t}/") - .append(dir) - .append(" && "); + ruleContext.registerAction(processAction.build(ruleContext)); + } else { + ruleContext.registerAction( + new SymlinkAction( + ruleContext.getActionOwner(), unprocessedIpa, processedIpa, "Processing IPA")); } - return codesignCommandLineBuilder.toString(); } - private ImmutableList getDirsToSign() { + private String signingCommandLine() { // The order here is important. The innermost code must singed first. ImmutableList.Builder dirsToSign = new ImmutableList.Builder<>(); String bundleDir = ShellUtils.shellEscape(bundling.getBundleDir()); @@ -517,7 +505,11 @@ public final class ReleaseBundlingSupport { } dirsToSign.add(bundleDir); - return dirsToSign.build(); + StringBuilder codesignCommandLineBuilder = new StringBuilder(); + for (String dir : dirsToSign.build()) { + codesignCommandLineBuilder.append(codesignCommand("${t}/" + dir)).append(" && "); + } + return codesignCommandLineBuilder.toString(); } /** @@ -1126,7 +1118,7 @@ public final class ReleaseBundlingSupport { return "security cms -D -i " + ShellUtils.shellEscape(provisioningProfile.getExecPathString()); } - private String deviceCodesignCommand(String appDir) { + private String codesignCommand(String appDir) { String signingCertName = ObjcRuleClasses.objcConfiguration(ruleContext).getSigningCertName(); Artifact entitlements = intermediateArtifacts.entitlements(); -- cgit v1.2.3