Change clang_format.py to search for clang-format in buildtools
BUG=none
R=brettw@chromium.org,nick@chromium.org
Review URL: https://codereview.chromium.org/356733002
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@280971 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_utils.py b/gclient_utils.py
index 655e5aa..9837cbb 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -655,6 +655,19 @@
This is based on the root of the checkout containing the current directory."""
gclient_root = FindGclientRoot(os.getcwd())
if not gclient_root:
+ # Some projects might not use .gclient. Try to see whether we're in a git
+ # checkout.
+ top_dir = [os.getcwd()]
+ def filter_fn(line):
+ top_dir[0] = os.path.normpath(line.rstrip('\n'))
+ try:
+ CheckCallAndFilter(["git", "rev-parse", "--show-toplevel"],
+ print_stdout=False, filter_fn=filter_fn)
+ except Exception:
+ pass
+ top_dir = top_dir[0]
+ if os.path.exists(os.path.join(top_dir, 'buildtools')):
+ return os.path.join(top_dir, 'buildtools')
return None
return os.path.join(gclient_root, 'src', 'buildtools')