shithub: jbig2

Download patch

ref: f8e18fdeb01cdbd9530804077beed6cac38ef077
parent: f34a521eba46e811287fb4f35519fc32f0b6d4e8
author: Ralph Giles <giles@ghostscript.com>
date: Thu Oct 29 12:52:50 EDT 2009

Have the scons build automatically determine the version string.

SConstruct tries to call 'git describe --tags' which produces a version
string based on the most recent tag, with the number of commits and
current commit hash appended if HEAD isn't a tagged revision.

If that command fails (i.e. building from a release tarball or another
version control system) it attempts to read the CHANGES file and uses
the first version number there.

--- a/SConstruct
+++ b/SConstruct
@@ -1,8 +1,24 @@
 # this is an SCons build specification file
 
+import os
+
+# try to get the version number from various local information
+version = os.popen('git describe --tags 2>/dev/null').read().strip()
+if not version:
+  try:
+    for line in open('CHANGES'):
+      words = line.split()
+      if len(words) > 1 and words[0].lower() == 'version':
+        version = words[1]
+        break
+  except IOError:
+    pass
+if not version:
+  version = 'unknown-version'
+
 env = Environment(CPPDEFINES = {'HAVE_STDINT_H' : None,
 				'PACKAGE' : '\\"jbig2dec\\"',
-				'VERSION' : '\\"0.11\\"',
+				'VERSION' : '\\"'+version+'\\"',
 				'JBIG2_DEBUG' : None,
 				'JBIG2_HALFTONE' : None})
 env.Append(CCFLAGS = ' -g -Wall')