diff options
author | 2015-09-15 10:36:26 +0000 | |
---|---|---|
committer | 2015-09-15 20:26:57 +0000 | |
commit | 27404a9225d507874879e01be4962fd5b3bd4e35 (patch) | |
tree | 063c5dbbb91c54fa7c63a6314d0e61bebd6fc342 /src/main/java/com/google/devtools/build/lib/rules/objc | |
parent | 30df7fc06f35fb691e0bb67085e25be1a8d21b04 (diff) |
Parses the correct values of SDK, Platform and XCode version numbers when generating
the environment's plist.
The script no longer parses the values from the Platform's Info.plist, which contained
the values used to compile the Platform's library *itself*, rather than the values
of the actual running environment.
Also the BuildMachineOSBuild is being read from the sw_version, rather than
the Xcode's plist, and the DTSDKBuild is determined by the plist under sdk-path.
An example environment.plist:
{
BuildMachineOSBuild = 14F27;
DTCompiler = "com.apple.compilers.llvm.clang.1_0";
DTPlatformBuild = 12H141;
DTPlatformVersion = "8.4";
DTSDKBuild = 12H141;
DTXCodeBuild = 6E35b;
DTXcode = 0640;
}
--
MOS_MIGRATED_REVID=103079006
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java | 2 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java | 47 |
2 files changed, 25 insertions, 24 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java index 7b53bcae59..3f4b60c659 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java @@ -981,6 +981,8 @@ public class ObjcRuleClasses { })) .add(attr("$bundlemerge", LABEL).cfg(HOST).exec() .value(env.getLabel("//tools/objc:bundlemerge"))) + .add(attr("$environment_plist_sh", LABEL).cfg(HOST) + .value(env.getLabel("//tools/objc:environment_plist.sh"))) .build(); } @Override 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 f6a3af6eb0..78acdaed12 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 @@ -21,6 +21,7 @@ import static com.google.devtools.build.lib.rules.objc.TargetDeviceFamily.UI_DEV import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; +import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -302,32 +303,22 @@ public final class ReleaseBundlingSupport { 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 + // 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=$(mktemp -d -t bazel_environment)/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(), - "rm -rf \"${PLIST}\""); - ruleContext.registerAction(ObjcRuleClasses.spawnBashOnDarwinActionBuilder(ruleContext, command) - .setMnemonic("EnvironmentPlist") - .addOutput(getGeneratedEnvironmentPlist()) - .build(ruleContext)); + String platformWithVersion = + String.format("%s%s", configuration.getBundlingPlatform().getLowerCaseNameInPlist(), + Strings.nullToEmpty(configuration.getIosSdkVersion())); + ruleContext.registerAction( + ObjcRuleClasses.spawnOnDarwinActionBuilder(ruleContext) + .setMnemonic("EnvironmentPlist") + .addInput(attributes.environmentPlistScript()) + .setExecutable(attributes.environmentPlistScript()) + .addArguments("--platform", platformWithVersion) + .addArguments( + "--output", getGeneratedEnvironmentPlist().getShellEscapedExecPathString()) + .addOutput(getGeneratedEnvironmentPlist()) + .build(ruleContext)); } private Artifact registerBundleSigningActions(Artifact ipaOutput) throws InterruptedException { @@ -877,6 +868,14 @@ public final class ReleaseBundlingSupport { return ruleContext.getPrerequisiteArtifact("$swiftstdlibtoolzip_deploy", Mode.HOST); } + /** + * Returns the location of the environment_plist.sh. + */ + public Artifact environmentPlistScript() { + return checkNotNull( + ruleContext.getPrerequisiteArtifact("$environment_plist_sh", Mode.HOST)); + } + String bundleId() { return checkNotNull(stringAttribute("bundle_id")); } |