Author Topic: How to make C::B to regenerate compiler command  (Read 3903 times)

Offline jackhab

  • Multiple posting newcomer
  • *
  • Posts: 16
How to make C::B to regenerate compiler command
« on: October 05, 2009, 03:57:33 pm »
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

  • Guest
Re: How to make C::B to regenerate compiler command
« Reply #1 on: October 05, 2009, 05:57:38 pm »
Hi jackhab,

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

Code
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


Offline jackhab

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: How to make C::B to regenerate compiler command
« Reply #2 on: October 05, 2009, 06:25:46 pm »
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: How to make C::B to regenerate compiler command
« Reply #3 on: October 05, 2009, 08:06:21 pm »
You need something like this:

Code
/*
 * 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

  • Guest
Re: How to make C::B to regenerate compiler command
« Reply #4 on: October 05, 2009, 08:42:50 pm »
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.