diff -r 69989a9e83ff -r 41feee1fac07 buildbot/Versioning --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/buildbot/Versioning Sat Apr 16 00:41:25 2011 -0700 @@ -0,0 +1,57 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os +import re +import subprocess +from ambuild.cache import Cache +import ambuild.command as command + +#Quickly try to ascertain the current repository revision +def GetVersion(): + args = ['hg', 'parent', '-R', AMBuild.sourceFolder] + p = command.RunDirectCommand(AMBuild, args) + m = re.match('changeset:\s+(\d+):(.+)', p.stdoutText) + if m == None: + raise Exception('Could not determine repository version') + return m.groups() + +def PerformReversioning(): + rev, cset = GetVersion() + cacheFile = os.path.join(AMBuild.outputFolder, '.ambuild', 'hgcache') + cache = Cache(cacheFile) + if os.path.isfile(cacheFile): + cache.LoadCache() + if cache.HasVariable('cset') and cache['cset'] == cset: + return False + cache.CacheVariable('cset', cset) + + productFile = open(os.path.join(AMBuild.sourceFolder, 'product.version'), 'r') + productContents = productFile.read() + productFile.close() + m = re.match('(\d+)\.(\d+)\.(\d+)(.*)', productContents) + if m == None: + raise Exception('Could not detremine product version') + major, minor, release, tag = m.groups() + + incFolder = os.path.join(AMBuild.outputFolder, 'includes') + if not os.path.isdir(incFolder): + os.makedirs(incFolder) + incFile = open(os.path.join(incFolder, 'cssdm_version_auto.h'), 'w') + incFile.write(""" +#ifndef _CSSDM_AUTO_VERSION_INFORMATION_H_ +#define _CSSDM_AUTO_VERSION_INFORMATION_H_ + +#define CSSDM_BUILD_STRING \"{0}\" +#define CSSDM_BUILD_UNIQUEID \"{1}:{2}\" CSSDM_BUILD_STRING +#define CSSDM_FULL_VERSION \"{3}.{4}.{5}\" CSSDM_BUILD_STRING +#define CSSDM_FILE_VERSION {6},{7},{8},0 + +#endif /* _CSSDM_AUTO_VERSION_INFORMATION_H_ */ + +""".format(tag, rev, cset, major, minor, release, major, minor, release)) + incFile.close() + + cache.WriteCache() + +PerformReversioning() + +