1 # version and about message management
2 # NOTE: this module is meant to be used on all platforms, it is not SCons centric
6 # include/version.default
8 # include/version.h include/RADIANT_MAJOR include/RADIANT_MINOR
9 # the header is used by C/C++ code, the straight text file by setup
12 # for non-official builds, we have a default message
13 # otherwise, use environment variable $RADIANT_ABOUTMSG
15 # include/aboutmsg.default
16 # or file pointed to by $RADIANT_ABOUTMSG if exists
20 import sys, re, string, os
24 f = open('include/version.default', 'r')
26 line = string.split(buffer, '\n')[0]
28 sys.stdout.write("version: %s\n" % line)
29 exp = re.compile('^1\\.([^\\.]*)\\.([0-9]*)')
30 (major, minor) = exp.findall(line)[0]
31 sys.stdout.write("minor: %s major: %s\n" % (minor, major))
32 return (line, major, minor)
34 # you can pass an optional message to append to aboutmsg
35 def radiant_makeversion(append_about):
36 (line, major, minor) = get_version()
37 f = open('include/version.h', 'w')
38 f.write('// generated header, see makeversion.py\n')
39 f.write('#define RADIANT_VERSION "%s"\n' % line)
40 f.write('#define RADIANT_MINOR_VERSION "%s"\n' % minor)
41 f.write('#define RADIANT_MAJOR_VERSION "%s"\n' % major)
43 f = open('include/RADIANT_MINOR', 'w')
46 f = open('include/RADIANT_MAJOR', 'w')
49 f = open('include/version', 'w')
53 aboutfile = 'include/aboutmsg.default'
54 if ( os.environ.has_key('RADIANT_ABOUTMSG') ):
55 aboutfile = os.environ['RADIANT_ABOUTMSG']
56 sys.stdout.write("about message is in %s\n" % aboutfile)
57 f = open(aboutfile, 'r')
59 line = string.split(buffer, '\n')[0]
61 # optional additional message
62 if ( not append_about is None ):
64 sys.stdout.write("about: %s\n" % line)
65 f = open('include/aboutmsg.h', 'w')
66 f.write('// generated header, see makeversion.py\n')
67 f.write('#define RADIANT_ABOUTMSG "%s"\n' % line)
70 # can be used as module (scons build), or by direct call
71 if __name__ == '__main__':
72 radiant_makeversion(None)