OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Meta checkout manager supporting both Subversion and GIT. | 6 """Meta checkout manager supporting both Subversion and GIT. |
7 | 7 |
8 Files | 8 Files |
9 .gclient : Current client configuration, written by 'config' command. | 9 .gclient : Current client configuration, written by 'config' command. |
10 Format is a Python script defining 'solutions', a list whose | 10 Format is a Python script defining 'solutions', a list whose |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 it will be removed from the list and the list will be extended | 42 it will be removed from the list and the list will be extended |
43 by the list of matching files. | 43 by the list of matching files. |
44 | 44 |
45 Example: | 45 Example: |
46 hooks = [ | 46 hooks = [ |
47 { "pattern": "\\.(gif|jpe?g|pr0n|png)$", | 47 { "pattern": "\\.(gif|jpe?g|pr0n|png)$", |
48 "action": ["python", "image_indexer.py", "--all"]}, | 48 "action": ["python", "image_indexer.py", "--all"]}, |
49 ] | 49 ] |
50 """ | 50 """ |
51 | 51 |
52 __version__ = "0.6" | 52 __version__ = "0.6.1" |
53 | 53 |
54 import copy | 54 import copy |
55 import logging | 55 import logging |
56 import optparse | 56 import optparse |
57 import os | 57 import os |
58 import posixpath | 58 import posixpath |
59 import pprint | 59 import pprint |
60 import re | 60 import re |
61 import subprocess | 61 import subprocess |
62 import sys | 62 import sys |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 else: | 247 else: |
248 raise gclient_utils.Error('Unkown url type') | 248 raise gclient_utils.Error('Unkown url type') |
249 | 249 |
250 def ParseDepsFile(self): | 250 def ParseDepsFile(self): |
251 """Parses the DEPS file for this dependency.""" | 251 """Parses the DEPS file for this dependency.""" |
252 assert self.processed == True | 252 assert self.processed == True |
253 if self.deps_parsed: | 253 if self.deps_parsed: |
254 logging.debug('%s was already parsed' % self.name) | 254 logging.debug('%s was already parsed' % self.name) |
255 return | 255 return |
256 self.deps_parsed = True | 256 self.deps_parsed = True |
257 filepath = os.path.join(self.root_dir(), self.name, self.deps_file) | |
258 if not os.path.isfile(filepath): | |
259 logging.info('%s: No DEPS file found at %s' % (self.name, filepath)) | |
260 return | |
261 deps_content = gclient_utils.FileRead(filepath) | |
262 logging.debug(deps_content) | |
263 | |
264 # Eval the content. | |
265 # One thing is unintuitive, vars= {} must happen before Var() use. | 257 # One thing is unintuitive, vars= {} must happen before Var() use. |
266 local_scope = {} | 258 local_scope = {} |
267 var = self.VarImpl(self.custom_vars, local_scope) | 259 var = self.VarImpl(self.custom_vars, local_scope) |
268 global_scope = { | 260 global_scope = { |
269 'File': self.FileImpl, | 261 'File': self.FileImpl, |
270 'From': self.FromImpl, | 262 'From': self.FromImpl, |
271 'Var': var.Lookup, | 263 'Var': var.Lookup, |
272 'deps_os': {}, | 264 'deps_os': {}, |
273 } | 265 } |
274 try: | 266 filepath = os.path.join(self.root_dir(), self.name, self.deps_file) |
275 exec(deps_content, global_scope, local_scope) | 267 if not os.path.isfile(filepath): |
276 except SyntaxError, e: | 268 logging.info('%s: No DEPS file found at %s' % (self.name, filepath)) |
277 gclient_utils.SyntaxErrorToError(filepath, e) | 269 else: |
| 270 deps_content = gclient_utils.FileRead(filepath) |
| 271 logging.debug(deps_content) |
| 272 # Eval the content. |
| 273 try: |
| 274 exec(deps_content, global_scope, local_scope) |
| 275 except SyntaxError, e: |
| 276 gclient_utils.SyntaxErrorToError(filepath, e) |
278 deps = local_scope.get('deps', {}) | 277 deps = local_scope.get('deps', {}) |
279 # load os specific dependencies if defined. these dependencies may | 278 # load os specific dependencies if defined. these dependencies may |
280 # override or extend the values defined by the 'deps' member. | 279 # override or extend the values defined by the 'deps' member. |
281 if 'deps_os' in local_scope: | 280 if 'deps_os' in local_scope: |
282 for deps_os_key in self.enforced_os(): | 281 for deps_os_key in self.enforced_os(): |
283 os_deps = local_scope['deps_os'].get(deps_os_key, {}) | 282 os_deps = local_scope['deps_os'].get(deps_os_key, {}) |
284 if len(self.enforced_os()) > 1: | 283 if len(self.enforced_os()) > 1: |
285 # Ignore any conflict when including deps for more than one | 284 # Ignore any conflict when including deps for more than one |
286 # platform, so we collect the broadest set of dependencies available. | 285 # platform, so we collect the broadest set of dependencies |
287 # We may end up with the wrong revision of something for our | 286 # available. We may end up with the wrong revision of something for |
288 # platform, but this is the best we can do. | 287 # our platform, but this is the best we can do. |
289 deps.update([x for x in os_deps.items() if not x[0] in deps]) | 288 deps.update([x for x in os_deps.items() if not x[0] in deps]) |
290 else: | 289 else: |
291 deps.update(os_deps) | 290 deps.update(os_deps) |
292 | 291 |
293 self.deps_hooks.extend(local_scope.get('hooks', [])) | 292 self.deps_hooks.extend(local_scope.get('hooks', [])) |
294 | 293 |
295 # If a line is in custom_deps, but not in the solution, we want to append | 294 # If a line is in custom_deps, but not in the solution, we want to append |
296 # this line to the solution. | 295 # this line to the solution. |
297 for d in self.custom_deps: | 296 for d in self.custom_deps: |
298 if d not in deps: | 297 if d not in deps: |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 return CMDhelp(parser, argv) | 1248 return CMDhelp(parser, argv) |
1250 except gclient_utils.Error, e: | 1249 except gclient_utils.Error, e: |
1251 print >> sys.stderr, 'Error: %s' % str(e) | 1250 print >> sys.stderr, 'Error: %s' % str(e) |
1252 return 1 | 1251 return 1 |
1253 | 1252 |
1254 | 1253 |
1255 if '__main__' == __name__: | 1254 if '__main__' == __name__: |
1256 sys.exit(Main(sys.argv[1:])) | 1255 sys.exit(Main(sys.argv[1:])) |
1257 | 1256 |
1258 # vim: ts=2:sw=2:tw=80:et: | 1257 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |