buildbot/Versioning
author Ruben Gonzalez <drifter01620@gmail.com>
Wed Nov 12 08:29:24 2014 -0500 (2014-11-12)
changeset 197 fd967f09ab68
parent 59 41feee1fac07
permissions -rw-r--r--
Update CSGO Gamedata
     1 # vim: set ts=2 sw=2 tw=99 noet ft=python: 
     2 import os
     3 import re
     4 import subprocess
     5 from ambuild.cache import Cache
     6 import ambuild.command as command
     7 
     8 #Quickly try to ascertain the current repository revision
     9 def GetVersion():
    10 	args = ['hg', 'parent', '-R', AMBuild.sourceFolder]
    11 	p = command.RunDirectCommand(AMBuild, args)
    12 	m = re.match('changeset:\s+(\d+):(.+)', p.stdoutText)
    13 	if m == None:
    14 		raise Exception('Could not determine repository version')
    15 	return m.groups()
    16 
    17 def PerformReversioning():
    18 	rev, cset = GetVersion()
    19 	cacheFile = os.path.join(AMBuild.outputFolder, '.ambuild', 'hgcache')
    20 	cache = Cache(cacheFile)
    21 	if os.path.isfile(cacheFile):
    22 		cache.LoadCache()
    23 		if cache.HasVariable('cset') and cache['cset'] == cset:
    24 			return False
    25 	cache.CacheVariable('cset', cset)
    26 
    27 	productFile = open(os.path.join(AMBuild.sourceFolder, 'product.version'), 'r')
    28 	productContents = productFile.read()
    29 	productFile.close()
    30 	m = re.match('(\d+)\.(\d+)\.(\d+)(.*)', productContents)
    31 	if m == None:
    32 		raise Exception('Could not detremine product version')
    33 	major, minor, release, tag = m.groups()
    34 
    35 	incFolder = os.path.join(AMBuild.outputFolder, 'includes')
    36 	if not os.path.isdir(incFolder):
    37 		os.makedirs(incFolder)
    38 	incFile = open(os.path.join(incFolder, 'cssdm_version_auto.h'), 'w')
    39 	incFile.write("""
    40 #ifndef _CSSDM_AUTO_VERSION_INFORMATION_H_
    41 #define _CSSDM_AUTO_VERSION_INFORMATION_H_
    42 
    43 #define CSSDM_BUILD_STRING 		\"{0}\"
    44 #define CSSDM_BUILD_UNIQUEID		\"{1}:{2}\" CSSDM_BUILD_STRING
    45 #define CSSDM_FULL_VERSION		\"{3}.{4}.{5}\" CSSDM_BUILD_STRING
    46 #define CSSDM_FILE_VERSION		{6},{7},{8},0
    47 
    48 #endif /* _CSSDM_AUTO_VERSION_INFORMATION_H_ */
    49 
    50 """.format(tag, rev, cset, major, minor, release, major, minor, release))
    51 	incFile.close()
    52 
    53 	cache.WriteCache()
    54 
    55 PerformReversioning()
    56 
    57