diff options
author | Googler <noreply@google.com> | 2015-12-16 16:35:56 +0000 |
---|---|---|
committer | Nathan Harmata <nharmata@google.com> | 2015-12-16 20:24:28 +0000 |
commit | f5c3a974a7c9568cb071c56800899de6d8650c5d (patch) | |
tree | 7cb45dd7a5e510e09336d61c41a3642b9a76a9d4 /src | |
parent | 76d94b1c2f3a92544f9c9de536b56b53a242c21a (diff) |
plmerge optionally consumes an executable name. This is necessary to ensure that Blaze can assign a default executable name, for when CFBundleExecutable is not given.
--
MOS_MIGRATED_REVID=110363400
Diffstat (limited to 'src')
4 files changed, 41 insertions, 8 deletions
diff --git a/src/main/protobuf/plmerge.proto b/src/main/protobuf/plmerge.proto index 0cfee922ab..58855d5328 100644 --- a/src/main/protobuf/plmerge.proto +++ b/src/main/protobuf/plmerge.proto @@ -19,7 +19,7 @@ option java_package = "com.google.devtools.build.xcode.plmerge.proto"; // Contains necessary arguments for PlMerge, which is responsible for merging // plist files. -// Next Id: 7 +// Next Id: 8 message Control { // Paths to the plist files to merge relative to execution root. repeated string source_file = 1; @@ -51,4 +51,10 @@ message Control { // identifier is not specified in primary_bundle_id or an associated plist // file. optional string fallback_bundle_id = 5; + + // Name of executable for the bundle this merged plist is intended for, or + // unset if no such executable exists. If a value for CFBundleExectuable is + // given in a source_file or immutable_source_file, that value mut not + // conflict with this key. + optional string executable_name = 7; }
\ No newline at end of file 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 6461fadc31..c9714b637b 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 @@ -152,7 +152,8 @@ public final class BundleMerging { control.getSdkVersion(), control.getMinimumOsVersion()), substitutionMap.build(), - new KeysToRemoveIfEmptyString("CFBundleIconFile", "NSPrincipalClass")); + new KeysToRemoveIfEmptyString("CFBundleIconFile", "NSPrincipalClass"), + /*executableName*/ null); if (control.hasExecutableName()) { plistMerging.setExecutableName(control.getExecutableName()); } diff --git a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/MergingArguments.java b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/MergingArguments.java index 9f92f65771..61d23de749 100644 --- a/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/MergingArguments.java +++ b/src/objc_tools/plmerge/java/com/google/devtools/build/xcode/plmerge/MergingArguments.java @@ -37,6 +37,7 @@ class MergingArguments { private final Map<String, String> variableSubstitutions; private final String primaryBundleId; private final String fallbackBundleId; + private final String executableName; /** * Build MergingArguments from a plmerge protobuf. @@ -58,6 +59,11 @@ class MergingArguments { variableSubstitutions = control.getVariableSubstitutionMap(); primaryBundleId = control.getPrimaryBundleId(); fallbackBundleId = control.getFallbackBundleId(); + if (control.hasExecutableName()) { + executableName = control.getExecutableName(); + } else { + executableName = null; + } } /** @@ -75,6 +81,7 @@ class MergingArguments { variableSubstitutions = ImmutableMap.<String, String>of(); primaryBundleId = options.primaryBundleId; fallbackBundleId = options.fallbackBundleId; + executableName = null; } /** @@ -130,4 +137,12 @@ class MergingArguments { public Map<String, String> getVariableSubstitutions() { return variableSubstitutions; } + + /** + * Returns the name of the executable for the bundle the merged plist is intended for, or null + * if no such executable exists. + */ + public String getExecutableName() { + return executableName; + } } 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 c7ed0b182a..6a39870910 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 @@ -187,24 +187,27 @@ public class PlistMerging extends Value<PlistMerging> { mergingArguments.getSourceFilePaths(), mergingArguments.getImmutableSourceFilePaths(), mergingArguments.getVariableSubstitutions(), - keysToRemoveIfEmptyString); + keysToRemoveIfEmptyString, + mergingArguments.getExecutableName()); } /** - * Generates a Plistmerging combining values from sourceFiles and immutableSourceFiles, and + * Generates a Plistmerging combining values from sourceFiles and immutableSourceFiles, and * modifying them based on subsitutions and keysToRemoveIfEmptyString. */ public static PlistMerging from( List<Path> sourceFiles, List<Path> immutableSourceFiles, Map<String, String> substitutions, - KeysToRemoveIfEmptyString keysToRemoveIfEmptyString) + KeysToRemoveIfEmptyString keysToRemoveIfEmptyString, + String executableName) throws IOException { return from( sourceFiles, PlistMerging.merge(immutableSourceFiles), substitutions, - keysToRemoveIfEmptyString); + keysToRemoveIfEmptyString, + executableName); } /** @@ -219,7 +222,8 @@ public class PlistMerging extends Value<PlistMerging> { List<Path> sourceFiles, Map<String, NSObject> immutableEntries, Map<String, String> substitutions, - KeysToRemoveIfEmptyString keysToRemoveIfEmptyString) + KeysToRemoveIfEmptyString keysToRemoveIfEmptyString, + String executableName) throws IOException { NSDictionary merged = PlistMerging.merge(sourceFiles); @@ -273,7 +277,14 @@ public class PlistMerging extends Value<PlistMerging> { } } } - return new PlistMerging(merged); + + PlistMerging result = new PlistMerging(merged); + + if (executableName != null) { + result.setExecutableName(executableName); + } + + return result; } private static String substituteEnvironmentVariable( |