Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(551)

Side by Side Diff: tools/run_hooks.py

Issue 1760353002: Make tools/run_hooks.py work when depot_tools is not in PATH (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # This script runs all of the hooks specified in DEPS in order. 6 # This script runs all of the hooks specified in DEPS in order.
7 7
8 import os 8 import os
9 import subprocess 9 import subprocess
10 import sys 10 import sys
11 11
12 scope = {} 12 scope = {}
13 13
14 def Var(key): 14 def Var(key):
15 return scope["vars"][key] 15 return scope["vars"][key]
16 16
17 scope["Var"] = Var 17 scope["Var"] = Var
18 18
19 def main(args): 19 def main(args):
20 gclient_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 20 gclient_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
21 os.pardir, os.pardir)) 21 os.pardir, os.pardir))
22 deps_path = os.path.join(gclient_path, "src", "DEPS") 22 deps_path = os.path.join(gclient_path, "src", "DEPS")
23 with open(deps_path) as deps_contents: 23 with open(deps_path) as deps_contents:
24 d = deps_contents.read() 24 d = deps_contents.read()
25 exec(d, scope) 25 exec(d, scope)
26 env = os.environ
27 # Some hooks expect depot_tools to be in the PATH already. If there is no
28 # depot_tools in the current environment's PATH add the default location of
29 # depot_tools in a standard checkout to the environment the hooks run in.
30 if env["PATH"].find("depot_tools") == -1:
lanechr 2016/03/04 17:35:41 why not just add the default_depot_tools_path to t
31 default_depot_tools_path = os.path.join(gclient_path, "depot_tools")
32 env["PATH"] = env["PATH"] + ":" + default_depot_tools_path
26 for hook in scope["hooks"]: 33 for hook in scope["hooks"]:
27 name = hook["name"] 34 name = hook["name"]
28 print "________ running '%s' in '%s'" % (" ".join(hook["action"]), 35 print "________ running '%s' in '%s'" % (" ".join(hook["action"]),
29 gclient_path) 36 gclient_path)
30 subprocess.check_call(hook["action"], cwd=gclient_path) 37 subprocess.check_call(hook["action"], cwd=gclient_path, env=env)
31 print 38 print
32 return 0 39 return 0
33 40
34 if __name__ == '__main__': 41 if __name__ == '__main__':
35 sys.exit(main(sys.argv[1:])) 42 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698