altosdroid: add autogenerated BuildInfo.java
authorMike Beattie <mike@ethernal.org>
Sun, 21 Oct 2012 22:55:07 +0000 (11:55 +1300)
committerMike Beattie <mike@ethernal.org>
Mon, 22 Oct 2012 06:17:58 +0000 (19:17 +1300)
* Generated by shell script that parses git describe
* Makefile rule to call script on every run
* also includes eclipse hooks to call shell script on build

Signed-off-by: Mike Beattie <mike@ethernal.org>
altosdroid/.externalToolBuilders/Generate BuildInfo.java.launch [new file with mode: 0644]
altosdroid/.gitignore
altosdroid/.project
altosdroid/Makefile.am
altosdroid/buildinfo.sh [new file with mode: 0755]
altosdroid/src/org/altusmetrum/AltosDroid/BuildInfo.java.in [new file with mode: 0644]

diff --git a/altosdroid/.externalToolBuilders/Generate BuildInfo.java.launch b/altosdroid/.externalToolBuilders/Generate BuildInfo.java.launch
new file mode 100644 (file)
index 0000000..3b8eff4
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;resources&gt;&#10;&lt;item path=&quot;/AltosDroid/src/org/altusmetrum/AltosDroid/BuildInfo.java&quot; type=&quot;1&quot;/&gt;&#10;&lt;/resources&gt;}"/>
+<booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/AltosDroid/buildinfo.sh}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/AltosDroid}"/>
+</launchConfiguration>
index c0bb8dd49fe499ffa29593dba371369e85d71f0d..e3acba4051795715f5a0514552778b6e09ae4371 100644 (file)
@@ -1,3 +1,4 @@
 local.properties
 bin
 gen
+src/org/altusmetrum/AltosDroid/BuildInfo.java
index 7b56596a3cbdd63eab336d51e0c5956b98d77961..ebe4a4bbc8aaf782401952810078cb74bd8627e9 100644 (file)
@@ -5,6 +5,16 @@
        <projects>
        </projects>
        <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
+                       <triggers>auto,full,incremental,</triggers>
+                       <arguments>
+                               <dictionary>
+                                       <key>LaunchConfigHandle</key>
+                                       <value>&lt;project&gt;/.externalToolBuilders/Generate BuildInfo.java.launch</value>
+                               </dictionary>
+                       </arguments>
+               </buildCommand>
                <buildCommand>
                        <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
                        <arguments>
index 96831b722ba7955a87242bf562e5823df8965f37..3860e110b1804357e8f070e792280852aa39f175 100644 (file)
@@ -30,6 +30,7 @@ SRC=\
        $(SRC_DIR)/TelemetryLogger.java \
        $(SRC_DIR)/AltosBluetooth.java \
        $(SRC_DIR)/DeviceListActivity.java \
+       $(SRC_DIR)/BuildInfo.java \
        $(SRC_DIR)/Dumper.java
 
 all: $(all_target)
@@ -38,6 +39,9 @@ $(ALTOSLIB): $(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR)
        mkdir -p $(EXT_LIBDIR)
        cd $(EXT_LIBDIR) && ln -s $(shell echo $(EXT_LIBDIR) | sed 's|[^/]\+|..|g')/$(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) .
 
+$(SRC_DIR)/BuildInfo.java:
+       ./buildinfo.sh
+
 if ANDROID
 install-release: bin/AltosDroid-release.apk
        $(ADB) install -r bin/AltosDroid-release.apk
@@ -55,3 +59,4 @@ endif
 clean:
        $(clean_command)
 
+.PHONY: $(SRC_DIR)/BuildInfo.java
diff --git a/altosdroid/buildinfo.sh b/altosdroid/buildinfo.sh
new file mode 100755 (executable)
index 0000000..f620c4a
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+
+describe=$(git describe --always 2>/dev/null || echo '')
+if [ -n "$describe" ]; then
+   version=$(echo $describe | cut -d- -f1)
+   commitnum=$(echo $describe | cut -d- -f2)
+   commithash=$(echo $describe | cut -d- -f3)
+else
+   . ../src/Version
+   version=$VERSION
+   commitnum=''
+   commithash=''
+fi
+
+builddate=$(date "+%Y-%m-%d")
+buildtime=$(date "+%H:%M")
+
+
+infile=src/org/altusmetrum/AltosDroid/BuildInfo.java.in
+outfile=src/org/altusmetrum/AltosDroid/BuildInfo.java
+
+echo "Version $describe, built on $builddate, $buildtime"
+
+sed -e "s/@DESCRIBE@/$describe/" \
+    -e "s/@VERSION@/$version/" \
+    -e "s/@COMMITNUM@/$commitnum/" \
+    -e "s/@COMMITHASH@/$commithash/" \
+    -e "s/@BUILDDATE@/$builddate/" \
+    -e "s/@BUILDTIME@/$buildtime/" \
+ $infile > $outfile
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/BuildInfo.java.in b/altosdroid/src/org/altusmetrum/AltosDroid/BuildInfo.java.in
new file mode 100644 (file)
index 0000000..763f814
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2012 Mike Beattie <mike@ethernal.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosDroid;
+
+public class BuildInfo {
+       public static final String git_describe = "@DESCRIBE@";
+       public static final String version      = "@VERSION@";
+       public static final String commitnum    = "@COMMITNUM@";
+       public static final String commithash   = "@COMMITHASH@";
+       public static final String builddate    = "@BUILDDATE@";
+       public static final String buildtime    = "@BUILDTIME@";
+}
+