[Vm-dev] About sqSCCVersion.h

Igor Stasenko siguctua at gmail.com
Thu Jul 21 16:13:03 UTC 2011


Hello,

i was looking how to make same trick for git, to embed the revision
information into the source and found no easy solution.

Using gitattributes is powerful, but too tedious for me to set it up
fast and too much info for doing simple things. (You may look
http://progit.org/book/ch7-2.html)

So, to make it fast, i will use shell script to generate output.

Unfortunately, it makes little sense to use #define GIT 1 (in sqSCCVersion.h)
because its easier to just include generated file:

#include "vmVersionInfo.h"  // defines REVISION_STRING


static char *sourceVersionString()
{
	return REVISION_STRING;
}

Where vmVersionInfo.h contents is generated dynamically by shell script.

To extract an URL a following command does it well:

git config --get remote.origin.url

Which shows:
git at gitorious.org:cogvm/blessed.git

To extract commit info, i using:

git show HEAD --pretty="Commit: %H Date: %cd By: %cn <%cE>"

Which shows:
b0df6dc6902a9eb05de02782a77712d855d0422e Date: Wed Jul 20 16:22:16
2011 +0200 By: Igor Stasenko <siguctua at gmail.com>

So, i will create a script which will generate a header file with
these two lines concatenated, and then just include it into modified
sqSCCVersion.h

The problem is that i cannot put invocation of this script it into
cmake config files, because then it will work only if you check out
source from git , but not for tarballs.
So, to generate the version info file this command will run separately
on server.

The output of sourceVersionString() function will be something like that:

git at gitorious.org:cogvm/blessed.git Commit:
b0df6dc6902a9eb05de02782a77712d855d0422e Date: Wed Jul 20 16:22:16
2011 +0200 By: Igor Stasenko <siguctua at gmail.com>

If you have better suggestions how this string should look like
(format, fields) i am here to listen. :)

-- 
Best regards,
Igor Stasenko AKA sig.


More information about the Vm-dev mailing list