Automatic Build number incrementation
Automatic build number incrementation always was a hot topic especially under Linux. My solution is fairly simple to implement, so let’s see some “code” right away:
#!/bin/bash
echo Fetching and updating build number ...
cat Core/Build.cpp | \
awk '{ printf("unsigned int g_internalbuildNumber = %d ;\n" \
,$5+1); }' > Core/_Build.cpp
rm Core/Build.cpp
mv Core/_Build.cpp Core/Build.cpp
This is a nice little bash script, but you already knew that, what it does? Well it reads in the previous build number and writes it back after incrementing it with 1.
The initial “Build.cpp” must contain the line:
unsigned int g_internalbuildNumber = 0 ;
… please notice the spacing because it is very very important, since awk parses the tokens based on the spaces.
Now make this script to be executed as the first thing inside your makefile, and make sure that the “Build.cpp” is compiled and linked with your executable, shared object or whatever.
To access the build number from within the code, you just have to do an “extern unsigned int g_internalbuildNumber;” and there you go, nothing fancy but still cool
Maybe it’s not the most elegant solution, but hey … it works for me and that’s all what matters ![]()
About
Blog moved to Szabster.net …
Formal Introduction: 100% Computer Science Geek, made from 100% pure and recyclable electrons.
Current Occupation: Software Engineer and a lot more
I speak fluently the following languages: Hungarian, Romanian, English, French, C/C++/C#, Delphi, HTML, CSS, JavaScript, PHP, MySQL, Python, and a lot more.
I am known as: Icebreaker, coder_master or Lone Wolf (Wolverine).
I can be also found on IRC: DynastyNet (network) as coderguy.
Favorite Quote: I’m never wrong. I thought I was wrong once but I was mistaken. - Jeff Mayer
My Favorite Linux Distribution is: Ubuntu
Place where I would like to relax: On the beach …
… and with who? : With a million naked girls.
My Personal Geek Code:
—–BEGIN GEEK CODE BLOCK—–
Version: 3.1.2
GCS/TW/IT dpu s: a? C++(++++) UBL
P+ L+(++) E— W+++ N+ o+
K- w++>+++ !O M V- PS+(+++) PE++
Y PGP>+ t+@ 5? X+ R>+++ !tv
b++(+++) DI? D+>+++$ G e h! r– y++
——END GEEK CODE BLOCK——
-
Archives
- May 2008 (15)
- April 2008 (12)
- March 2008 (7)
- February 2008 (11)
- January 2008 (3)
- December 2007 (2)
- November 2007 (8)
- October 2007 (6)
- August 2007 (1)
- July 2007 (2)
- May 2007 (1)
- April 2007 (6)
-
Categories
- 4k 64k
- Blogging
- box2d
- Chick
- Coding
- demo
- directx
- documents
- Download
- easter
- egg
- flash
- framework
- Free
- Friends
- Game
- Game Engine
- Gamer
- Games
- Geek
- humor
- Internet
- intro
- Linux
- mac
- macosx
- music
- Nerd
- Open Source
- OpenGL
- Operating System
- physics
- Poetry
- Programming
- rc
- Real Life
- resources
- Scene
- sdl
- skype
- Social Networking
- software
- sp1
- texture
- Toughts on things
- Ubuntu
- Uncategorized
- Vista
- web
- winamp
- Windows
- word
-
RSS
Entries RSS
Comments RSS



