aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2015-05-27 15:12:01 +0000
committerGravatar Laurent Le Brun <laurentlb@google.com>2015-05-27 16:50:13 +0000
commit0540fdefe2c27605516a772c2a224d579db0a74d (patch)
tree4d7c11fcf331704d17ca19a68c53257b065f074f /src/main/java/com/google/devtools/build
parent1170dc6055ed0d669275efb1ab1906d2715ad1c3 (diff)
Extract version numbers that look like "..._1.2.3_..." from BUILD_EMBED_LABEL into Info.plist.
-- MOS_MIGRATED_REVID=94572729
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java
index 289b3b9379..975600f5ca 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java
@@ -87,6 +87,18 @@ public final class ReleaseBundlingSupport {
@VisibleForTesting
static final String EXTENSION_BUNDLE_DIR_FORMAT = "PlugIns/%s.appex";
+ /**
+ * Command string for "sed" that tries to extract the application version number from a larger
+ * string. For example, from "foo_1.2.3_RC00" this would extract "1.2.3". This regex looks for
+ * versions of the format "x.y" or "x.y.z", which may be preceded and/or followed by other text,
+ * such as a project name or release candidate number.
+ *
+ * <p>This command also preserves double quotes around the string, if any.
+ */
+ private static final String EXTRACT_VERSION_NUMBER_SED_COMMAND =
+ "s#\\(\"\\)\\{0,1\\}\\(.*_\\)\\{0,1\\}\\([0-9][0-9]*\\(\\.[0-9][0-9]*\\)\\{1,2\\}\\)"
+ + "\\(_[^\"]*\\)\\{0,1\\}\\(\"\\)\\{0,1\\}#\\1\\3\\6#";
+
private final Attributes attributes;
private final BundleSupport bundleSupport;
private final RuleContext ruleContext;
@@ -224,7 +236,8 @@ public final class ReleaseBundlingSupport {
.add(
"VERSION=\"$("
+ "grep \"^" + BuildInfo.BUILD_EMBED_LABEL + "\" " + buildInfo.getExecPathString()
- + " | cut -d' ' -f2- | sed -e 's#\"#\\\"#g')\" && "
+ + " | cut -d' ' -f2- | sed -e '" + EXTRACT_VERSION_NUMBER_SED_COMMAND + "' | "
+ + "sed -e 's#\"#\\\"#g')\" && "
+ "cat >" + getGeneratedVersionPlist().getExecPathString() + " <<EOF\n"
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" "