2006-02-10 22:01:20 +00:00
|
|
|
# Copyright (C) 1999-2006 Id Software, Inc. and contributors.
|
|
|
|
# For a list of contributors, see the accompanying CONTRIBUTORS file.
|
|
|
|
#
|
|
|
|
# This file is part of GtkRadiant.
|
|
|
|
#
|
|
|
|
# GtkRadiant is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# GtkRadiant is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with GtkRadiant; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
|
|
|
|
# version and about message management
|
|
|
|
# NOTE: this module is meant to be used on all platforms, it is not SCons centric
|
|
|
|
|
|
|
|
# version:
|
|
|
|
# input:
|
|
|
|
# include/version.default
|
|
|
|
# output:
|
|
|
|
# include/version.h include/RADIANT_MAJOR include/RADIANT_MINOR
|
|
|
|
# the header is used by C/C++ code, the straight text file by setup
|
|
|
|
|
|
|
|
# about message
|
|
|
|
# for non-official builds, we have a default message
|
|
|
|
# otherwise, use environment variable $RADIANT_ABOUTMSG
|
|
|
|
# input:
|
2006-02-12 19:47:01 +00:00
|
|
|
# file pointed to by $RADIANT_ABOUTMSG if exists
|
|
|
|
# else include/aboutmsg.default
|
2006-02-10 22:01:20 +00:00
|
|
|
# ouput:
|
|
|
|
# include/aboutmsg.h
|
|
|
|
|
|
|
|
import sys, re, string, os
|
|
|
|
|
2006-02-12 19:47:01 +00:00
|
|
|
import svn
|
|
|
|
|
2006-02-10 22:01:20 +00:00
|
|
|
def get_version():
|
|
|
|
# version
|
|
|
|
f = open('include/version.default', 'r')
|
|
|
|
buffer = f.read()
|
|
|
|
line = string.split(buffer, '\n')[0]
|
|
|
|
f.close()
|
|
|
|
sys.stdout.write("version: %s\n" % line)
|
|
|
|
exp = re.compile('^1\\.([^\\.]*)\\.([0-9]*)')
|
|
|
|
(major, minor) = exp.findall(line)[0]
|
|
|
|
sys.stdout.write("minor: %s major: %s\n" % (minor, major))
|
|
|
|
return (line, major, minor)
|
|
|
|
|
|
|
|
# you can pass an optional message to append to aboutmsg
|
2006-02-19 17:05:45 +00:00
|
|
|
def radiant_makeversion(append_about, root = os.getcwd()):
|
2006-02-10 22:01:20 +00:00
|
|
|
(line, major, minor) = get_version()
|
2006-02-19 17:05:45 +00:00
|
|
|
f = open(os.path.join(root, 'include/version.h'), 'w')
|
2006-02-10 22:01:20 +00:00
|
|
|
f.write('// generated header, see makeversion.py\n')
|
|
|
|
f.write('#define RADIANT_VERSION "%s"\n' % line)
|
|
|
|
f.write('#define RADIANT_MINOR_VERSION "%s"\n' % minor)
|
|
|
|
f.write('#define RADIANT_MAJOR_VERSION "%s"\n' % major)
|
|
|
|
f.close()
|
2006-02-19 17:05:45 +00:00
|
|
|
f = open(os.path.join(root, 'include/RADIANT_MINOR'), 'w')
|
2006-02-10 22:01:20 +00:00
|
|
|
f.write(minor)
|
|
|
|
f.close()
|
2006-02-19 17:05:45 +00:00
|
|
|
f = open(os.path.join(root, 'include/RADIANT_MAJOR'), 'w')
|
2006-02-10 22:01:20 +00:00
|
|
|
f.write(major)
|
|
|
|
f.close()
|
2006-02-19 17:05:45 +00:00
|
|
|
f = open(os.path.join(root, 'include/version'), 'w')
|
2006-02-10 22:01:20 +00:00
|
|
|
f.write(line)
|
|
|
|
f.close()
|
|
|
|
# aboutmsg
|
2006-02-19 17:05:45 +00:00
|
|
|
aboutfile = os.path.join(root, 'include/aboutmsg.default')
|
2006-02-10 22:01:20 +00:00
|
|
|
if ( os.environ.has_key('RADIANT_ABOUTMSG') ):
|
|
|
|
aboutfile = os.environ['RADIANT_ABOUTMSG']
|
2006-02-12 19:47:01 +00:00
|
|
|
line = None
|
|
|
|
if os.path.isfile(aboutfile):
|
|
|
|
sys.stdout.write("about message is in %s\n" % aboutfile)
|
|
|
|
f = open(aboutfile, 'r')
|
|
|
|
line = f.readline()
|
|
|
|
f.close()
|
2006-03-02 22:05:35 +00:00
|
|
|
if line.endswith("\n"):
|
|
|
|
line = line[:-1]
|
2006-02-12 19:47:01 +00:00
|
|
|
else:
|
2007-05-11 20:11:16 +00:00
|
|
|
line = "Custom build"
|
2006-02-10 22:01:20 +00:00
|
|
|
# optional additional message
|
|
|
|
if ( not append_about is None ):
|
|
|
|
line += append_about
|
|
|
|
sys.stdout.write("about: %s\n" % line)
|
2006-02-19 17:05:45 +00:00
|
|
|
f = open(os.path.join(root, 'include/aboutmsg.h'), 'w')
|
2006-02-10 22:01:20 +00:00
|
|
|
f.write('// generated header, see makeversion.py\n')
|
|
|
|
f.write('#define RADIANT_ABOUTMSG "%s"\n' % line)
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
# can be used as module (scons build), or by direct call
|
|
|
|
if __name__ == '__main__':
|
2006-02-19 17:05:45 +00:00
|
|
|
root = os.path.dirname(__file__)
|
|
|
|
if not os.path.isabs(root):
|
|
|
|
root = os.getcwd()
|
|
|
|
radiant_makeversion(None, root)
|