SConstruct (8297:d57afdcf38f5) SConstruct (8336:3a2aebf01bf3)
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 = """
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 M5 style hook.
203Please install the hook so we can ensure that all code fits a common style.
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: """
204
206
205All you'd need to do is add the following lines to your repository .hg/hgrc
206or your personal .hgrc
207----------------
208
207mercurial_style_hook = """
208# The following lines were automatically added by gem5/SConstruct
209# to provide the gem5 style-checking hooks
209[extensions]
210style = %s/util/style.py
211
212[hooks]
213pretxncommit.style = python:style.check_style
214pre-qrefresh.style = python:style.check_style
210[extensions]
211style = %s/util/style.py
212
213[hooks]
214pretxncommit.style = python:style.check_style
215pre-qrefresh.style = python:style.check_style
215""" % (main.root)
216# End of SConstruct additions
216
217
217mercurial_bin_not_found = """
218Mercurial binary cannot be found, unfortunately this means that we
219cannot easily determine the version of M5 that you are running and
220this makes error messages more difficult to collect. Please consider
221installing mercurial if you choose to post an error message
222"""
218""" % (main.root.abspath)
223
224mercurial_lib_not_found = """
219
220mercurial_lib_not_found = """
225Mercurial libraries cannot be found, ignoring style hook
226If you are actually a M5 developer, please fix this and
227run the style hook. It is important.
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.
228"""
229
224"""
225
230if hgdir.exists():
231 # Ensure that the style hook is in place.
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
232 try:
231 try:
233 ui = None
234 if not GetOption('ignore_style'):
235 from mercurial import ui
236 ui = ui.ui()
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
237 except ImportError:
238 print mercurial_lib_not_found
239
240 if ui is not None:
241 ui.readconfig(hgdir.File('hgrc').abspath)
242 style_hook = ui.config('hooks', 'pretxncommit.style', None)
243
244 if not style_hook:
245 print mercurial_style_message
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"
246 sys.exit(1)
247 sys.exit(1)
247else:
248 print ".hg directory not found"
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)
249
257
258
250###################################################
251#
252# Figure out which configurations to set up based on the path(s) of
253# the target(s).
254#
255###################################################
256
257# Find default configuration & binary.

--- 742 unchanged lines hidden ---
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 ---