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

Side by Side Diff: gclient.py

Issue 11246004: Allow DEPS file to specify 'target_os'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix a comment Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/gclient_test.py » ('j') | 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 # 'managed' and 'should_process' is that the user specifies 'managed' via 165 # 'managed' and 'should_process' is that the user specifies 'managed' via
166 # the --unmanaged command-line flag or a .gclient config, where 166 # the --unmanaged command-line flag or a .gclient config, where
167 # 'should_process' is dynamically set by gclient if it goes over its 167 # 'should_process' is dynamically set by gclient if it goes over its
168 # recursion limit and controls gclient's behavior so it does not misbehave. 168 # recursion limit and controls gclient's behavior so it does not misbehave.
169 self._managed = managed 169 self._managed = managed
170 self._should_process = should_process 170 self._should_process = should_process
171 # This is a mutable value that overrides the normal recursion limit for this 171 # This is a mutable value that overrides the normal recursion limit for this
172 # dependency. It is read from the actual DEPS file so cannot be set on 172 # dependency. It is read from the actual DEPS file so cannot be set on
173 # class instantiation. 173 # class instantiation.
174 self.recursion_override = None 174 self.recursion_override = None
175 # This is a mutable value which has the list of 'target_os' OSes listed in
176 # the current deps file.
177 self.local_target_os = None
175 178
176 # These are only set in .gclient and not in DEPS files. 179 # These are only set in .gclient and not in DEPS files.
177 self._custom_vars = custom_vars or {} 180 self._custom_vars = custom_vars or {}
178 self._custom_deps = custom_deps or {} 181 self._custom_deps = custom_deps or {}
179 182
180 # Post process the url to remove trailing slashes. 183 # Post process the url to remove trailing slashes.
181 if isinstance(self._url, basestring): 184 if isinstance(self._url, basestring):
182 # urls are sometime incorrectly written as proto://host/path/@rev. Replace 185 # urls are sometime incorrectly written as proto://host/path/@rev. Replace
183 # it to proto://host/path@rev. 186 # it to proto://host/path@rev.
184 self._url = self._url.replace('/@', '@') 187 self._url = self._url.replace('/@', '@')
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 def url(self): 235 def url(self):
233 return self._url 236 return self._url
234 237
235 @property 238 @property
236 def recursion_limit(self): 239 def recursion_limit(self):
237 """Returns > 0 if this dependency is not too recursed to be processed.""" 240 """Returns > 0 if this dependency is not too recursed to be processed."""
238 if self.recursion_override is not None: 241 if self.recursion_override is not None:
239 return self.recursion_override 242 return self.recursion_override
240 return max(self.parent.recursion_limit - 1, 0) 243 return max(self.parent.recursion_limit - 1, 0)
241 244
245 @property
246 def target_os(self):
247 if self.local_target_os is not None:
248 return tuple(set(self.local_target_os).union(self.parent.target_os))
249 else:
250 return self.parent.target_os
251
242 def get_custom_deps(self, name, url): 252 def get_custom_deps(self, name, url):
243 """Returns a custom deps if applicable.""" 253 """Returns a custom deps if applicable."""
244 if self.parent: 254 if self.parent:
245 url = self.parent.get_custom_deps(name, url) 255 url = self.parent.get_custom_deps(name, url)
246 # None is a valid return value to disable a dependency. 256 # None is a valid return value to disable a dependency.
247 return self.custom_deps.get(name, url) 257 return self.custom_deps.get(name, url)
248 258
249 259
250 class Dependency(gclient_utils.WorkItem, DependencySettings): 260 class Dependency(gclient_utils.WorkItem, DependencySettings):
251 """Object that represents a dependency checkout.""" 261 """Object that represents a dependency checkout."""
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 # Eval the content. 458 # Eval the content.
449 try: 459 try:
450 exec(deps_content, global_scope, local_scope) 460 exec(deps_content, global_scope, local_scope)
451 except SyntaxError, e: 461 except SyntaxError, e:
452 gclient_utils.SyntaxErrorToError(filepath, e) 462 gclient_utils.SyntaxErrorToError(filepath, e)
453 deps = local_scope.get('deps', {}) 463 deps = local_scope.get('deps', {})
454 if 'recursion' in local_scope: 464 if 'recursion' in local_scope:
455 self.recursion_override = local_scope.get('recursion') 465 self.recursion_override = local_scope.get('recursion')
456 logging.warning( 466 logging.warning(
457 'Setting %s recursion to %d.', self.name, self.recursion_limit) 467 'Setting %s recursion to %d.', self.name, self.recursion_limit)
468 # If present, save 'target_os' in the local_target_os property.
469 if 'target_os' in local_scope:
470 self.local_target_os = local_scope['target_os']
458 # load os specific dependencies if defined. these dependencies may 471 # load os specific dependencies if defined. these dependencies may
459 # override or extend the values defined by the 'deps' member. 472 # override or extend the values defined by the 'deps' member.
460 if 'deps_os' in local_scope: 473 if 'deps_os' in local_scope:
461 enforced_os = self.root.enforced_os 474 for deps_os_key in self.target_os:
462 for deps_os_key in enforced_os:
463 os_deps = local_scope['deps_os'].get(deps_os_key, {}) 475 os_deps = local_scope['deps_os'].get(deps_os_key, {})
464 if len(enforced_os) > 1: 476 if len(self.target_os) > 1:
465 # Ignore any conflict when including deps for more than one 477 # Ignore any conflict when including deps for more than one
466 # platform, so we collect the broadest set of dependencies 478 # platform, so we collect the broadest set of dependencies
467 # available. We may end up with the wrong revision of something for 479 # available. We may end up with the wrong revision of something for
468 # our platform, but this is the best we can do. 480 # our platform, but this is the best we can do.
469 deps.update([x for x in os_deps.items() if not x[0] in deps]) 481 deps.update([x for x in os_deps.items() if not x[0] in deps])
470 else: 482 else:
471 deps.update(os_deps) 483 deps.update(os_deps)
472 484
473 # If a line is in custom_deps, but not in the solution, we want to append 485 # If a line is in custom_deps, but not in the solution, we want to append
474 # this line to the solution. 486 # this line to the solution.
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 @property 1171 @property
1160 def enforced_os(self): 1172 def enforced_os(self):
1161 """What deps_os entries that are to be parsed.""" 1173 """What deps_os entries that are to be parsed."""
1162 return self._enforced_os 1174 return self._enforced_os
1163 1175
1164 @property 1176 @property
1165 def recursion_limit(self): 1177 def recursion_limit(self):
1166 """How recursive can each dependencies in DEPS file can load DEPS file.""" 1178 """How recursive can each dependencies in DEPS file can load DEPS file."""
1167 return self._recursion_limit 1179 return self._recursion_limit
1168 1180
1181 @property
1182 def target_os(self):
1183 return self._enforced_os
1184
1169 1185
1170 #### gclient commands. 1186 #### gclient commands.
1171 1187
1172 1188
1173 def CMDcleanup(parser, args): 1189 def CMDcleanup(parser, args):
1174 """Cleans up all working copies. 1190 """Cleans up all working copies.
1175 1191
1176 Mostly svn-specific. Simply runs 'svn cleanup' for each module. 1192 Mostly svn-specific. Simply runs 'svn cleanup' for each module.
1177 """ 1193 """
1178 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST', 1194 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST',
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 1659 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1644 print >> sys.stderr, 'Error: %s' % str(e) 1660 print >> sys.stderr, 'Error: %s' % str(e)
1645 return 1 1661 return 1
1646 1662
1647 1663
1648 if '__main__' == __name__: 1664 if '__main__' == __name__:
1649 fix_encoding.fix_encoding() 1665 fix_encoding.fix_encoding()
1650 sys.exit(Main(sys.argv[1:])) 1666 sys.exit(Main(sys.argv[1:]))
1651 1667
1652 # vim: ts=2:sw=2:tw=80:et: 1668 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | tests/gclient_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698