scons: Fix the scons script failing to install git hooks
authorHoa Nguyen <hoanguyen@ucdavis.edu>
Tue, 22 Dec 2020 12:39:29 +0000 (04:39 -0800)
committerHoa Nguyen <hoanguyen@ucdavis.edu>
Wed, 23 Dec 2020 02:37:27 +0000 (02:37 +0000)
A recent change,
https://gem5-review.googlesource.com/c/public/gem5/+/38616,
removed the 'root' environment variable, while the git hooks
installation script relies on the variable. This commit
addresses this problem.

Change-Id: I2d27861794021a6a60ef8668461e4127cb1db261
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38655
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
site_scons/site_tools/git.py

index c5b2d5dac18c5f255bec8ad7cf85c7e5aaaa9899..87738b8f03ef428a5458937a91510df4cb948e3d 100644 (file)
@@ -85,7 +85,7 @@ def install_style_hooks(env):
 
         # Use a relative symlink if the hooks live in the source directory,
         # and the hooks directory is not a symlink to an absolute path.
-        if hook.is_under(env.root) and not abs_symlink_hooks:
+        if hook.is_under(env.Dir("#")) and not abs_symlink_hooks:
             script_path = os.path.relpath(
                 os.path.realpath(script.get_abspath()),
                 os.path.realpath(hook.Dir(".").get_abspath()))
@@ -108,8 +108,8 @@ def install_style_hooks(env):
         print("Input exception, exiting scons.\n")
         sys.exit(1)
 
-    git_style_script = env.root.Dir("util").File("git-pre-commit.py")
-    git_msg_script = env.root.Dir("ext").File("git-commit-msg")
+    git_style_script = env.Dir("#util").File("git-pre-commit.py")
+    git_msg_script = env.Dir("#ext").File("git-commit-msg")
 
     hook_install("pre-commit", git_style_script)
     hook_install("commit-msg", git_msg_script)