r181563 - trunk/tools/depot_tools/support

0 views
Skip to first unread message

rc...@google.com

unread,
Feb 8, 2013, 5:29:53 PM2/8/13
to chromium...@chromium.org
Author: rc...@google.com
Date: Fri Feb 8 14:29:53 2013
New Revision: 181563

Log:
chromite_wrapper: Add support for gclient checkouts.

Chromite will be added to the Chrome checkout at third_party/chromite -
detect when the checkout is a gclient checkout, and look for chromite at
that path.

BUG=None
TEST=ran 'cbuildbot' in both a repo and gclient checkout.


Review URL: https://chromiumcodereview.appspot.com/12094111

Modified:
trunk/tools/depot_tools/support/chromite_wrapper

Modified: trunk/tools/depot_tools/support/chromite_wrapper
==============================================================================
--- trunk/tools/depot_tools/support/chromite_wrapper (original)
+++ trunk/tools/depot_tools/support/chromite_wrapper Fri Feb 8 14:29:53 2013
@@ -29,15 +29,21 @@
# 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 @@


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 @@
# 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'])
Reply all
Reply to author
Forward
0 new messages