]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - makeversion.py
creating trunk dir, step 1 of 2
[xonotic/netradiant.git] / makeversion.py
1 # Copyright (C) 1999-2006 Id Software, Inc. and contributors.
2 # For a list of contributors, see the accompanying CONTRIBUTORS file.
3
4 # This file is part of GtkRadiant.
5
6 # GtkRadiant is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # GtkRadiant is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with GtkRadiant; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
20
21 # version and about message management
22 # NOTE: this module is meant to be used on all platforms, it is not SCons centric
23
24 # version:
25 # input:
26 #   include/version.default
27 # output:
28 #   include/version.h include/RADIANT_MAJOR include/RADIANT_MINOR
29 #   the header is used by C/C++ code, the straight text file by setup
30
31 # about message
32 #   for non-official builds, we have a default message
33 #   otherwise, use environment variable $RADIANT_ABOUTMSG
34 # input:
35 #   include/aboutmsg.default
36 #   or file pointed to by $RADIANT_ABOUTMSG if exists
37 # ouput:
38 #   include/aboutmsg.h
39
40 import sys, re, string, os
41
42 def get_version():
43   # version
44   f = open('include/version.default', 'r')
45   buffer = f.read()
46   line = string.split(buffer, '\n')[0]
47   f.close()
48   sys.stdout.write("version: %s\n" % line)
49   exp = re.compile('^1\\.([^\\.]*)\\.([0-9]*)')
50   (major, minor) = exp.findall(line)[0]
51   sys.stdout.write("minor: %s major: %s\n" % (minor, major))
52   return (line, major, minor)  
53
54 # you can pass an optional message to append to aboutmsg
55 def radiant_makeversion(append_about):
56   (line, major, minor) = get_version()
57   f = open('include/version.h', 'w')
58   f.write('// generated header, see makeversion.py\n')
59   f.write('#define RADIANT_VERSION "%s"\n' % line)
60   f.write('#define RADIANT_MINOR_VERSION "%s"\n' % minor)
61   f.write('#define RADIANT_MAJOR_VERSION "%s"\n' % major)
62   f.close()
63   f = open('include/RADIANT_MINOR', 'w')
64   f.write(minor)
65   f.close()
66   f = open('include/RADIANT_MAJOR', 'w')
67   f.write(major)
68   f.close()
69   f = open('include/version', 'w')
70   f.write(line)
71   f.close()
72   # aboutmsg
73   aboutfile = 'include/aboutmsg.default'
74   if ( os.environ.has_key('RADIANT_ABOUTMSG') ):
75     aboutfile = os.environ['RADIANT_ABOUTMSG']
76   sys.stdout.write("about message is in %s\n" % aboutfile)
77   f = open(aboutfile, 'r')
78   buffer = f.read()
79   line = string.split(buffer, '\n')[0]
80   f.close()
81   # optional additional message
82   if ( not append_about is None ):
83     line += append_about
84   sys.stdout.write("about: %s\n" % line)
85   f = open('include/aboutmsg.h', 'w')
86   f.write('// generated header, see makeversion.py\n')
87   f.write('#define RADIANT_ABOUTMSG "%s"\n' % line)
88   f.close()
89
90 # can be used as module (scons build), or by direct call
91 if __name__ == '__main__':
92   radiant_makeversion(None)