Chromium Code Reviews| OLD | NEW |
|---|---|
| 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:])) |
| OLD | NEW |