Computer Science Canada Build/Versioning |
Author: | md [ Sat Aug 20, 2005 4:43 pm ] | ||
Post subject: | Build/Versioning | ||
One thing that I like to keep track of for changelogs and such is the build count of a particular program, and the version of said build. I also use the version information to keep track of which version of the executable I'm currently running (it's sucks when you're trying to solve a bug and not using the new executable to test... makes fixing the bug difficult at best) Now... version isn't so hard, just create a header with the version and inlude it in the project. Build count is something more of a challenge. I use MSVC++.Net to do my programming so this is focused mainly on that, however with very little work I'm sure you could get this to work on any platform. first things first; auto incrementing a build count. Since there is no built in function to do this I wrote my own (sorry wtd... it's a cludge...) short program to increment the build count, and then build a header containing the version and build count.
I wrote this in er... 5 minutes, tops? So it's not hte cleanest but it works. Next: create two files in hte same directory as the exe; build_count.txt with contents of 0 (initial build count) and build_version.txt with whatever string of text you want as your version. Build hte above code and put the exe in the base directory... now here's the interesting part... I have all my code in a directory called Source off of the main directory (which contains my changelog, todo, makefile (or project), etc.). If you don't you may need to change the program above. Now... you should have two files (build_count.txt, build_version.txt) and an exe in your base directory, and a source directory where a file called Build_Version.h will be created when the exe runs. Right now all this does is create the new header when you run the exe not what we want, but close. Now all that's left is addign a custom build step that runs the exe; this I'll leave up to you to figure out as it's not so hard (and if you're actually trying this you probably know what your doing... mostly...) **** NOTES **** 1. I've had very little sleep in the last few days; so this might seem a bit random 2. I wrote this and the accompanying code in < 10 minutes, so I can't guaruntee anythign about either 3. I thought that since I wanted such a feature other's might too, so I thought I'd share how I did it... that's not to say that it's something you should do. |
Author: | Onega [ Mon May 08, 2006 4:10 am ] |
Post subject: | |
another option is using ANT (ant.apache.org/)build tools, create some task to update the version information. ANT tool is very handy for building large systems that consists of many projects. |
Author: | md [ Mon May 08, 2006 7:53 am ] |
Post subject: | |
Or you could just put something similar to this in your make file... Since this is such a small program it'd be much easier to use then learning how ANT works; especially for smaller projects. |