Skip to content

Commit

Permalink
Rollback of commit 2eaa31f.
Browse files Browse the repository at this point in the history
*** 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
  • Loading branch information
meisterT authored and dslomov committed Nov 25, 2016
1 parent 5c9fcaf commit eb06c40
Showing 1 changed file with 33 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ private void registerPostProcessAndSigningActions() {
Artifact processedIpa = releaseBundling.getIpaArtifact();
Artifact unprocessedIpa = intermediateArtifacts.unprocessedIpa();

boolean processingNeeded = false;
NestedSetBuilder<Artifact> inputs =
NestedSetBuilder.<Artifact>stableOrder().add(unprocessedIpa);

Expand All @@ -453,58 +454,45 @@ private void registerPostProcessAndSigningActions() {

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<String> getDirsToSign() {
private String signingCommandLine() {
// The order here is important. The innermost code must singed first.
ImmutableList.Builder<String> dirsToSign = new ImmutableList.Builder<>();
String bundleDir = ShellUtils.shellEscape(bundling.getBundleDir());
Expand All @@ -517,7 +505,11 @@ private ImmutableList<String> getDirsToSign() {
}
dirsToSign.add(bundleDir);

return dirsToSign.build();
StringBuilder codesignCommandLineBuilder = new StringBuilder();
for (String dir : dirsToSign.build()) {
codesignCommandLineBuilder.append(codesignCommand("${t}/" + dir)).append(" && ");
}
return codesignCommandLineBuilder.toString();
}

/**
Expand Down Expand Up @@ -1126,7 +1118,7 @@ private String extractPlistCommand(Artifact provisioningProfile) {
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();

Expand Down

0 comments on commit eb06c40

Please sign in to comment.