aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc_tools
diff options
context:
space:
mode:
authorGravatar Dave MacLachlan <dmaclach@google.com>2015-10-24 00:05:57 +0000
committerGravatar Florian Weikert <fwe@google.com>2015-10-27 11:46:22 +0000
commit6b47b094cb3410ce54e978d16f4121d92027f3bf (patch)
treec337d2f07216a377dcfa82e3a78ab2b29b49da04 /src/objc_tools
parentd7795f42c61b90c4b33715b57234ef7c99817154 (diff)
Change default bundle ids that are generated in plists to be RFC1034 compliant. In general this means taking bad characters [^-0-9A-Za-z.] and converting them to "-". So com.foo.bar_bam becomes com.foo.bar-bam. This is essentially equivalent to what Xcode does internally.
RELNOTES:none -- MOS_MIGRATED_REVID=106191981
Diffstat (limited to 'src/objc_tools')
-rw-r--r--src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/PlistMerging.java26
1 files changed, 16 insertions, 10 deletions
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 e35255c57c..1ba520f9ba 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
@@ -230,23 +230,29 @@ public class PlistMerging extends Value<PlistMerging> {
return new PlistMerging(merged);
}
- // Assume that if an RFC 1034 format string is specified, the value is RFC 1034 compliant.
private static String substituteEnvironmentVariable(
Map<String, String> substitutions, String string) {
// The substitution is *not* performed recursively.
for (Map.Entry<String, String> variable : substitutions.entrySet()) {
- for (String variableNameWithFormatString : withFormatStrings(variable.getKey())) {
- string = string
- .replace("${" + variableNameWithFormatString + "}", variable.getValue())
- .replace("$(" + variableNameWithFormatString + ")", variable.getValue());
- }
+ String key = variable.getKey();
+ String value = variable.getValue();
+ string = string
+ .replace("${" + key + "}", value)
+ .replace("$(" + key + ")", value);
+ key = key + ":rfc1034identifier";
+ value = convertToRFC1034(value);
+ string = string
+ .replace("${" + key + "}", value)
+ .replace("$(" + key + ")", value);
}
return string;
}
- private static ImmutableSet<String> withFormatStrings(String variableName) {
- return ImmutableSet.of(variableName, variableName + ":rfc1034identifier");
+ // Force RFC1034 compliance by changing any "bad" character to a '-'
+ // This is essentially equivalent to what Xcode does.
+ private static String convertToRFC1034(String value) {
+ return value.replaceAll("[^-0-9A-Za-z.]", "-");
}
@VisibleForTesting
@@ -291,10 +297,10 @@ public class PlistMerging extends Value<PlistMerging> {
NSString bundleIdentifier = (NSString) merged.get(BUNDLE_IDENTIFIER_PLIST_KEY);
if (primaryIdentifier != null) {
- merged.put(BUNDLE_IDENTIFIER_PLIST_KEY, primaryIdentifier);
+ merged.put(BUNDLE_IDENTIFIER_PLIST_KEY, convertToRFC1034(primaryIdentifier));
} else if (bundleIdentifier == null) {
if (fallbackIdentifier != null) {
- merged.put(BUNDLE_IDENTIFIER_PLIST_KEY, fallbackIdentifier);
+ merged.put(BUNDLE_IDENTIFIER_PLIST_KEY, convertToRFC1034(fallbackIdentifier));
} else {
// TODO(bazel-team): We shouldn't be generating an info.plist in this case.
merged.put(BUNDLE_IDENTIFIER_PLIST_KEY, BUNDLE_IDENTIFIER_DEFAULT);