Tech /

Version Strings





edit SideBar

Version Strings

Methods

Compiler define: Set a preprocessor define passed to the compiler.

Keyword substitution: Provide a header with keywords into which substitutions are made.

Template header: Provide a template with keywords which are processed and output to a generated header.

Tools

TortoiseSVN?: SubWCRev?

svn: svnversion

git: git-describe

Implementation

Compiler Define

Subversion

-D`svnversion`

Requires svn command line tools (not installed by default with TortoiseSVN?).

Git

-D`git describe`

Keyword substitution

  • An anti-pattern
  • Unsuitable for VCSs? with no global version id (SVN).

Template Header

Subversion

Create a template header file "version.in" of the form:

#ifndef VERSION_H
#define VERSION_H

#define VERSION_VCS_REV "$WCREV$"
#define VERSION_BUILD_TIME "$WCNOW$"
#define VERSION_VCS_PATH "$WCURL$"
#define VERSION_LOCAL_MODS $WCMODS?1:0$

#endif /*VERSION_H*/
 

and in the build script run

SubWCRev . version.in version.h

The generated output looks like

#ifndef VERSION_H
#define VERSION_H

#define VERSION_VCS_REV "120"
#define VERSION_BUILD_TIME "2013/02/21 17:44:46"
#define VERSION_VCS_PATH "http://path/to/repo/trunk"
#define VERSION_LOCAL_MODS 1

#endif /*VERSION_H*/
 

Git

No equivalent?

Problems

  • No way to pre-process the variables in the build script.
  • Windows platform only.

Generated Header

  • Dependency problems

Links

Recent Changes (All) | Edit SideBar Page last modified on 21 February 2013, at 06:15 PM UTC Edit Page | Page History
Powered by PmWiki