Skip to content

Commit

Permalink
Add user-defined IPA post-processors.
Browse files Browse the repository at this point in the history
RELNOTES[NEW]: iOS ipa_post_processor attribute allows for user-defined IPA edits.

--
MOS_MIGRATED_REVID=115338312
  • Loading branch information
aragos authored and damienmg committed Feb 23, 2016
1 parent a08a6e2 commit 08bb682
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ public static void setup(ConfiguredRuleClassProvider.Builder builder) {
builder.addRuleDefinition(new ObjcRuleClasses.CompileDependencyRule());
builder.addRuleDefinition(new ObjcRuleClasses.ResourceToolsRule());
builder.addRuleDefinition(new ObjcRuleClasses.XcrunRule());
builder.addRuleDefinition(new ObjcRuleClasses.IpaRule());
builder.addRuleDefinition(new AppleToolchain.RequiresXcodeConfigRule());
builder.addRuleDefinition(new IosApplicationRule());
builder.addRuleDefinition(new IosExtensionBinaryRule());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ public Artifact appendExtensionForEntitlementArtifact(String extension) {
return artifact;
}

/**
* Returns the location of this target's generated entitlements file.
*/
public Artifact entitlements() {
return appendExtensionForEntitlementArtifact(".entitlements");
}

/**
* Returns a derived artifact in the bin directory obtained by appending some extension to the end
* of the given {@link PathFragment}.
Expand Down Expand Up @@ -362,4 +369,11 @@ public Artifact j2objcPrunedArchive(Artifact unprunedArchive) {
prunedSourceArtifactPath,
ruleContext.getBinOrGenfilesDirectory());
}

/**
* Returns the location of this target's merged but not post-processed or signed IPA.
*/
public Artifact unprocessedIpa() {
return appendExtension(".unprocessed.ipa");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
import com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.IpaRule;

/**
* Rule definition for ios_application.
Expand Down Expand Up @@ -75,8 +76,12 @@ public Metadata getMetadata() {
return RuleDefinition.Metadata.builder()
.name("ios_application")
.factoryClass(IosApplication.class)
.ancestors(BaseRuleClasses.BaseRule.class, ObjcRuleClasses.ReleaseBundlingRule.class,
ObjcRuleClasses.XcodegenRule.class, ObjcRuleClasses.SimulatorRule.class)
.ancestors(
BaseRuleClasses.BaseRule.class,
ObjcRuleClasses.ReleaseBundlingRule.class,
ObjcRuleClasses.XcodegenRule.class,
ObjcRuleClasses.SimulatorRule.class,
IpaRule.class)
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
import com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.IpaRule;

/**
* Rule definition for ios_extension.
Expand Down Expand Up @@ -60,8 +61,11 @@ public Metadata getMetadata() {
return RuleDefinition.Metadata.builder()
.name("ios_extension")
.factoryClass(IosExtension.class)
.ancestors(BaseRuleClasses.BaseRule.class, ObjcRuleClasses.ReleaseBundlingRule.class,
ObjcRuleClasses.XcodegenRule.class)
.ancestors(
BaseRuleClasses.BaseRule.class,
ObjcRuleClasses.ReleaseBundlingRule.class,
ObjcRuleClasses.XcodegenRule.class,
IpaRule.class)
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.devtools.build.lib.rules.objc;

import static com.google.devtools.build.lib.packages.Attribute.ANY_RULE;
import static com.google.devtools.build.lib.packages.Attribute.ConfigurationTransition.HOST;
import static com.google.devtools.build.lib.packages.Attribute.attr;
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
Expand Down Expand Up @@ -971,6 +972,43 @@ public Metadata getMetadata() {
}
}

/**
* Common attributes for {@code objc_*} rules that create a signed IPA.
*/
public static class IpaRule implements RuleDefinition {
@Override
public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
return builder
/* <!-- #BLAZE_RULE($objc_signing_rule).ATTRIBUTE(ipa_post_processor) -->
A tool that edits this target's IPA output after it is assembled but before it is
(optionally) signed.
<p>
The tool is invoked with a single positional argument which represents the path to a
directory containing the unzipped contents of the IPA. The only entry in this directory
will be the <code>Payload</code> root directory of the IPA. Any changes made by the tool
must be made in this directory, whose contents will be (optionally) signed and then
zipped up as the final IPA after the tool terminates.
<p>
The tool's execution must be hermetic given these inputs to ensure that its result can be
safely cached.
<!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
.add(
attr("ipa_post_processor", LABEL)
.allowedRuleClasses(ANY_RULE)
.allowedFileTypes(FileTypeSet.ANY_FILE)
.exec())
.build();
}

@Override
public Metadata getMetadata() {
return RuleDefinition.Metadata.builder()
.name("$objc_ipa_rule")
.type(RuleClassType.ABSTRACT)
.build();
}
}

/**
* Common attributes for {@code objc_*} rules that use the iOS simulator.
*/
Expand Down
Loading

0 comments on commit 08bb682

Please sign in to comment.