Figuring out how to put version info into the app automatically
The version information data is crucial for completing the <teiHeader> in a useful way, and I've been puzzling over how best to do it in an automated way. Following hints from this post: http://qtcreator.blogspot.com/2009/10/generating-automatic-version-numbers.html, I've written a bash script that creates a version.h header file, which provides all the key versioning info I'll want to include. Below is the script at the moment (it will probably get a bit more complicated later). I'll also want to figure out how to include the same info into a resource file in order to embed the correct versioning info into Windows builds, based on this post: http://stackoverflow.com/questions/2784697/setting-application-info-in-qt. I run the script automatically when doing a build, to get an up-to-date version.h file. This is done using a Custom Build Step in the Build Settings panel of QT (in "Projects").
#!/bin/bash
#Major version number (unlikely to change).
major=2
#Minor version number is changeable, but done manually.
minor=0
#Build number is yyyymmdd from today.
date=$(date +%Y%m%d)
#This is the file we're dealing with.
outfile="version.h"
#Remove the old file.
rm $outfile
#Do an SVN commit to update the revision number.
svn commit --message "Committing before an application build."
#Get the SVN revision number into a variable.
svnrev=`svnversion`
#echo the info into the output file.
#echo $svnrev>>$outfile
#echo $major"."$minor"."$build"."$svnrev>>$outfile
echo "#ifndef VERSION_H">>$outfile
echo "#define VERSION_H">>$outfile
echo "">>$outfile
echo "namespace Version">>$outfile
echo "{">>$outfile
echo "const int MAJOR = "$major";">>$outfile
echo "const int MINOR = "$minor";">>$outfile
echo "const int DATE = "$date";">>$outfile
echo "const int REVISION = "$svnrev";">>$outfile
echo "}">>$outfile
echo "inline const char* versionString(){return "$'\042'$major"."$minor"."$date"."$svnrev$'\042'"};">>$outfile
echo "">>$outfile
echo "">>$outfile
echo "">>$outfile
echo "#endif // VERSION_H">>$outfile