1# -*- mode:python -*- 2 3# Copyright (c) 2013, 2015, 2016 ARM Limited 4# All rights reserved. 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating --- 254 unchanged lines hidden (view full) --- 263 264 265style_message = """ 266You're missing the gem5 style hook, which automatically checks your code 267against the gem5 style rules on %s. 268This script will now install the hook in your %s. 269Press enter to continue, or ctrl-c to abort: """ 270 |
271mercurial_style_message = """ 272You're missing the gem5 style hook, which automatically checks your code 273against the gem5 style rules on hg commit and qrefresh commands. 274This script will now install the hook in your .hg/hgrc file. 275Press enter to continue, or ctrl-c to abort: """ |
276 |
277git_style_message = """ 278You're missing the gem5 style or commit message hook. These hooks help 279to ensure that your code follows gem5's style rules on git commit. 280This script will now install the hook in your .git/hooks/ directory. 281Press enter to continue, or ctrl-c to abort: """ 282 |
283mercurial_style_upgrade_message = """ 284Your Mercurial style hooks are not up-to-date. This script will now 285try to automatically update them. A backup of your hgrc will be saved 286in .hg/hgrc.old. 287Press enter to continue, or ctrl-c to abort: """ 288 289mercurial_style_hook = """ 290# The following lines were automatically added by gem5/SConstruct --- 87 unchanged lines hidden (view full) --- 378 try: 379 gitdir = Dir(readCommand( 380 ["git", "rev-parse", "--git-dir"]).strip("\n")) 381 except Exception, e: 382 print "Warning: Failed to find git repo directory: %s" % e 383 return 384 385 git_hooks = gitdir.Dir("hooks") |
386 def hook_exists(hook_name): 387 hook = git_hooks.File(hook_name) 388 return hook.exists() |
389 |
390 def hook_install(hook_name, script): 391 hook = git_hooks.File(hook_name) 392 if hook.exists(): 393 print "Warning: Can't install %s, hook already exists." % hook_name 394 return 395 396 if not git_hooks.exists(): 397 mkdir(git_hooks.get_abspath()) 398 399 # Use a relative symlink if the hooks live in the source directory 400 if hook.is_under(main.root): 401 script_path = os.path.relpath( 402 script.get_abspath(), 403 hook.Dir(".").get_abspath()) 404 else: 405 script_path = script.get_abspath() 406 407 try: 408 os.symlink(script_path, hook.get_abspath()) 409 except: 410 print "Error updating git %s hook" % hook_name 411 raise 412 413 if hook_exists("pre-commit") and hook_exists("commit-msg"): |
414 return 415 416 print git_style_message, 417 try: 418 raw_input() 419 except: 420 print "Input exception, exiting scons.\n" 421 sys.exit(1) 422 |
423 git_style_script = File("util/git-pre-commit.py") 424 git_msg_script = File("ext/git-commit-msg") |
425 |
426 hook_install("pre-commit", git_style_script) 427 hook_install("commit-msg", git_msg_script) |
428 |
429# Try to wire up git to the style hooks 430if not ignore_style and main.root.Entry(".git").exists(): 431 install_git_style_hooks() 432 433################################################### 434# 435# Figure out which configurations to set up based on the path(s) of 436# the target(s). --- 1155 unchanged lines hidden --- |