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

Unified Diff: clang_format.py

Issue 135653014: Search for the source root rather than checkout root in clang_format.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Rebase. Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: clang_format.py
diff --git a/clang_format.py b/clang_format.py
index 9fb642545c57b74b2885240efbf2bf435005ef01..77c65cb573db00f52d8848a72238e1fc94a39ca3 100755
--- a/clang_format.py
+++ b/clang_format.py
@@ -23,19 +23,20 @@ class NotFoundError(Exception):
' %s' % e)
-def _FindChromiumTree():
- """Return the root of the current chromium checkout, or die trying."""
- source_root = gclient_utils.FindFileUpwards('.gclient')
+def _FindChromiumSourceRoot():
+ """Return the source root of the current chromium checkout, or die trying."""
+ # The use of .gn is somewhat incongruous here, but we need a file uniquely
+ # existing at src/. GN does the same thing at least.
+ source_root = gclient_utils.FindFileUpwards('.gn')
if not source_root:
raise NotFoundError(
- '.gclient file not found in any parent of the current path.')
+ '.gn file not found in any parent of the current path.')
return source_root
def FindClangFormatToolInChromiumTree():
"""Return a path to the clang-format executable, or die trying."""
- # The binaries in platform-specific subdirectories in src/tools/gn/bin.
- tool_path = os.path.join(_FindChromiumTree(), 'src', 'third_party',
+ tool_path = os.path.join(_FindChromiumSourceRoot(), 'third_party',
'clang_format', 'bin',
gclient_utils.GetMacWinOrLinux(),
'clang-format' + gclient_utils.GetExeSuffix())
@@ -62,11 +63,11 @@ def FindClangFormatToolInChromiumTree():
def FindClangFormatScriptInChromiumTree(script_name):
"""Return a path to a clang-format helper script, or die trying."""
- script_path = os.path.join(_FindChromiumTree(), 'src', 'third_party',
+ script_path = os.path.join(_FindChromiumSourceRoot(), 'third_party',
'clang_format', 'script', script_name)
if not os.path.exists(script_path):
# TODO(thakis): Remove the fallback to the old location after a few weeks.
- script_path = os.path.join(_FindChromiumTree(), 'src', 'third_party',
+ script_path = os.path.join(_FindChromiumSourceRoot(), 'third_party',
'clang_format', 'scripts', script_name)
if not os.path.exists(script_path):
raise NotFoundError('File does not exist: %s' % script_path)
« 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