summaryrefslogtreecommitdiff
path: root/src/python
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2008-06-13 01:09:04 -0400
committerAli Saidi <saidi@eecs.umich.edu>2008-06-13 01:09:04 -0400
commit907b28cc626e8b156d98187b0f91f5e8df0e9d56 (patch)
tree6713cd35ce3c7e49a620c0dd25982c27aec5d5d5 /src/python
parent2b4874449ce45504a1759c593a1f9b00983fca01 (diff)
downloadgem5-907b28cc626e8b156d98187b0f91f5e8df0e9d56.tar.xz
HG: Add compiled hg revision and date to the standard M5 output.
Diffstat (limited to 'src/python')
-rw-r--r--src/python/generate.py35
-rw-r--r--src/python/m5/main.py4
-rw-r--r--src/python/swig/core.i4
3 files changed, 41 insertions, 2 deletions
diff --git a/src/python/generate.py b/src/python/generate.py
index eead6ff5d..f4d923870 100644
--- a/src/python/generate.py
+++ b/src/python/generate.py
@@ -31,8 +31,7 @@ import py_compile
import sys
import zipfile
-from os.path import basename
-from os.path import exists
+from os.path import basename, exists, isdir, join
class DictImporter(object):
'''This importer takes a dictionary of arbitrary module names that
@@ -527,3 +526,35 @@ extern const Flags *compoundFlags[];
'''
f.close()
+
+ def programInfo(self, target, source, env):
+ def gen_file(target, rev, node, date):
+ pi_stats = file(target, 'w')
+ print >>pi_stats, 'const char *hgRev = "%s:%s";' % (rev, node)
+ print >>pi_stats, 'const char *hgDate = "%s";' % date
+ pi_stats.close()
+
+ target = str(target[0])
+ scons_dir = eval(str(source[0]))
+ try:
+ import mercurial.demandimport, mercurial.hg, mercurial.ui
+ import mercurial.util, mercurial.node
+ if not exists(scons_dir) or not isdir(scons_dir) or \
+ not exists(join(scons_dir, ".hg")):
+ raise ValueError
+ repo = mercurial.hg.repository(mercurial.ui.ui(), scons_dir)
+ rev = mercurial.node.nullrev + repo.changelog.count()
+ changenode = repo.changelog.node(rev)
+ changes = repo.changelog.read(changenode)
+ date = mercurial.util.datestr(changes[2])
+
+ gen_file(target, rev, mercurial.node.hex(changenode), date)
+
+ mercurial.demandimport.disable()
+ except ImportError:
+ gen_file(target, "Unknown", "Unknown", "Unknown")
+
+ except:
+ print "in except"
+ gen_file(target, "Unknown", "Unknown", "Unknown")
+ mercurial.demandimport.disable()
diff --git a/src/python/m5/main.py b/src/python/m5/main.py
index 4bcca46d2..cbdd65492 100644
--- a/src/python/m5/main.py
+++ b/src/python/m5/main.py
@@ -268,6 +268,10 @@ def main():
print "M5 compiled %s" % internal.core.cvar.compileDate;
print "M5 started %s" % datetime.datetime.now().ctime()
print "M5 executing on %s" % socket.gethostname()
+
+ print "M5 revision %s" % internal.core.cvar.hgRev
+ print "M5 commit date %s" % internal.core.cvar.hgDate
+
print "command line:",
for argv in sys.argv:
print argv,
diff --git a/src/python/swig/core.i b/src/python/swig/core.i
index 770765ca4..567eff591 100644
--- a/src/python/swig/core.i
+++ b/src/python/swig/core.i
@@ -39,6 +39,8 @@
#include "sim/startup.hh"
extern const char *compileDate;
+extern const char *hgRev;
+extern const char *hgDate;
%}
%include "stdint.i"
@@ -51,6 +53,8 @@ void SimStartup();
void doExitCleanup();
char *compileDate;
+char *hgRev;
+char *hgDate;
void setClockFrequency(Tick ticksPerSecond);