Skip to content

Commit

Permalink
Base .entitlements (and related extension) files on the full target l…
Browse files Browse the repository at this point in the history
…abel as opposed to treating the label name as a file (which the extension is stripped from).

This prevents this functionality from breaking if the target contains what looks like an extension (e.g. test.foo)

--
MOS_MIGRATED_REVID=102600479
  • Loading branch information
c-parsons authored and lberki committed Sep 9, 2015
1 parent 2fc8bf2 commit 1343a77
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ final class IntermediateArtifacts {
this.archiveFileNameSuffix = Preconditions.checkNotNull(archiveFileNameSuffix);
}

/**
* Returns a derived artifact in the bin directory obtained by appending some extension to the
* main label name; the result artifact is placed in a unique "entitlements" directory.
* For example, if this artifact is for a target Foo with extension ".extension", the result
* artifact will be located at {target_base_path}/entitlements/Foo.extension.
*/
public Artifact appendExtensionForEntitlementArtifact(String extension) {
PathFragment entitlementsDirectory = ruleContext.getUniqueDirectory("entitlements");
Artifact artifact =
ruleContext.getDerivedArtifact(
entitlementsDirectory.replaceName(
entitlementsDirectory.getBaseName() + extension),
ruleContext.getConfiguration().getBinDirectory());
return artifact;
}

/**
* Returns a derived artifact in the bin directory obtained by appending some extension to the end
* of the given {@link PathFragment}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import com.google.devtools.build.lib.packages.Type;
import com.google.devtools.build.lib.rules.objc.BundleSupport.ExtraActoolArgs;
import com.google.devtools.build.lib.shell.ShellUtils;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.xcode.xcodegen.proto.XcodeGenProtos.XcodeprojBuildSetting;

import java.util.List;
Expand Down Expand Up @@ -331,19 +330,21 @@ private void registerEnvironmentPlistAction() {
}

private Artifact registerBundleSigningActions(Artifact ipaOutput) {
PathFragment entitlementsDirectory = ruleContext.getUniqueDirectory("entitlements");
IntermediateArtifacts intermediateArtifacts =
ObjcRuleClasses.intermediateArtifacts(ruleContext);
Artifact teamPrefixFile =
ruleContext.getRelatedArtifact(entitlementsDirectory, ".team_prefix_file");
intermediateArtifacts.appendExtensionForEntitlementArtifact(".team_prefix_file");
registerExtractTeamPrefixAction(teamPrefixFile);

Artifact entitlementsNeedingSubstitution = attributes.entitlements();
if (entitlementsNeedingSubstitution == null) {
entitlementsNeedingSubstitution = ruleContext.getRelatedArtifact(
entitlementsDirectory, ".entitlements_with_variables");
entitlementsNeedingSubstitution =
intermediateArtifacts.appendExtensionForEntitlementArtifact(
".entitlements_with_variables");
registerExtractEntitlementsAction(entitlementsNeedingSubstitution);
}
Artifact entitlements =
ruleContext.getRelatedArtifact(entitlementsDirectory, ".entitlements");
intermediateArtifacts.appendExtensionForEntitlementArtifact(".entitlements");
registerEntitlementsVariableSubstitutionAction(
entitlementsNeedingSubstitution, entitlements, teamPrefixFile);
Artifact ipaUnsigned = ruleContext.getImplicitOutputArtifact(IPA_UNSIGNED);
Expand Down

0 comments on commit 1343a77

Please sign in to comment.