[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: rev 4076 - in trunk: . build

From: Matt Kraai <kraai_at_alumni.cmu.edu>
Date: 2002-12-11 22:13:24 CET

On Wed, Dec 11, 2002 at 11:09:50AM -0800, Justin Erenkrantz wrote:
> <kraai@alumni.cmu.edu> wrote:
>
> >How about the following patch?
> >
> >Matt
> >
> >* Makefile.in
> > (local-extraclean): Remove configure.in.
> >
> >* autogen.sh: Ensure build/getversion.py is executable, and generate
> > configure.in with the version embedded therein.
> >
> >* build/get-version.sh: Remove.
> >
> >* build/getversion.py: Add #! line and convert line endings.
> >
> >* configure.in: Rename to...
> >
> >* configure.in.in: ...this and remove version determination.
>
> Oooh, yuck. -1. Please no configure.in.in baloney. -- justin

OK. I've appended my next attempt. Does anyone know how to remove
the extra newline from the version?

Matt

* build/get-version.sh: Remove.

* build/getversion.py: Add #! line and convert line endings.

* configure.in: Use getversion.py instead of get-version.sh.

Index: build/get-version.sh
===================================================================
--- build/get-version.sh (working copy)
+++ build/get-version.sh (working copy)
@@ -1,46 +0,0 @@
-#!/bin/sh
-#
-# USAGE: get-version.sh path/to/svn_version.h
-#
-# This script will print Subversion's version number on stdout. For example:
-#
-# $ ./build/get-version.sh ./subversion/include/svn_version.h
-# 0.15.0
-# $
-#
-
-if test $# = 0; then
- echo "ERROR: pathname for svn_version.h was not provided."
- echo ""
- echo "USAGE: $0 path/to/svn_version.h"
- exit 1
-fi
-if test $# != 1; then
- echo "ERROR: too many arguments were provided."
- echo ""
- echo "USAGE: $0 path/to/svn_version.h"
- exit 1
-fi
-
-hdr="$1"
-if test ! -r "$hdr"; then
- echo "ERROR: '$hdr' does not exist, or is not readable."
- exit 1
-fi
-
-MAJOR_VERSION="`sed -n -e '/SVN_VER_MAJOR/s/[^0-9]*//gp' $hdr`"
-MINOR_VERSION="`sed -n -e '/SVN_VER_MINOR/s/[^0-9]*//gp' $hdr`"
-MICRO_VERSION="`sed -n -e '/SVN_VER_MICRO/s/[^0-9]*//gp' $hdr`"
-
-# Determine how to tell echo not to print the trailing \n. This is
-# similar to Autoconf's @ECHO_C@ and @ECHO_N@; however, we don't
-# generate this file via autoconf (in fact, get-version.sh is used
-# to *create* ./configure), so we just do something similar inline.
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ;;
- *) ECHO_N= ECHO_C='\c' ;;
-esac
-
-echo $ECHO_N "$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$ECHO_C"
Index: build/getversion.py
===================================================================
--- build/getversion.py (revision 4087)
+++ build/getversion.py (working copy)
@@ -1,53 +1,53 @@
-#
-# getversion.py - Parse version numbers from C header files.
-#
-
-
-import re
-
-__all__ = ['Parser', 'Result']
-
-class Result:
- pass
-
-class Parser:
- def __init__(self):
- self.patterns = {}
-
- def search(self, define_name, value_name):
- 'Add the name of a define to the list of search pattenrs.'
- self.patterns[define_name] = value_name
-
- def parse(self, file):
- 'Parse the file, extracting defines into a Result object.'
- stream = open(file, 'rt')
- result = Result()
- regex = re.compile(r'^\s*#\s*define\s+(\w+)\s+(\d+)')
- for line in stream.readlines():
- match = regex.match(line)
- if match:
- try:
- name = self.patterns[match.group(1)]
- except:
- continue
- setattr(result, name, int(match.group(2)))
- stream.close()
- return result
-
-
-if __name__ == '__main__':
- # Example: Get the version number from svn_version.h
- p = Parser()
- p.search('SVN_VER_MAJOR', 'major')
- p.search('SVN_VER_MINOR', 'minor')
- p.search('SVN_VER_MICRO', 'patch')
- p.search('SVN_VER_LIBRARY', 'libver')
-
- import os, sys
- r = p.parse(os.path.join(os.path.dirname(sys.argv[0]),
- '../subversion/include/svn_version.h'))
- print "Subversion %d.%d.%d" % (r.major, r.minor, r.patch)
- print "Library version %d" % r.libver
-
-
-### End of file.
+#!/usr/bin/env python
+#
+# getversion.py - Parse version numbers from C header files.
+#
+
+import re
+
+__all__ = ['Parser', 'Result']
+
+class Result:
+ pass
+
+class Parser:
+ def __init__(self):
+ self.patterns = {}
+
+ def search(self, define_name, value_name):
+ 'Add the name of a define to the list of search pattenrs.'
+ self.patterns[define_name] = value_name
+
+ def parse(self, file):
+ 'Parse the file, extracting defines into a Result object.'
+ stream = open(file, 'rt')
+ result = Result()
+ regex = re.compile(r'^\s*#\s*define\s+(\w+)\s+(\d+)')
+ for line in stream.readlines():
+ match = regex.match(line)
+ if match:
+ try:
+ name = self.patterns[match.group(1)]
+ except:
+ continue
+ setattr(result, name, int(match.group(2)))
+ stream.close()
+ return result
+
+
+if __name__ == '__main__':
+ # Example: Get the version number from svn_version.h
+ p = Parser()
+ p.search('SVN_VER_MAJOR', 'major')
+ p.search('SVN_VER_MINOR', 'minor')
+ p.search('SVN_VER_MICRO', 'patch')
+ p.search('SVN_VER_LIBRARY', 'libver')
+
+ import os, sys
+ r = p.parse(os.path.join(os.path.dirname(sys.argv[0]),
+ '../subversion/include/svn_version.h'))
+ print "Subversion %d.%d.%d" % (r.major, r.minor, r.patch)
+ print "Library version %d" % r.libver
+
+
+### End of file.
Index: configure.in
===================================================================
--- configure.in (revision 4087)
+++ configure.in (working copy)
@@ -20,7 +20,7 @@
 dnl GNU M4 to test it right now.
 define([subversion_version],
        ifdef([__gnu__],
- [esyscmd(build/get-version.sh subversion/include/svn_version.h)],
+ [esyscmd(build/getversion.py | sed -n 's/Subversion //p')],
              [0.x]))
 AC_INIT(subversion, subversion_version, [http://subversion.tigris.org])
 undefine([subversion_version])

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Dec 11 22:09:47 2002

This is an archived mail posted to the Subversion Dev mailing list.