More hacking about with the revision number stuff. Now build timestamp is derived with __DATE__ and __TIME__, and make-svn-rev-header.py checks if there's any need to update the .h file, which should result in less needless rebuilds/relinks.
Originally committed to SVN as r431.
This commit is contained in:
parent
c68c13c59a
commit
b1671d596c
2 changed files with 15 additions and 6 deletions
|
@ -11,19 +11,27 @@
|
||||||
|
|
||||||
from xml.dom.minidom import parse
|
from xml.dom.minidom import parse
|
||||||
from time import gmtime, strftime
|
from time import gmtime, strftime
|
||||||
|
from os.path import isfile
|
||||||
|
from sys import exit
|
||||||
|
|
||||||
entries_file = parse('../.svn/entries')
|
entries_file = parse('../.svn/entries')
|
||||||
|
|
||||||
def getRevision(entries):
|
def getRevision(entries):
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
if entry.getAttribute("name") == "":
|
if entry.getAttribute("name") == "":
|
||||||
return entry.getAttribute("revision")
|
return entry.getAttribute("revision")
|
||||||
|
|
||||||
revision = getRevision(entries_file.getElementsByTagName("entry"))
|
revision = getRevision(entries_file.getElementsByTagName("entry"))
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
outfile = file("svn-revision.h", "w+")
|
outfile = file("svn-revision.h", "w+")
|
||||||
outfile.write("// This file is automatically generated by make-svn-rev-header.py\n")
|
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("// Do not modify or add to revision control\n\n")
|
||||||
outfile.write("#define BUILD_SVN_REVISION " + revision + "\n")
|
outfile.write("#define BUILD_SVN_REVISION " + revision + "\n")
|
||||||
outfile.write("#define BUILD_TIMESTAMP \"" + strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()) + "\"\n")
|
|
||||||
outfile.close()
|
outfile.close()
|
||||||
|
|
|
@ -49,13 +49,14 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define BUILD_TIMESTAMP __DATE__ " " __TIME__
|
|
||||||
|
|
||||||
#ifndef BUILD_SVN_REVISION
|
#ifndef BUILD_SVN_REVISION
|
||||||
#define BUILD_SVN_REVISION 0
|
#define BUILD_SVN_REVISION 0
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BUILD_TIMESTAMP _T(__DATE__) _T(" ") _T(__TIME__)
|
||||||
|
|
||||||
// If the BUILD_SVN_REVISION happens to be negative, the build is assumed to be a public-release build (ie. not prerel)
|
// If the BUILD_SVN_REVISION happens to be negative, the build is assumed to be a public-release build (ie. not prerel)
|
||||||
// So manually edit build/svn-revision.h to match that, when doing such a build, or add some other magic to do that.
|
// So manually edit build/svn-revision.h to match that, when doing such a build, or add some other magic to do that.
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ struct VersionInfoStruct {
|
||||||
IsDebug = false;
|
IsDebug = false;
|
||||||
#endif
|
#endif
|
||||||
SvnRev = BUILD_SVN_REVISION;
|
SvnRev = BUILD_SVN_REVISION;
|
||||||
BuildTime = _T(BUILD_TIMESTAMP);
|
BuildTime = BUILD_TIMESTAMP;
|
||||||
BuildCredit = _T(BUILD_CREDIT);
|
BuildCredit = _T(BUILD_CREDIT);
|
||||||
|
|
||||||
if (SvnRev > 0)
|
if (SvnRev > 0)
|
||||||
|
|
Loading…
Reference in a new issue