OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Find Revision In Subversion
Capn_Fish
post Dec 26 2008, 08:45 PM
Post #1





Group: Members
Posts: 2,350
Joined: 30-July 06
Member No.: 10,575



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:

CODE
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)?

Thanks.
Go to the top of the page
 
+Quote Post
dhns
post Dec 27 2008, 12:43 AM
Post #2





Group: Members
Posts: 699
Joined: 26-February 04
From: near Munich, Germany
Member No.: 2,043



CODE
/usr/bin/svnversion

http://svnbook.red-bean.com/en/1.1/re57.html
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
Go to the top of the page
 
+Quote Post
Capn_Fish
post Dec 28 2008, 11:30 AM
Post #3





Group: Members
Posts: 2,350
Joined: 30-July 06
Member No.: 10,575



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:

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


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

Thanks in advance.
Go to the top of the page
 
+Quote Post
speculatrix
post Dec 28 2008, 03:00 PM
Post #4





Group: Admin
Posts: 3,281
Joined: 29-July 04
From: Cambridge, England
Member No.: 4,149



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!
Go to the top of the page
 
+Quote Post
Capn_Fish
post Dec 28 2008, 07:22 PM
Post #5





Group: Members
Posts: 2,350
Joined: 30-July 06
Member No.: 10,575



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.

Thanks!

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.
Go to the top of the page
 
+Quote Post
sdjf
post Dec 29 2008, 09:51 PM
Post #6





Group: Members
Posts: 454
Joined: 17-November 05
Member No.: 8,551



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.

sdjf
Go to the top of the page
 
+Quote Post
Capn_Fish
post Dec 30 2008, 04:56 PM
Post #7





Group: Members
Posts: 2,350
Joined: 30-July 06
Member No.: 10,575



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

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


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

CODE
#define VERSION x.y.z


to a file called version.hpp and then deleting it upon cleanup, FWIW.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 26th July 2014 - 01:12 AM