aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc_tools
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-12-11 19:02:17 +0000
committerGravatar David Chen <dzc@google.com>2015-12-13 18:27:34 +0000
commit1373e6681e4b54f271aa3a2c762a915b462d0da7 (patch)
treefd51edad1f2b3a1be44e2e11729a5efe544c773c /src/objc_tools
parent881913ae3c5d8c587226c0280ab9ef8c0d1a8c83 (diff)
Bundlemerge optionally takes a completed plist to bundle into the archive, instead of multiple plists to merge and variable substitutions to apply.
The new key bundle_info_plist_file, gives the path to the completed plist. If it is defined, the keys source_plist_file and variable_substitution are not used. -- MOS_MIGRATED_REVID=110010012
Diffstat (limited to 'src/objc_tools')
-rw-r--r--src/objc_tools/bundlemerge/java/com/google/devtools/build/xcode/bundlemerge/BundleMerging.java73
-rw-r--r--src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java6
2 files changed, 50 insertions, 29 deletions
diff --git a/src/objc_tools/bundlemerge/java/com/google/devtools/build/xcode/bundlemerge/BundleMerging.java b/src/objc_tools/bundlemerge/java/com/google/devtools/build/xcode/bundlemerge/BundleMerging.java
index c402f60a96..6461fadc31 100644
--- a/src/objc_tools/bundlemerge/java/com/google/devtools/build/xcode/bundlemerge/BundleMerging.java
+++ b/src/objc_tools/bundlemerge/java/com/google/devtools/build/xcode/bundlemerge/BundleMerging.java
@@ -87,6 +87,10 @@ public final class BundleMerging {
private static final String INFOPLIST_FILENAME = "Info.plist";
private static final String PKGINFO_FILENAME = "PkgInfo";
+ @VisibleForTesting
+ static final String BOTH_ARGS_ERR =
+ "Only one of source_plist_file and bundle_info_plist_file may be specified";
+
/**
* A hack needed briefly to maintain backwards compatibility during rename of {@link Platform}
* enums. Except for backwards-compatible names, falls back to usage of {@link Platform#valueOf}.
@@ -114,35 +118,50 @@ public final class BundleMerging {
Path tempMergedPlist = Files.createTempFile(tempDir, null, INFOPLIST_FILENAME);
Path tempPkgInfo = Files.createTempFile(tempDir, null, PKGINFO_FILENAME);
- // Generate the Info.plist and PkgInfo files to include in the app bundle.
- ImmutableList.Builder<Path> sourcePlistFilesBuilder = new ImmutableList.Builder<>();
- for (String sourcePlist : control.getSourcePlistFileList()) {
- sourcePlistFilesBuilder.add(fileSystem.getPath(sourcePlist));
- }
- ImmutableList<Path> sourcePlistFiles = sourcePlistFilesBuilder.build();
- ImmutableMap.Builder<String, String> substitutionMap = ImmutableMap.builder();
- for (VariableSubstitution substitution : control.getVariableSubstitutionList()) {
- substitutionMap.put(substitution.getName(), substitution.getValue());
- }
- PlistMerging plistMerging = PlistMerging.from(
- sourcePlistFiles,
- PlistMerging.automaticEntries(
- control.getTargetDeviceFamilyList(),
- platformFromName(control.getPlatform()),
- control.getSdkVersion(),
- control.getMinimumOsVersion()),
- substitutionMap.build(),
- new KeysToRemoveIfEmptyString("CFBundleIconFile", "NSPrincipalClass"));
- if (control.hasExecutableName()) {
- plistMerging.setExecutableName(control.getExecutableName());
+
+ if (control.hasBundleInfoPlistFile() && !control.getSourcePlistFileList().isEmpty()) {
+ throw new IllegalArgumentException(BOTH_ARGS_ERR);
}
+ if (control.hasBundleInfoPlistFile()) {
+ Path bundleInfoPlist = fileSystem.getPath(control.getBundleInfoPlistFile());
- plistMerging.setBundleIdentifier(
- control.hasPrimaryBundleIdentifier() ? control.getPrimaryBundleIdentifier() : null,
- control.hasFallbackBundleIdentifier() ? control.getFallbackBundleIdentifier() : null);
+ new PlistMerging(PlistMerging.readPlistFile(bundleInfoPlist))
+ .setBundleIdentifier(
+ control.hasPrimaryBundleIdentifier() ? control.getPrimaryBundleIdentifier() : null,
+ control.hasFallbackBundleIdentifier() ? control.getFallbackBundleIdentifier() : null)
+ .write(tempMergedPlist, tempPkgInfo);
+ } else {
+ // TODO (cpeyser): Remove this branch once blaze uses bundle_info_plist_file
- plistMerging.write(tempMergedPlist, tempPkgInfo);
+ // Generate the Info.plist and PkgInfo files to include in the app bundle.
+ ImmutableList.Builder<Path> sourcePlistFilesBuilder = new ImmutableList.Builder<>();
+ for (String sourcePlist : control.getSourcePlistFileList()) {
+ sourcePlistFilesBuilder.add(fileSystem.getPath(sourcePlist));
+ }
+ ImmutableList<Path> sourcePlistFiles = sourcePlistFilesBuilder.build();
+ ImmutableMap.Builder<String, String> substitutionMap = ImmutableMap.builder();
+ for (VariableSubstitution substitution : control.getVariableSubstitutionList()) {
+ substitutionMap.put(substitution.getName(), substitution.getValue());
+ }
+ PlistMerging plistMerging =
+ PlistMerging.from(
+ sourcePlistFiles,
+ PlistMerging.automaticEntries(
+ control.getTargetDeviceFamilyList(),
+ platformFromName(control.getPlatform()),
+ control.getSdkVersion(),
+ control.getMinimumOsVersion()),
+ substitutionMap.build(),
+ new KeysToRemoveIfEmptyString("CFBundleIconFile", "NSPrincipalClass"));
+ if (control.hasExecutableName()) {
+ plistMerging.setExecutableName(control.getExecutableName());
+ }
+ plistMerging.setBundleIdentifier(
+ control.hasPrimaryBundleIdentifier() ? control.getPrimaryBundleIdentifier() : null,
+ control.hasFallbackBundleIdentifier() ? control.getFallbackBundleIdentifier() : null)
+ .write(tempMergedPlist, tempPkgInfo);
+ }
bundleRoot = joinPath(bundleRoot, control.getBundleRoot());
@@ -232,8 +251,8 @@ public final class BundleMerging {
combiner.addFile(zipOutEntry, zipIn);
}
}
- }
-
+ }
+
@VisibleForTesting
void execute() throws IOException {
try (OutputStream out = Files.newOutputStream(outputZip);
diff --git a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java
index 00f211dd9e..c7ed0b182a 100644
--- a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java
+++ b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java
@@ -80,8 +80,10 @@ public class PlistMerging extends Value<PlistMerging> {
private final NSDictionary merged;
- @VisibleForTesting
- PlistMerging(NSDictionary merged) {
+ /**
+ * Wraps a {@code NSDictionary} as a PlistMerging.
+ */
+ public PlistMerging(NSDictionary merged) {
super(merged);
this.merged = merged;
}