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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « docs/quickstart.md ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grab_deps.py
diff --git a/tools/grab_deps.py b/tools/grab_deps.py
new file mode 100755
index 0000000000000000000000000000000000000000..5219ce97697abbadd7ab97e24b5df9c8c5c926af
--- /dev/null
+++ b/tools/grab_deps.py
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+# Copyright 2014 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
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.
+
+import git_utils
+import misc_utils
+import os
+import subprocess
+import sys
+
+
+SKIA_CHECKOUT_PATH = os.path.join(os.path.dirname(__file__), os.pardir)
+
+
+def rm_directory_if_exists(directory):
+ if os.path.isdir(directory) and not os.path.islink(directory):
+ shutil.rmtree(directory)
+ elif os.path.lexists(directory):
+ os.remove(directory)
+
+
+def git_checkout_to_directory(repo, checkout, directory, verbose=False):
+ """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.
+ """
+ git = git_utils.git_executable()
+ assert git
+ try:
+ with misc_utils.ChangeDir(directory):
+ if verbose:
+ print '%s\n>>>> %s\n>>>> %s\n' % (directory, repo, checkout)
+ subprocess.check_call([git, 'fetch'])
+ subprocess.check_call([git, 'checkout', '--quiet', checkout])
+ except:
+ rm_directory_if_exists(directory)
+ subprocess.check_call([git, 'clone', repo, directory])
+ with misc_utils.ChangeDir(directory):
+ if verbose:
+ print '%s\n>>>> %s\n>>>> %s\n' % (directory, repo, checkout)
+ subprocess.check_call([git, 'checkout', '--quiet', checkout])
+
+
+def main(argv):
+ deps_file = os.path.join(SKIA_CHECKOUT_PATH, 'DEPS')
+ DEPS = {}
+ execfile(deps_file, DEPS)
+ dependencies = DEPS['deps'].copy()
+ 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.
+ if arg not in DEPS['deps_os']:
+ 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.
+ exit(1)
+ for dep in DEPS['deps_os'][arg]:
+ dependencies[dep] = DEPS['deps_os'][arg][dep]
+ for directory in dependencies:
+ if '@' in dependencies[directory]:
+ 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-
+ else:
+ repo, checkout = dependencies[directory], 'origin/master'
+
+ with misc_utils.ChangeDir(SKIA_CHECKOUT_PATH):
+ git_checkout_to_directory(repo, checkout, directory, verbose=True)
+
+if __name__ == '__main__':
+ main(sys.argv[1:])
+
« 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