Help - Search - Members - Calendar
Full Version: Find Revision In Subversion
OESF Portables Forum > Everything Else > Archived Forums > Distros, Development, and Model Specific Forums > Zaurus - Everything Development > Linux Applications
I've been working on some stuff, and have it in a local subversion repo. Since I've got a client and a server, I'd like to have my code check to ensure that both are using the same version. I thought that, for at least testing, using the revision number would be a good way to go (I could throw in some compile-time options to have an actual number if stuff ever gets to that point).

My problem is that I have yet to figure out a way to find the revision number. I've got a script that builds binaries, and thought it would be as easy as doing something like:

g++ -o mytestprogram src/*.cpp -DVERSION=`cat .svn/version` -lMYLIBS

(sorry about the likely poor syntax with the "-D..." part. I've never tried to actually define something as a string, just as existing or not, plus it's been a long day)

Anyway, I didn't see the revision anywhere in the .svn dirs. Could somebody help me out (once again, sorry if this is obvious, I'm tired)?

The result has to be processed a little since it tells the version in the repository and the local version (if they are not the same).

-- hns
Thanks! Now I've got another question:

How can I define something to have a value (instead of just being defined or not)? Something like:

g++ -o foo foo.cpp -DBAR="bar"

The above obviously doesn't work, though...

Thanks in advance.
I'd have thought a makefile macro would be the best way

1/ using make will make life easier for repeatable command sequence
2/ make allows you to do some clever macros which will allow derivation of versions
3/ profit!
I've been meaning to get autotools working with this project, but haven't found a good how-to, and I haven't looked into Makefiles. I guess I should.


EDIT: Well, the Makefile helps, but I still can't figure out how to do this defining stuff. All I want is a way to #define a version number...

EDIT2: It looks like most examples just echo the version to a file and then delete said file when doing a "make clean." There's got to be a better way.
There probably is a way to use bash to extract the original version number and then use the "expr" command to add one to it, but the code would be quite complex. Quickening has helped me do some stuff like this with modifying a string I wanted to use as a file name, but it would take a lot of trial and error to get it working.

It's a question for a bash coding expert (which I am not)! There may be a better way to do it, but I would save your file with a temporary file name, and then have a script that you call which gives it a spiffy new name that meets your specs.

Can you cope with that approach? I don't want to waste time playing around with the code if it isn't how you would consider handling it.

Also, if interested, please show me what the file name would look like before and after, I don't understand the C++ stuff at all.

I don't want to rename anything, just get a version number into the build. I'm guessing that most autotools apps create a "config.h" file that has all of the options in it, as it appears to be impossible to do

g++ -o foobar foo.cpp -DBAR="BAR"

Anyway, thanks for the help (I'm currently just echoing

#define VERSION x.y.z

to a file called version.hpp and then deleting it upon cleanup, FWIW.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.