News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

How to make C::B to regenerate compiler command

Started by jackhab, October 05, 2009, 03:57:33 PM

Previous topic - Next topic

jackhab

I needed to define a constant to give me the SVN version of a project. I added the following line to Compiler settings > Other Options:
\'-DSVN_VER=\"`svnversion`\"\'

The problem is once CB generates compiler command with all the switches and the expansion of svnversion command it reuses the same command string for the following compilations and SVN_REV never redefined (clean, rebuild don't help) until I close and open CB again.

I want
\'-DSVN_VER=\"`svnversion`\"\'
to be shell-expanded every time I build. Is it possible?

Thanks.

mariocup

Hi jackhab,

I do not know if I understand exactly your problem. Your could define a pre build step to get the SVN revision


svn --xml info <your file name>


The resulting output could be parsed by simple grep and sed script and then this information could be redirected in to a header file, which sets the Define SVN_VER


jackhab

Initially I used svnversion and sed combination to insert SVN version into a header but I found this approach not convenient because:

Step 1: I checkout revision 100 from repository
Step 2: I build. At this stage the header is modified so its revision goes up and project source is modified only because I preformed a build.

So I decided to dynamically generate revision constant using gcc's -D switch.

But now after I explained it I see the source of the problem. I should have created a *new* header file only containing the revision define and not keep this file under version control.

Thanks.

oBFusCATed

You need something like this:


/*
* This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
* http://www.gnu.org/licenses/lgpl-3.0.html
*
* $Revision: 4909 $
* $Id: annoyingdialog.cpp 4909 2008-02-27 13:15:26Z mortenmacfly $
* $HeadURL: svn://svn.berlios.de/codeblocks/branches/wxpropgrid_debugger/src/sdk/annoyingdialog.cpp $
*/


?

Read the svn book I think it is called annotations or something like that.... never used them and never will
Why someone would use them?
It make diff-ing a svn tree and a separate non-svn tree (a tree in git-svn for example) impossible.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

mariocup

Hi oBFusCATed,

the SVN keywords like $Revision: 4909 $ are only updated if checkout and differ from the current revision of the repository, this means if you modify other files in the repository you do not have the recent SVN revision within the keywords. But the SVN command line tools will give you the revision of the working copy.