aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc_tools/bundlemerge/java/com/google/devtools/build/xcode/bundlemerge/BundleMerging.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/objc_tools/bundlemerge/java/com/google/devtools/build/xcode/bundlemerge/BundleMerging.java')
-rw-r--r--src/objc_tools/bundlemerge/java/com/google/devtools/build/xcode/bundlemerge/BundleMerging.java73
1 files changed, 46 insertions, 27 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);