X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=makeversion.py;h=3dab61c67f0282034a2cd8a99a6def8978985137;hp=296b456a4c50c260db1bf4a310e098ee8ef1cbd3;hb=8048d7086658ef4eedb99a740181d9563db5987c;hpb=12b372f89ce109a4db9d510884fbe7d05af79870 diff --git a/makeversion.py b/makeversion.py index 296b456a..3dab61c6 100644 --- a/makeversion.py +++ b/makeversion.py @@ -32,13 +32,15 @@ # for non-official builds, we have a default message # otherwise, use environment variable $RADIANT_ABOUTMSG # input: -# include/aboutmsg.default -# or file pointed to by $RADIANT_ABOUTMSG if exists +# file pointed to by $RADIANT_ABOUTMSG if exists +# else include/aboutmsg.default # ouput: # include/aboutmsg.h import sys, re, string, os +import svn + def get_version(): # version f = open('include/version.default', 'r') @@ -52,41 +54,49 @@ def get_version(): return (line, major, minor) # you can pass an optional message to append to aboutmsg -def radiant_makeversion(append_about): +def radiant_makeversion(append_about, root = os.getcwd()): (line, major, minor) = get_version() - f = open('include/version.h', 'w') + f = open(os.path.join(root, 'include/version.h'), 'w') 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() - f = open('include/RADIANT_MINOR', 'w') + f = open(os.path.join(root, 'include/RADIANT_MINOR'), 'w') f.write(minor) f.close() - f = open('include/RADIANT_MAJOR', 'w') + f = open(os.path.join(root, 'include/RADIANT_MAJOR'), 'w') f.write(major) f.close() - f = open('include/version', 'w') + f = open(os.path.join(root, 'include/version'), 'w') f.write(line) f.close() # aboutmsg - aboutfile = 'include/aboutmsg.default' + aboutfile = os.path.join(root, 'include/aboutmsg.default') if ( os.environ.has_key('RADIANT_ABOUTMSG') ): aboutfile = os.environ['RADIANT_ABOUTMSG'] - sys.stdout.write("about message is in %s\n" % aboutfile) - f = open(aboutfile, 'r') - buffer = f.read() - line = string.split(buffer, '\n')[0] - f.close() + 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() + if line.endswith("\n"): + line = line[:-1] + else: + line = "Custom build based on revision " + str(svn.getRevision(os.getcwd())) # optional additional message if ( not append_about is None ): line += append_about sys.stdout.write("about: %s\n" % line) - f = open('include/aboutmsg.h', 'w') + f = open(os.path.join(root, 'include/aboutmsg.h'), 'w') 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__': - radiant_makeversion(None) + root = os.path.dirname(__file__) + if not os.path.isabs(root): + root = os.getcwd() + radiant_makeversion(None, root)