On Sat, 6 Oct 2007, Robinson Tryon wrote:
On 10/5/07, Ward Vandewege ward@gnu.org wrote:
On Sat, Oct 06, 2007 at 12:30:06AM +0200, Uwe Hermann wrote:
etc.) or at least ask some svn experts whether there is an easier and cleaner way to include a revision number?
Yeah, that would surely be great. Do you know any method or whom to ask? I browsed the svn code and manuals but didn't find anything better than $Rev$.
Can't we do this with a commit hook that would update the version number (which is in 1 place only) automatically to the SVN revision number?
I was going to suggest that the buildscript pull the current revision # out of SVN, but the idea of a commit hook sounds like it could be cleaner. Would the hook apply whenever any file is committed to the repository, or just to files in the superiotool directory?
NACK. svn commit hooks should not change the contents of the commit, at least not according to the svn book (client side caching problems might occur).
I've attached a patch that during build time extracts the svn revision from $Rev$ comments in each source file, and keeps the extracted value up to date using make.
Direct application of the patch might give one failure on superiotool.h (it has the expanded $Rev$ in your working directory), and compilation failure on superiotool.c, since the new $Rev$'s haven't yet been expanded (these two issues should not appear when receiving the patch through 'svn update'). For testing I expanded the $Rev$ by hand to the corresponding svn revisions, and then it worked like a charme:
$ make sed -ne 's/.*Rev: ([0-9]*) .*/\1/p' ali.c fintek.c ite.c nsc.c smsc.c superiotool.c winbond.c superiotool.h \ | sort -n \ | tail -1 \ | sed 's/.*/#define SUPERIOTOOL_VERSION "&"/' >version.h gcc -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing -Werror-implicit-function-declaration -ansi -c -o superiotool.o superiotool.c gcc -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing -Werror-implicit-function-declaration -ansi -c -o ali.o ali.c gcc -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing -Werror-implicit-function-declaration -ansi -c -o fintek.o fintek.c gcc -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing -Werror-implicit-function-declaration -ansi -c -o ite.o ite.c gcc -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing -Werror-implicit-function-declaration -ansi -c -o nsc.o nsc.c gcc -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing -Werror-implicit-function-declaration -ansi -c -o smsc.o smsc.c gcc -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing -Werror-implicit-function-declaration -ansi -c -o winbond.o winbond.c gcc -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing -Werror-implicit-function-declaration -ansi -o superiotool superiotool.o ali.o fintek.o ite.o nsc.o smsc.o winbond.o $ ./superiotool --version superiotool r2828
/ulf