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

Side by Side Diff: gclient.py

Issue 368713002: Add fallback to DEPS from a missing deps file. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: update test Created 6 years, 5 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 | tests/gclient_smoketest.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 # Files 7 # Files
8 # .gclient : Current client configuration, written by 'config' command. 8 # .gclient : Current client configuration, written by 'config' command.
9 # Format is a Python script defining 'solutions', a list whose 9 # Format is a Python script defining 'solutions', a list whose
10 # entries each are maps binding the strings "name" and "url" 10 # entries each are maps binding the strings "name" and "url"
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 new_deps.update(target_os_deps) 528 new_deps.update(target_os_deps)
529 return new_deps 529 return new_deps
530 530
531 def ParseDepsFile(self): 531 def ParseDepsFile(self):
532 """Parses the DEPS file for this dependency.""" 532 """Parses the DEPS file for this dependency."""
533 assert not self.deps_parsed 533 assert not self.deps_parsed
534 assert not self.dependencies 534 assert not self.dependencies
535 535
536 deps_content = None 536 deps_content = None
537 use_strict = False 537 use_strict = False
538 filepath = os.path.join(self.root.root_dir, self.name, self.deps_file) 538
539 if not os.path.isfile(filepath): 539 # First try to locate the configured deps file. If it's missing, fallback
540 # to DEPS.
541 deps_files = [self.deps_file]
542 if 'DEPS' not in deps_files:
543 deps_files.append('DEPS')
544 for deps_file in deps_files:
545 filepath = os.path.join(self.root.root_dir, self.name, deps_file)
546 if os.path.isfile(filepath):
547 logging.info(
548 'ParseDepsFile(%s): %s file found at %s', self.name, deps_file,
549 filepath)
550 break
540 logging.info( 551 logging.info(
541 'ParseDepsFile(%s): No %s file found at %s' % ( 552 'ParseDepsFile(%s): No %s file found at %s', self.name, deps_file,
542 self.name, self.deps_file, filepath)) 553 filepath)
543 else: 554
555 if os.path.isfile(filepath):
544 deps_content = gclient_utils.FileRead(filepath) 556 deps_content = gclient_utils.FileRead(filepath)
545 logging.debug('ParseDepsFile(%s) read:\n%s' % (self.name, deps_content)) 557 logging.debug('ParseDepsFile(%s) read:\n%s', self.name, deps_content)
546 use_strict = 'use strict' in deps_content.splitlines()[0] 558 use_strict = 'use strict' in deps_content.splitlines()[0]
547 559
548 local_scope = {} 560 local_scope = {}
549 if deps_content: 561 if deps_content:
550 # One thing is unintuitive, vars = {} must happen before Var() use. 562 # One thing is unintuitive, vars = {} must happen before Var() use.
551 var = self.VarImpl(self.custom_vars, local_scope) 563 var = self.VarImpl(self.custom_vars, local_scope)
552 if use_strict: 564 if use_strict:
553 logging.info( 565 logging.info(
554 'ParseDepsFile(%s): Strict Mode Enabled', self.name) 566 'ParseDepsFile(%s): Strict Mode Enabled', self.name)
555 global_scope = { 567 global_scope = {
(...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 print >> sys.stderr, 'Error: %s' % str(e) 2045 print >> sys.stderr, 'Error: %s' % str(e)
2034 return 1 2046 return 1
2035 finally: 2047 finally:
2036 gclient_utils.PrintWarnings() 2048 gclient_utils.PrintWarnings()
2037 2049
2038 2050
2039 if '__main__' == __name__: 2051 if '__main__' == __name__:
2040 sys.exit(Main(sys.argv[1:])) 2052 sys.exit(Main(sys.argv[1:]))
2041 2053
2042 # vim: ts=2:sw=2:tw=80:et: 2054 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | tests/gclient_smoketest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698