User forums > Using Code::Blocks

Help with pre-build steps

(1/1)

ironhead:
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
--- End code ---

which generates the following svnversion.h:


--- Code: ---#define SVN_VERSION 1837
#define SVN_VERSION_STR "1837"
--- End code ---

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}
--- End code ---

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


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

--- End code ---

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:


--- 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}
--- End code ---

Navigation

[0] Message Index

Go to full version