aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-07-16 18:12:12 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2015-07-17 13:18:04 +0000
commitba1d6aaaed82fc267ccb049b4289ac7471239506 (patch)
tree7e44d115b64b763aaad2b684ac3779bda2a719c4 /src/main/java/com/google/devtools/build/lib/rules
parent6009cf953643af157c395732e058e5af8657a833 (diff)
Sets the correct properties in the Info.plist, based on the environment that the
rule was executed. -- MOS_MIGRATED_REVID=98417915
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/IosSdkCommands.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java37
2 files changed, 38 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosSdkCommands.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosSdkCommands.java
index 799597bee0..b10bc05b16 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosSdkCommands.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosSdkCommands.java
@@ -68,7 +68,7 @@ public class IosSdkCommands {
return Platform.forArch(configuration.getIosCpu()).getNameInPlist();
}
- private static String platformDir(ObjcConfiguration configuration) {
+ public static String platformDir(ObjcConfiguration configuration) {
return DEVELOPER_DIR + "/Platforms/" + getPlatformPlistName(configuration) + ".platform";
}
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 dc0fa8eca7..025dac666b 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
@@ -219,6 +219,7 @@ public final class ReleaseBundlingSupport {
}
registerEmbedLabelPlistAction();
+ registerEnvironmentPlistAction();
BundleMergeControlBytes bundleMergeControlBytes = new BundleMergeControlBytes(
bundling, maybeSignedIpa, objcConfiguration, bundleSupport.targetDeviceFamilies());
@@ -266,6 +267,36 @@ public final class ReleaseBundlingSupport {
.build(ruleContext));
}
+ private void registerEnvironmentPlistAction() {
+ ObjcConfiguration configuration = ObjcRuleClasses.objcConfiguration(ruleContext);
+ // Generates a .plist that contains environment values (such as the SDK used to build, the Xcode
+ // version, etc), which are parsed from various .plist files of the OS, namely XCodes' and
+ // Platforms' plists.
+ // The resulting file is meant to be merged with the final bundle.
+ String command = Joiner.on(" && ").join(
+ "PLATFORM_PLIST=" + IosSdkCommands.platformDir(configuration) + "/Info.plist",
+ "PLIST=${TMPDIR}/env.plist",
+ "os_build=$(/usr/bin/defaults read ${PLATFORM_PLIST} BuildMachineOSBuild)",
+ "compiler=$(/usr/bin/defaults read ${PLATFORM_PLIST} DTCompiler)",
+ "platform_version=$(/usr/bin/defaults read ${PLATFORM_PLIST} Version)",
+ "sdk_build=$(/usr/bin/defaults read ${PLATFORM_PLIST} DTSDKBuild)",
+ "platform_build=$(/usr/bin/defaults read ${PLATFORM_PLIST} DTPlatformBuild)",
+ "xcode_build=$(/usr/bin/defaults read ${PLATFORM_PLIST} DTXcodeBuild)",
+ "xcode_version=$(/usr/bin/defaults read ${PLATFORM_PLIST} DTXcode)",
+ "/usr/bin/defaults write ${PLIST} DTPlatformBuild -string ${platform_build}",
+ "/usr/bin/defaults write ${PLIST} DTSDKBuild -string ${sdk_build}",
+ "/usr/bin/defaults write ${PLIST} DTPlatformVersion -string ${platform_version}",
+ "/usr/bin/defaults write ${PLIST} DTXcode -string ${xcode_version}",
+ "/usr/bin/defaults write ${PLIST} DTXCodeBuild -string ${xcode_build}",
+ "/usr/bin/defaults write ${PLIST} DTCompiler -string ${compiler}",
+ "/usr/bin/defaults write ${PLIST} BuildMachineOSBuild -string ${os_build}",
+ "cat ${PLIST} > " + getGeneratedEnvironmentPlist().getShellEscapedExecPathString());
+ ruleContext.registerAction(ObjcRuleClasses.spawnBashOnDarwinActionBuilder(command)
+ .setMnemonic("EnvironmentPlist")
+ .addOutput(getGeneratedEnvironmentPlist())
+ .build(ruleContext));
+ }
+
private Artifact registerBundleSigningActions(Artifact ipaOutput) {
PathFragment entitlementsDirectory = ruleContext.getUniqueDirectory("entitlements");
Artifact teamPrefixFile =
@@ -433,6 +464,7 @@ public final class ReleaseBundlingSupport {
.setObjcProvider(objcProvider)
.addInfoplistInputFromRule(ruleContext)
.addInfoplistInput(getGeneratedVersionPlist())
+ .addInfoplistInput(getGeneratedEnvironmentPlist())
.setIntermediateArtifacts(ObjcRuleClasses.intermediateArtifacts(ruleContext))
.setPrimaryBundleId(primaryBundleId)
.setFallbackBundleId(fallbackBundleId)
@@ -726,6 +758,11 @@ public final class ReleaseBundlingSupport {
ruleContext.getUniqueDirectory("plists"), "-version.plist");
}
+ private Artifact getGeneratedEnvironmentPlist() {
+ return ruleContext.getRelatedArtifact(
+ ruleContext.getUniqueDirectory("plists"), "-environment.plist");
+ }
+
/**
* Logic to access attributes required by application support. Attributes are required and
* guaranteed to return a value or throw unless they are annotated with {@link Nullable} in which