Deleted Added
sdiff udiff text old ( 8297:d57afdcf38f5 ) new ( 8336:3a2aebf01bf3 )
full compact
1# -*- mode:python -*-
2
3# Copyright (c) 2011 Advanced Micro Devices, Inc.
4# Copyright (c) 2009 The Hewlett-Packard Development Company
5# Copyright (c) 2004-2005 The Regents of The University of Michigan
6# All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without

--- 185 unchanged lines hidden (view full) ---

194# If the M5 directory is a mercurial repository, we should do some
195# extra things.
196#
197########################################################################
198
199hgdir = main.root.Dir(".hg")
200
201mercurial_style_message = """
202You're missing the gem5 style hook, which automatically checks your code
203against the gem5 style rules on hg commit and qrefresh commands. This
204script will now install the hook in your .hg/hgrc file.
205Press enter to continue, or ctrl-c to abort: """
206
207mercurial_style_hook = """
208# The following lines were automatically added by gem5/SConstruct
209# to provide the gem5 style-checking hooks
210[extensions]
211style = %s/util/style.py
212
213[hooks]
214pretxncommit.style = python:style.check_style
215pre-qrefresh.style = python:style.check_style
216# End of SConstruct additions
217
218""" % (main.root.abspath)
219
220mercurial_lib_not_found = """
221Mercurial libraries cannot be found, ignoring style hook. If
222you are a gem5 developer, please fix this and run the style
223hook. It is important.
224"""
225
226# Check for style hook and prompt for installation if it's not there.
227# Skip this if --ignore-style was specified, there's no .hg dir to
228# install a hook in, or there's no interactive terminal to prompt.
229if not GetOption('ignore_style') and hgdir.exists() and sys.stdin.isatty():
230 style_hook = True
231 try:
232 from mercurial import ui
233 ui = ui.ui()
234 ui.readconfig(hgdir.File('hgrc').abspath)
235 style_hook = ui.config('hooks', 'pretxncommit.style', None) and \
236 ui.config('hooks', 'pre-qrefresh.style', None)
237 except ImportError:
238 print mercurial_lib_not_found
239
240 if not style_hook:
241 print mercurial_style_message,
242 # continue unless user does ctrl-c/ctrl-d etc.
243 try:
244 raw_input()
245 except:
246 print "Input exception, exiting scons.\n"
247 sys.exit(1)
248 hgrc_path = '%s/.hg/hgrc' % main.root.abspath
249 print "Adding style hook to", hgrc_path, "\n"
250 try:
251 hgrc = open(hgrc_path, 'a')
252 hgrc.write(mercurial_style_hook)
253 hgrc.close()
254 except:
255 print "Error updating", hgrc_path
256 sys.exit(1)
257
258
259###################################################
260#
261# Figure out which configurations to set up based on the path(s) of
262# the target(s).
263#
264###################################################
265
266# Find default configuration & binary.

--- 742 unchanged lines hidden ---