aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc_tools
diff options
context:
space:
mode:
authorGravatar Dave MacLachlan <dmaclach@google.com>2015-10-27 16:21:53 +0000
committerGravatar David Chen <dzc@google.com>2015-10-27 19:43:48 +0000
commit45af6c20716fa40bec914d53f5c5ec6045a5df16 (patch)
tree45dafb27b249ac38964e13a962a90177c5f204dc /src/objc_tools
parentd8e857e93c6e71efbda7cafaf867b8c749012aa2 (diff)
Do not add CFBundleIdentifier, CFBundleVersion and CFBundleShortVersion to all files that go through the plmerge routines. It turns out we use plmerge to convert string files from text to binary.
RELNOTES:none -- MOS_MIGRATED_REVID=106403889
Diffstat (limited to 'src/objc_tools')
-rw-r--r--src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java6
-rw-r--r--src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java37
2 files changed, 25 insertions, 18 deletions
diff --git a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java
index c07a8992b5..ea13c29ab9 100644
--- a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java
+++ b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlMerge.java
@@ -89,7 +89,11 @@ public class PlMerge {
PlistMerging merging = PlistMerging.from(sourceFilePaths, ImmutableMap.<String, NSObject>of(),
ImmutableMap.<String, String>of(), new KeysToRemoveIfEmptyString());
- merging.setBundleIdentifier(options.primaryBundleId, options.fallbackBundleId);
+ if (options.primaryBundleId != null || options.fallbackBundleId != null) {
+ // Only set the bundle identifier if we were passed arguments to do so.
+ // This prevents CFBundleIdentifiers being put into strings files.
+ merging.setBundleIdentifier(options.primaryBundleId, options.fallbackBundleId);
+ }
merging.writePlist(fileSystem.getPath(options.outFile));
}
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 1ba520f9ba..d38bb7c572 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
@@ -174,8 +174,8 @@ public class PlistMerging extends Value<PlistMerging> {
}
/**
- * Generates final merged Plist file and PkgInfo file in the specified locations, and includes the
- * "automatic" entries in the Plist.
+ * Generates a Plistmerging combining values from sourceFiles and automaticEntries, and modifying
+ * them based on subsitutions and keysToRemoveIfEmptyString.
*/
public static PlistMerging from(List<Path> sourceFiles, Map<String, NSObject> automaticEntries,
Map<String, String> substitutions, KeysToRemoveIfEmptyString keysToRemoveIfEmptyString)
@@ -206,27 +206,30 @@ public class PlistMerging extends Value<PlistMerging> {
// Info.plist files must contain a valid CFBundleVersion and a valid CFBundleShortVersionString,
// or it will be rejected by Apple.
// A valid Bundle Version is 18 characters or less, and only contains [0-9.]
+ // We know we have an info.plist file as opposed to a strings file if the automaticEntries
+ // have any values set.
// TODO(bazel-team): warn user if we replace their values.
- Pattern versionPattern = Pattern.compile("[^0-9.]");
- if (!merged.containsKey(BUNDLE_VERSION_PLIST_KEY)) {
- merged.put(BUNDLE_VERSION_PLIST_KEY, BUNDLE_VERSION_DEFAULT);
- } else {
- NSObject nsVersion = merged.get(BUNDLE_VERSION_PLIST_KEY);
- String version = (String) nsVersion.toJavaObject();
- if (version.length() > 18 || versionPattern.matcher(version).find()) {
+ if (automaticEntries.size() > 0) {
+ Pattern versionPattern = Pattern.compile("[^0-9.]");
+ if (!merged.containsKey(BUNDLE_VERSION_PLIST_KEY)) {
merged.put(BUNDLE_VERSION_PLIST_KEY, BUNDLE_VERSION_DEFAULT);
+ } else {
+ NSObject nsVersion = merged.get(BUNDLE_VERSION_PLIST_KEY);
+ String version = (String) nsVersion.toJavaObject();
+ if (version.length() > 18 || versionPattern.matcher(version).find()) {
+ merged.put(BUNDLE_VERSION_PLIST_KEY, BUNDLE_VERSION_DEFAULT);
+ }
}
- }
- if (!merged.containsKey(BUNDLE_SHORT_VERSION_STRING_PLIST_KEY)) {
- merged.put(BUNDLE_SHORT_VERSION_STRING_PLIST_KEY, BUNDLE_SHORT_VERSION_STRING_DEFAULT);
- } else {
- NSObject nsVersion = merged.get(BUNDLE_SHORT_VERSION_STRING_PLIST_KEY);
- String version = (String) nsVersion.toJavaObject();
- if (version.length() > 18 || versionPattern.matcher(version).find()) {
+ if (!merged.containsKey(BUNDLE_SHORT_VERSION_STRING_PLIST_KEY)) {
merged.put(BUNDLE_SHORT_VERSION_STRING_PLIST_KEY, BUNDLE_SHORT_VERSION_STRING_DEFAULT);
+ } else {
+ NSObject nsVersion = merged.get(BUNDLE_SHORT_VERSION_STRING_PLIST_KEY);
+ String version = (String) nsVersion.toJavaObject();
+ if (version.length() > 18 || versionPattern.matcher(version).find()) {
+ merged.put(BUNDLE_SHORT_VERSION_STRING_PLIST_KEY, BUNDLE_SHORT_VERSION_STRING_DEFAULT);
+ }
}
}
-
return new PlistMerging(merged);
}