Author Topic: Help with pre-build steps  (Read 3783 times)

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Help with pre-build steps
« on: July 10, 2008, 02:05:27 pm »
I have the following in my makefile:

Code
..$/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:

Code
#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:

Code
$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

  • Guest
Re: Help with pre-build steps
« Reply #1 on: July 10, 2008, 04:42:42 pm »
Hi ironhead,

normally I use

Code
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

Offline ironhead

  • Almost regular
  • **
  • Posts: 210
Re: Help with pre-build steps
« Reply #2 on: July 11, 2008, 02:57:33 am »
I got it to work with the following pre-build step:

Code
$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}