News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Help with pre-build steps

Started by ironhead, July 10, 2008, 02:05:27 PM

Previous topic - Next topic

ironhead

I have the following in my makefile:

..$/svnversion.h:
@echo #define SVN_VERSION $(shell svn info --revision HEAD | grep Revision | cut -f2 -d" ") > ..$/svnversion.h
@echo #define SVN_VERSION_STR "$(shell svn info --revision HEAD | grep Revision | cut -f2 -d" ")" >> ..$/svnversion.h


which generates the following svnversion.h:

#define SVN_VERSION 1837
#define SVN_VERSION_STR "1837"


My question is how can I create a pre-build step that results in the same file generation as that of my make file?

I have the first line of the file generating with:

$if($SVN_BUILD){cmd /c svn info --revision HEAD | grep Revision | sed -e "s/Revision:/#define SVN_VERSION/" > svnversion.h}

but I can't get sed to handle inserting the double quote.  I'm also hoping there is a cleaner way to do this with the built in C::B scripting support.

Thanx!

mariocup

Hi ironhead,

normally I use


sed -es/string/replace/ > name.h


without quotes. The quotes depend on the using shell/cmd. So you could try alternatively to use ' as quote.

Bye,

Mario

ironhead

I got it to work with the following pre-build step:

$if($SVN_BUILD){cmd /c svn info --revision HEAD | grep Revision | sed -e "s/Revision:/#define SVN_VERSION/" > svnversion.h}
$if($SVN_BUILD){cmd /c svn info --revision HEAD | grep Revision | sed -e "s/Revision: /#define SVN_VERSION_STR \"/" -e "s/$/\"/" >> svnversion.h}