summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2007-07-21 22:33:08 -0700
committerNathan Binkert <nate@binkert.org>2007-07-21 22:33:08 -0700
commit4b5ba96d380cd70c103e4deee85a95633fada7da (patch)
treef6d81ecf79cf7e4426ae3b1856a8ea8145c824cf /SConstruct
parent92bb9242fb14db7ce3f78572ea428c8b3c06798a (diff)
downloadgem5-4b5ba96d380cd70c103e4deee85a95633fada7da.tar.xz
Add code to turn the style stuff into a mercurial hook.
Nag the user during compile if they have an hg cloned copy of M5, have mercurial installed, but don't have the style hook enabled. --HG-- extra : convert_revision : 6bcbb67f1a3fcd36db7d3ef16a9ff19680f126f2
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct30
1 files changed, 29 insertions, 1 deletions
diff --git a/SConstruct b/SConstruct
index fa2366963..1c2dcab1c 100644
--- a/SConstruct
+++ b/SConstruct
@@ -67,7 +67,7 @@ import sys
import os
import subprocess
-from os.path import join as joinpath
+from os.path import isdir, join as joinpath
# Check for recent-enough Python and SCons versions. If your system's
# default installation of Python is not recent enough, you can use a
@@ -97,6 +97,34 @@ SRCDIR = joinpath(ROOT, 'src')
# tell python where to find m5 python code
sys.path.append(joinpath(ROOT, 'src/python'))
+def check_style_hook(ui):
+ ui.readconfig(joinpath(ROOT, '.hg', 'hgrc'))
+ style_hook = ui.config('hooks', 'pretxncommit.style', None)
+
+ if not style_hook:
+ print """\
+You're missing the M5 style hook.
+Please install the hook so we can ensure that all code fits a common style.
+
+All you'd need to do is add the following lines to your repository .hg/hgrc
+or your personal .hgrc
+----------------
+
+[extensions]
+style = %s/util/style.py
+
+[hooks]
+pretxncommit.style = python:style.check_whitespace
+""" % (ROOT)
+ sys.exit(1)
+
+if isdir(joinpath(ROOT, '.hg')):
+ try:
+ from mercurial import ui
+ check_style_hook(ui.ui())
+ except ImportError:
+ pass
+
###################################################
#
# Figure out which configurations to set up based on the path(s) of