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

Side by Side Diff: tools/git-sync-deps

Issue 494713005: git-sync-deps: handle recursion and deps_os at the same time (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comments from mtklein Created 6 years, 3 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 | « no previous file | 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
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2014 Google Inc. 2 # Copyright 2014 Google Inc.
3 # 3 #
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 7
8 """Parse a DEPS file and git checkout all of the dependencies. 8 """Parse a DEPS file and git checkout all of the dependencies.
9 9
10 Args: 10 Args:
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 execfile(path, dictionary) 147 execfile(path, dictionary)
148 return dictionary 148 return dictionary
149 149
150 150
151 class DepsError(Exception): 151 class DepsError(Exception):
152 """Raised if deps_os is a bad key. 152 """Raised if deps_os is a bad key.
153 """ 153 """
154 pass 154 pass
155 155
156 156
157 def git_sync_deps(deps_file_path, deps_os_list, verbose): 157 def git_sync_deps(deps_file_path, command_line_os_requests, verbose):
158 """Grab dependencies, with optional platform support. 158 """Grab dependencies, with optional platform support.
159 159
160 Args: 160 Args:
161 deps_file_path (string) Path to the DEPS file. 161 deps_file_path (string) Path to the DEPS file.
162 162
163 deps_os_list (list of strings) Can be empty list. List of 163 deps_os_list (list of strings) Can be empty list. List of
mtklein 2014/08/26 18:58:36 update?
164 strings that should each be a key in the deps_os 164 strings that should each be a key in the deps_os
165 dictionary in the DEPS file. 165 dictionary in the DEPS file.
166 166
167 Raises DepsError exception and git Exceptions. 167 Raises DepsError exception and git Exceptions.
168 """ 168 """
169 git = git_executable() 169 git = git_executable()
170 assert git 170 assert git
171 171
172 deps_file_directory = os.path.dirname(deps_file_path) 172 deps_file_directory = os.path.dirname(deps_file_path)
173 deps = parse_file_to_dict(deps_file_path) 173 deps_file = parse_file_to_dict(deps_file_path)
174 dependencies = deps['deps'].copy() 174 dependencies = deps_file['deps'].copy()
175 for deps_os in deps_os_list: 175 os_specific_dependencies = deps_file.get('deps_os', [])
176 for os_name in command_line_os_requests:
176 # Add OS-specific dependencies 177 # Add OS-specific dependencies
177 if deps_os not in deps['deps_os']: 178 if os_name in os_specific_dependencies:
178 raise DepsError( 179 dependencies.update(os_specific_dependencies[os_name])
179 'Argument "%s" not found within deps_os keys %r' %
180 (deps_os, deps['deps_os'].keys()))
181 for dep in deps['deps_os'][deps_os]:
182 dependencies[dep] = deps['deps_os'][deps_os][dep]
183 list_of_arg_lists = [] 180 list_of_arg_lists = []
184 for directory in dependencies: 181 for directory in dependencies:
185 if '@' in dependencies[directory]: 182 if '@' in dependencies[directory]:
186 repo, checkoutable = dependencies[directory].split('@', 1) 183 repo, checkoutable = dependencies[directory].split('@', 1)
187 else: 184 else:
188 repo, checkoutable = dependencies[directory], 'origin/master' 185 repo, checkoutable = dependencies[directory], 'origin/master'
189 186
190 relative_directory = os.path.join(deps_file_directory, directory) 187 relative_directory = os.path.join(deps_file_directory, directory)
191 188
192 list_of_arg_lists.append( 189 list_of_arg_lists.append(
193 (git, repo, checkoutable, relative_directory, verbose)) 190 (git, repo, checkoutable, relative_directory, verbose))
194 191
195 multithread(git_checkout_to_directory, list_of_arg_lists) 192 multithread(git_checkout_to_directory, list_of_arg_lists)
196 193
197 for directory in deps.get('recursedeps', []): 194 for directory in deps_file.get('recursedeps', []):
198 recursive_path = os.path.join(deps_file_directory, directory, 'DEPS') 195 recursive_path = os.path.join(deps_file_directory, directory, 'DEPS')
199 git_sync_deps(recursive_path, deps_os_list, verbose) 196 git_sync_deps(recursive_path, command_line_os_requests, verbose)
200 197
201 198
202 def multithread(function, list_of_arg_lists): 199 def multithread(function, list_of_arg_lists):
203 # for args in list_of_arg_lists: 200 # for args in list_of_arg_lists:
204 # function(*args) 201 # function(*args)
205 # return 202 # return
206 threads = [] 203 threads = []
207 for args in list_of_arg_lists: 204 for args in list_of_arg_lists:
208 thread = threading.Thread(None, function, None, args) 205 thread = threading.Thread(None, function, None, args)
209 thread.start() 206 thread.start()
210 threads.append(thread) 207 threads.append(thread)
211 for thread in threads: 208 for thread in threads:
212 thread.join() 209 thread.join()
213 210
214 211
215 def main(argv): 212 def main(argv):
216 deps_file_path = os.environ.get('GIT_SYNC_DEPS_PATH', DEFAULT_DEPS_PATH) 213 deps_file_path = os.environ.get('GIT_SYNC_DEPS_PATH', DEFAULT_DEPS_PATH)
217 verbose = not bool(os.environ.get('GIT_SYNC_DEPS_QUIET', False)) 214 verbose = not bool(os.environ.get('GIT_SYNC_DEPS_QUIET', False))
218 try: 215 try:
219 git_sync_deps(deps_file_path, argv, verbose) 216 git_sync_deps(deps_file_path, argv, verbose)
220 return 0 217 return 0
221 except DepsError: 218 except DepsError:
222 usage(deps_file_path) 219 usage(deps_file_path)
223 return 1 220 return 1
224 221
225 222
226 if __name__ == '__main__': 223 if __name__ == '__main__':
227 exit(main(sys.argv[1:])) 224 exit(main(sys.argv[1:]))
OLDNEW
« 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