SConstruct (11469:015cad6e65d5) | SConstruct (11476:8c67ac296e75) |
---|---|
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 --- 246 unchanged lines hidden (view full) --- 255# Mercurial Stuff. 256# 257# If the gem5 directory is a mercurial repository, we should do some 258# extra things. 259# 260######################################################################## 261 262hgdir = main.root.Dir(".hg") | 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 --- 246 unchanged lines hidden (view full) --- 255# Mercurial Stuff. 256# 257# If the gem5 directory is a mercurial repository, we should do some 258# extra things. 259# 260######################################################################## 261 262hgdir = main.root.Dir(".hg") |
263gitdir = main.root.Dir(".git") | |
264 265 266style_message = """ 267You're missing the gem5 style hook, which automatically checks your code 268against the gem5 style rules on %s. 269This script will now install the hook in your %s. 270Press enter to continue, or ctrl-c to abort: """ 271 --- 91 unchanged lines hidden (view full) --- 363 print "Adding style hook to", hgrc_path, "\n" 364 try: 365 with open(hgrc_path, 'a') as f: 366 f.write(mercurial_style_hook) 367 except: 368 print "Error updating", hgrc_path 369 sys.exit(1) 370 | 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 --- 91 unchanged lines hidden (view full) --- 362 print "Adding style hook to", hgrc_path, "\n" 363 try: 364 with open(hgrc_path, 'a') as f: 365 f.write(mercurial_style_hook) 366 except: 367 print "Error updating", hgrc_path 368 sys.exit(1) 369 |
371# Try to wire up git to the style hooks 372git_pre_commit_hook = gitdir.File("hooks/pre-commit") 373if not ignore_style and gitdir.exists() and not git_pre_commit_hook.exists(): | 370def install_git_style_hooks(): 371 try: 372 gitdir = Dir(readCommand( 373 ["git", "rev-parse", "--git-dir"]).strip("\n")) 374 except Exception, e: 375 print "Warning: Failed to find git repo directory: %s" % e 376 return 377 378 git_hooks = gitdir.Dir("hooks") 379 git_pre_commit_hook = git_hooks.File("pre-commit") |
374 git_style_script = File("util/git-pre-commit.py") 375 | 380 git_style_script = File("util/git-pre-commit.py") 381 |
382 if git_pre_commit_hook.exists(): 383 return 384 |
|
376 print git_style_message, 377 try: 378 raw_input() 379 except: 380 print "Input exception, exiting scons.\n" 381 sys.exit(1) 382 | 385 print git_style_message, 386 try: 387 raw_input() 388 except: 389 print "Input exception, exiting scons.\n" 390 sys.exit(1) 391 |
383 try: 384 rel_style_script = os.path.relpath( | 392 if not git_hooks.exists(): 393 mkdir(git_hooks.get_abspath()) 394 395 # Use a relative symlink if the hooks live in the source directory 396 if git_pre_commit_hook.is_under(main.root): 397 script_path = os.path.relpath( |
385 git_style_script.get_abspath(), 386 git_pre_commit_hook.Dir(".").get_abspath()) | 398 git_style_script.get_abspath(), 399 git_pre_commit_hook.Dir(".").get_abspath()) |
387 os.symlink(rel_style_script, git_pre_commit_hook.get_abspath()) | 400 else: 401 script_path = git_style_script.get_abspath() 402 403 try: 404 os.symlink(script_path, git_pre_commit_hook.get_abspath()) |
388 except: 389 print "Error updating git pre-commit hook" 390 raise | 405 except: 406 print "Error updating git pre-commit hook" 407 raise |
391 sys.exit(1) | |
392 | 408 |
409# Try to wire up git to the style hooks 410if not ignore_style and main.root.Entry(".git").exists(): 411 install_git_style_hooks() 412 |
|
393################################################### 394# 395# Figure out which configurations to set up based on the path(s) of 396# the target(s). 397# 398################################################### 399 400# Find default configuration & binary. --- 1130 unchanged lines hidden --- | 413################################################### 414# 415# Figure out which configurations to set up based on the path(s) of 416# the target(s). 417# 418################################################### 419 420# Find default configuration & binary. --- 1130 unchanged lines hidden --- |