Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Source Control/Version Control for AVR projects

2011-10-28 by David Kelly

On Oct 27, 2011, at 5:29 PM, Chuck Hackett wrote:

> Thanks to all for your suggestions.  
> 
> I have installed Subversion and Tortoise SVN and have begun reading the
> documentation and 'finding my way around'.
> 
> One of the things I'm currently looking for is how to embed the version
> number into C source files as a literal, string, etc.

I'd like to know how to do it cleanly in AVR Studio 4.x without an external Makefile. But here are the basics to get you started with TortoiseSVN:

Command line something like this:
SubWCRev . VersionTemplate.txt Version.c

VersionTemplate.txt looks something like this:

//
//  Template for SubWCRev, generates Version.c
//  $Id: VersionTemplate.txt 322 2011-02-18 19:08:48Z dkelly $
//

char *svn_Revision  = "$WCREV$";
char *svn_Modified  = "$WCMODS?Modified:Not modified$";
char *svn_Date      = "$WCDATE$";
char *svn_BuildDate = "$WCNOW$";
char *svn_Range     = "$WCRANGE$";
char *svn_Mixed     = "$WCMIXED?Mixed revision WC:Not mixed$";
char *svn_URL       = "$WCURL$";

//#if $WCMODS?1:0$
//#error Source is modified
//#endif

You might rather generate a .h file and do #define's rather than char*'s but you can see from above how to do that. And of course the above needs a Version.h for access:

//
//  $Id: Version.h 322 2011-02-18 19:08:48Z dkelly $
//

extern char *svn_Revision;
extern char *svn_Modified;
extern char *svn_Date;
extern char *svn_BuildDate;
extern char *svn_Range;
extern char *svn_Mixed;
extern char *svn_URL;


The $Id:$ strings in the above files are expanded if you have the svn:keywords property set to Id. The problem in using that version for an indicator in your code is that its only the version of that particular file. The above stuff with SubWCRev gets the particulars for the entire project. Be sure to consult the SubWCRev man page, its in the TortoiseSVN help system.

--
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.