aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
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
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')
-rw-r--r--src/main/protobuf/bundlemerge.proto12
-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
3 files changed, 62 insertions, 29 deletions
diff --git a/src/main/protobuf/bundlemerge.proto b/src/main/protobuf/bundlemerge.proto
index b31bec9852..41a338a093 100644
--- a/src/main/protobuf/bundlemerge.proto
+++ b/src/main/protobuf/bundlemerge.proto
@@ -20,11 +20,19 @@ option java_package = "com.google.devtools.build.xcode.bundlemerge.proto";
// Contains all the arguments necessary to drive the BundleMerge tool,
// including the path to the output file and extra files to include in the
// bundle.
+// Next Id: 17
message Control {
// Paths to the plist files to merge into the final Plist.info file. These
// can be binary, XML, or ASCII format.
+ // This field is deprecated, but is supported for backwards compatibility.
+ // If bundle_info_plist_file is not supplied, this key will be used instead.
repeated string source_plist_file = 1;
+ // The single info.plist file to be bundled into the archive. This plist will
+ // not be modified by bundlemerge.
+ // This field replaces source_plist_file.
+ optional string bundle_info_plist_file = 16;
+
// Path to the .ipa file to write. This is the final application bundle. Note
// this is ignored for nested bundles.
optional string out_file = 2;
@@ -69,6 +77,10 @@ message Control {
// Variable substitutions to perform on property values in the merged
// .plist file.
+ // This field is deprecated, and will not be used if a bundle_info_plist_file
+ // is specified. For backwards compatibility, if a bundle_info_plist_file
+ // is not specified, source_plist_file will be used instead and variable
+ // substitutions will be applied.
repeated VariableSubstitution variable_substitution = 11;
// Bundles that are nested within this one. bundle_root in these bundles is
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;
}