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

Re: Adding current svn revision to source automatically

From: JeremyP <jeremyp_at_jeremyp.net>
Date: Fri, 19 Dec 2008 16:37:16 +0000

On 19 Dec 2008, at 14:19, Kenneth Goldman wrote:

> Thanks to all who got me clues. In return, I offer my 'solution'.
> However, it convinces me that the $GlobalRev$ that the manual admits
> doesn't exist should be implemented.
>

It would be nice to have, but there are technical reasons why it's
hard to do.
>
>
> 1 - The hacks using svnversion are just that - hacks. $GlobalRev$
> would be much cleaner.
>
I disagree that they are hacks.

>
>
> 2 - My solution is Unix only. Windows doesn't have svnversion,
>

Yes it does

>
> doesn't have sed, and might not even have make.
>

Cygwin

>
>
> My solution:
>
> 1 - Create a .h file with this:
>
>
> The FAQ implies that svnversion returns a number, but it could
> worst case return a value of the form nnnn:nnnnM. The first
> nnnn evidently refers to the version in other parts of the
> project. The M indicates that files aren't committed yet,
> common during development. sed filters these out.
>

The first nnnn refers to the lowest revision of any file in your
working copy. Why do you bother to filter it and the M out?

>
>
> 2 - Create the .c file in the makefile like this
>
> .c: $(everything)
> echo -n 'const unsigned short svn_revision = ' > .c
> echo -n $(SVNVERSION) >> .c
> echo ';' >> .c
>
> The .c file has to depend on everything else, so the
> everything variable has to be created manually and kept up to
> date. I didn't like the force option in the FAQ, because it
> forces a link even when nothing changes.
>
It's quite possible for the revision number of a working copy to
change without any of your source code files changing, for instance if
you build your project then commit it, unless your source code files
all have svn keywords in them, the next time you build, you'll get an
out of date revision number.

>
>
> 3 - Create the export target
>
> export:
> rm -rf /tmp/src
> svn export ../src /tmp/src
> cp .c /tmp/src
> touch /tmp/src/.c
>
>
>
> Since the .c file isn't committed, it has to copied
> separately. I touch it to force it to be compiled when
> testing the release before creating the tarball.
>

cp changes the modification time of the destination unless you
explicitly use the -p switch. The touch is unnecessary.

>
>
> 4 - Add the .o file to the make target.
>
> 5 - Add the .c file to the clean target
>
> --
> Ken Goldman kgold_at_watson.ibm.com
> 914-784-7646 (863-7646)

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=987586

To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2008-12-19 17:39:27 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.