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

Side by Side Diff: tools/grab_deps.py

Issue 191133005: git-sync-deps tool (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: AnotherPatchSet Created 6 years, 8 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 unified diff | Download patch
« no previous file with comments | « docs/quickstart.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright 2014 Google Inc.
3 #
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
mtklein 2014/04/11 15:58:47 Add a brief usage? # Run to grab Skia deps, with
hal.canary 2014/04/11 17:46:51 Done.
7
8 import git_utils
9 import misc_utils
10 import os
11 import subprocess
12 import sys
13
14
15 SKIA_CHECKOUT_PATH = os.path.join(os.path.dirname(__file__), os.pardir)
16
17
18 def rm_directory_if_exists(directory):
19 if os.path.isdir(directory) and not os.path.islink(directory):
20 shutil.rmtree(directory)
21 elif os.path.lexists(directory):
22 os.remove(directory)
23
24
25 def git_checkout_to_directory(repo, checkout, directory, verbose=False):
26 """TODO(halcanary): document this function.
epoger 2014/04/11 16:16:11 Please document it before committing, unless this
hal.canary 2014/04/11 17:46:51 Done.
27 """
28 git = git_utils.git_executable()
29 assert git
30 try:
31 with misc_utils.ChangeDir(directory):
32 if verbose:
33 print '%s\n>>>> %s\n>>>> %s\n' % (directory, repo, checkout)
34 subprocess.check_call([git, 'fetch'])
35 subprocess.check_call([git, 'checkout', '--quiet', checkout])
36 except:
37 rm_directory_if_exists(directory)
38 subprocess.check_call([git, 'clone', repo, directory])
39 with misc_utils.ChangeDir(directory):
40 if verbose:
41 print '%s\n>>>> %s\n>>>> %s\n' % (directory, repo, checkout)
42 subprocess.check_call([git, 'checkout', '--quiet', checkout])
43
44
45 def main(argv):
46 deps_file = os.path.join(SKIA_CHECKOUT_PATH, 'DEPS')
47 DEPS = {}
48 execfile(deps_file, DEPS)
49 dependencies = DEPS['deps'].copy()
50 for arg in argv:
epoger 2014/04/11 16:16:11 Please add comment like: # Add OS-specific depend
epoger 2014/04/11 16:16:11 Does it make sense for us to pick up multiple OSes
hal.canary 2014/04/11 17:46:51 Yes, since I might test my branch by cross-compili
hal.canary 2014/04/11 17:46:51 Done.
51 if arg not in DEPS['deps_os']:
52 print arg, '?'
epoger 2014/04/11 16:16:11 Maybe instead of print/exit, do this? raise Excep
hal.canary 2014/04/11 17:46:51 Done.
53 exit(1)
54 for dep in DEPS['deps_os'][arg]:
55 dependencies[dep] = DEPS['deps_os'][arg][dep]
56 for directory in dependencies:
57 if '@' in dependencies[directory]:
58 repo, checkout = dependencies[directory].split('@', 1)
epoger 2014/04/11 16:16:11 maybe "tag", "githash", "version", or "revision" w
hal.canary 2014/04/11 17:46:51 I mean 'checkout' as anything that can be passed t
epoger 2014/04/11 18:28:39 In "git checkout --help", they use the term "tree-
59 else:
60 repo, checkout = dependencies[directory], 'origin/master'
61
62 with misc_utils.ChangeDir(SKIA_CHECKOUT_PATH):
63 git_checkout_to_directory(repo, checkout, directory, verbose=True)
64
65 if __name__ == '__main__':
66 main(sys.argv[1:])
67
OLDNEW
« no previous file with comments | « docs/quickstart.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698