[armedbear-cvs] r13197 - in trunk/abcl: . src/org/armedbear/lisp

Mark Evenson mevenson at common-lisp.net
Sun Jan 30 22:26:44 UTC 2011


Author: mevenson
Date: Sun Jan 30 17:26:43 2011
New Revision: 13197

Log:
Incorporate output of 'svnversion' into LISP-IMPLEMENTATION-VERSION.

In the Ant-based build, if the executable 'svnversion' can be found on
the PATH and the topmost '.svn' subdirectory exists, the output of
'svnversion' is appended to the value returned by
LISP-IMPLEMENTATION-VERSION.

The use of 'version.src' in 'abcl.properties' has been removed.

TODO: the same functionality should be added to the Lisp-based build.

TODO: test that this works on Windows.

Modified:
   trunk/abcl/abcl.properties.in
   trunk/abcl/build.xml
   trunk/abcl/src/org/armedbear/lisp/Version.java

Modified: trunk/abcl/abcl.properties.in
==============================================================================
--- trunk/abcl/abcl.properties.in	(original)
+++ trunk/abcl/abcl.properties.in	Sun Jan 30 17:26:43 2011
@@ -1,8 +1,5 @@
 # $Id$
 
-# version.src contents show up in JAR Manifest in the Implementation-Source attribute
-#version.src=[abcl svn]
-
 # abcl.build.incremental attempts to perform incremental compilation
 #abcl.build.incremental=true
 

Modified: trunk/abcl/build.xml
==============================================================================
--- trunk/abcl/build.xml	(original)
+++ trunk/abcl/build.xml	Sun Jan 30 17:26:43 2011
@@ -85,6 +85,7 @@
       <include name="org/armedbear/lisp/**/*.class"/>
       <include name="org/armedbear/lisp/**/*.cls"/> 
       <include name="org/armedbear/lisp/**/*.abcl"/>
+      <include name="org/armedbear/lisp/version"/>
       <include name="org/armedbear/lisp/scripting/*.class" if="abcl.jsr-223.p"/>
       <include name="org/armedbear/lisp/scripting/util/*.class" if="abcl.jsr-223.p"/>
       <patternset refid="abcl.source.lisp.dist"/>
@@ -147,10 +148,6 @@
 	</or>  
       </condition>
 
-      <!-- Set from commandline via -D or in 'build.properties' -->
-      <property name="build.version" value="abcl.svn"/>
-      <echo>Implementation-Source: ${version.src}</echo>
-
     </target>
     
     <target name="abcl.java.warning" 
@@ -258,25 +255,85 @@
 
     <property name="abcl.build.path"
 	      value="${build.classes.dir}/org/armedbear/lisp/build"/>
-    <target name="abcl.stamp" depends="abcl.compile,abcl.stamp.version,abcl.stamp.hostname">
+    <target name="abcl.stamp" 
+            depends="abcl.compile,abcl.stamp.version,abcl.stamp.hostname">
       <mkdir dir="${abcl.build.path}/.."/>
       <echo message="${build}" file="${abcl.build.path}"/>    
     </target>
 
+
+    <!-- Environment variables may be accessed as ${env.NAME} -->
+    <property environment="env"/>
+
+    <!-- Can we derive an SVN version from the current build tree? -->
+    <condition property="abcl.version.svn.p">
+      <and>
+        <available
+            file="${basedir}/.svn"
+            type="dir"/>
+        <available
+            file="svnversion"
+            filepath="${env.PATH}"/>
+      </and>
+    </condition>
+
+    <target name="abcl.version.src" depends="abcl.version.src.3"/>
+
+    <target name="abcl.version.src.1">
+      <exec 
+          executable="svnversion"
+          outputproperty="abcl.version.svn"
+          failifexecutionfails="false" />
+    </target>
+
+    <target name="abcl.version.src.2" 
+            depends="abcl.version.src.1"
+            if="abcl.version.svn.p">
+      <echo>abcl.version.svn: ${abcl.version.svn}</echo>
+      <property name="abcl.version.src"
+                value="svn-${abcl.version.svn}"/>
+    </target>
+
+    <target name="abcl.version.src.3"
+            depends="abcl.version.src.2"
+            unless="abcl.version.svn.p">
+      <property name="abcl.version.src"
+                value=""/>
+    </target>
+
     <property name="abcl.home.dir"
               value="${src.dir}/org/armedbear/lisp/"/>
     <property name="abcl.version.path"
 	      value="${build.classes.dir}/org/armedbear/lisp/version"/>
-    <target name="abcl.stamp.version" depends="abcl.compile.java"  >
+
+    <target name="abcl.stamp.version" 
+            depends="abcl.version.src,abcl.stamp.version.1,abcl.stamp.version.2">
+      <mkdir dir="${abcl.version.path}/.."/>
+      <echo>ABCL implementation version: ${abcl.implementation.version}</echo>
+      <echo file="${abcl.version.path}">${abcl.implementation.version}</echo>
+    </target>
+    
+    <target name="abcl.stamp.version.0" 
+            depends="abcl.compile.java">
       <java fork="true"
 	    classpath="${build.classes.dir}"
 	    outputproperty="abcl.version"
 	    classname="org.armedbear.lisp.Version"
             logerror="yes"/> <!-- Don't catch stderr output -->
+    </target>
 
-      <echo>ABCL version: ${abcl.version}</echo>
-      <mkdir dir="${abcl.version.path}/.."/>
-      <echo message="${abcl.version}" file="${abcl.version.path}"/> 
+    <target name="abcl.stamp.version.1"
+            depends="abcl.stamp.version.0"
+            unless="abcl.version.svn.p">
+      <property name="abcl.implementation.version"
+                value="${abcl.version}"/>
+    </target>
+
+    <target name="abcl.stamp.version.2" 
+            depends="abcl.stamp.version.0"
+            if="abcl.version.svn.p">
+      <property name="abcl.implementation.version"
+                value="${abcl.version}-${abcl.version.src}"/>
     </target>
 
     <target name="abcl.stamp.hostname" if="unix">
@@ -324,11 +381,9 @@
 	    <attribute name="Implementation-Title" 
 		       value="ABCL"/>
 	    <attribute name="Implementation-Version"  
-		       value="${abcl.version}"/>
+		       value="${abcl.implementation.version}"/>
 	    <attribute name="Implementation-Build" 
 		       value="${build}"/>
-	    <attribute name="Implementation-Source" 
-		       value="${version.src}"/>
 	  </section>
 	</manifest>
 	<metainf dir="${src.dir}/META-INF"> 

Modified: trunk/abcl/src/org/armedbear/lisp/Version.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Version.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Version.java	Sun Jan 30 17:26:43 2011
@@ -33,15 +33,34 @@
 
 package org.armedbear.lisp;
 
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
 public final class Version
 {
-  private Version()
-  {
+  private Version() {}
+  
+  static final String baseVersion = "0.25.0-dev";
+  
+  static void init() {
+    try {
+      InputStream input = Version.class.getResourceAsStream("version");
+      BufferedReader reader = new BufferedReader(new InputStreamReader(input));
+      String v = reader.readLine().trim();
+      version = v;
+    } catch (Throwable t) {
+      version = baseVersion;
+    } 
   }
-
-  public static String getVersion()
+  
+  static String version = "";
+  public synchronized static String getVersion()
   {
-    return "0.25.0-dev";
+    if ("".equals(version)) {
+      init();
+    }
+    return version;
   }
 
   public static void main(String args[]) {




More information about the armedbear-cvs mailing list