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

Unified Diff: support/chromite_wrapper

Issue 12094111: chromite_wrapper: Add support for gclient checkouts. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 7 years, 10 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: support/chromite_wrapper
diff --git a/support/chromite_wrapper b/support/chromite_wrapper
index f459b2c6457081af33e96dd57bc3a586bf919b6d..dd2e1d133ddc7937be9c7f363b26439cf33391b2 100755
--- a/support/chromite_wrapper
+++ b/support/chromite_wrapper
@@ -29,15 +29,21 @@ import sys
# fallback code- any/all new scripts symlinked to this script *must* exist
# in chromite/bin/ .
-def _FindRoot(path):
- """Find the root of a repo checkout"""
+def _FindChromite(path):
+ """Find the chromite dir in a repo or gclient checkout."""
path = os.path.abspath(path)
+ # Depending on the checkout type (whether repo chromeos or gclient chrome)
+ # Chromite lives in a different location.
+ roots = (
+ ('.repo', 'chromite/.git'),
+ ('.gclient', 'src/third_party/chromite/.git'),
+ )
+
while path != '/':
- # Look for the chromite repository itself- it's always been at the root
- # of a repo checkout.
- if all(os.path.exists(os.path.join(path, x))
- for x in ['.repo', 'chromite/.git']):
- return path
+ for root, chromite_git_dir in roots:
+ if all(os.path.exists(os.path.join(path, x))
+ for x in [root, chromite_git_dir]):
+ return os.path.dirname(os.path.join(path, chromite_git_dir))
path = os.path.dirname(path)
return None
@@ -54,12 +60,12 @@ and retry. If you need to setup a Chromium OS source tree, see
def main():
- root = _FindRoot(os.getcwd())
+ chromite_dir = _FindChromite(os.getcwd())
target = os.path.basename(sys.argv[0])
- if root is None:
+ if chromite_dir is None:
return _MissingErrorOut(target)
-
- path = os.path.join(root, 'chromite/bin', target)
+
+ path = os.path.join(chromite_dir, 'bin', target)
try:
os.execv(path, [path] + sys.argv[1:])
except EnvironmentError, e:
@@ -70,14 +76,14 @@ def main():
# an old (pre 6be2efcf5bb575b03862113eec097c44d8d7f93e) revision of
# chromite. Fallback to trying to import it; this code works at least as
# far back as branch 0.11.241.B; likely further.
-
+
if target == 'cbuildbot':
target = 'chromite.buildbot.cbuildbot'
else:
target = 'chromite.bin.%s' % (target,)
# Adjust the path importation so we can import our our target.
- sys.path.insert(0, root)
+ sys.path.insert(0, os.path.dirname(chromite_dir))
try:
module = __import__(target, fromlist=['main'])
« 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