2006-03-26 23:16:08 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# This file is used to automatically extract the SVN revision number and
|
|
|
|
# create a C include file.
|
|
|
|
|
|
|
|
# In MSVS, you can add the following Pre-Build Step to use this script:
|
|
|
|
# cd $(InputDir)core\build
|
|
|
|
# c:\Python24\python.exe make-svn-rev-header.py
|
|
|
|
|
|
|
|
# This is intended for use with a custom version.cpp,
|
|
|
|
# as described in version.cpp
|
|
|
|
|
|
|
|
from xml.dom.minidom import parse
|
2006-05-07 14:38:33 +02:00
|
|
|
from time import gmtime, strftime
|
2006-06-27 20:06:31 +02:00
|
|
|
from os.path import isfile
|
|
|
|
from sys import exit
|
2006-03-26 23:16:08 +02:00
|
|
|
|
|
|
|
entries_file = parse('../.svn/entries')
|
|
|
|
|
|
|
|
def getRevision(entries):
|
2006-06-27 20:06:31 +02:00
|
|
|
for entry in entries:
|
|
|
|
if entry.getAttribute("name") == "":
|
|
|
|
return entry.getAttribute("revision")
|
2006-03-26 23:16:08 +02:00
|
|
|
|
|
|
|
revision = getRevision(entries_file.getElementsByTagName("entry"))
|
|
|
|
|
2006-06-27 20:06:31 +02:00
|
|
|
if isfile("svn-revision.h"):
|
|
|
|
infile = file("svn-revision.h", "r")
|
|
|
|
for ln in infile:
|
|
|
|
if ln == "#define BUILD_SVN_REVISION " + revision + "\n":
|
|
|
|
infile.close()
|
|
|
|
exit()
|
|
|
|
|
2006-03-26 23:16:08 +02:00
|
|
|
outfile = file("svn-revision.h", "w+")
|
|
|
|
outfile.write("// This file is automatically generated by make-svn-rev-header.py\n")
|
|
|
|
outfile.write("// Do not modify or add to revision control\n\n")
|
|
|
|
outfile.write("#define BUILD_SVN_REVISION " + revision + "\n")
|
|
|
|
outfile.close()
|