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

Side by Side Diff: tools/checkdeps/checkdeps.py

Issue 8609003: Allow checkdeps to function in the presence of File(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | 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 (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 """Makes sure that files include headers from allowed directories. 6 """Makes sure that files include headers from allowed directories.
7 7
8 Checks DEPS files in the source tree for rules, and applies those rules to 8 Checks DEPS files in the source tree for rules, and applies those rules to
9 "#include" commands in source files. Any source file including something not 9 "#include" commands in source files. Any source file including something not
10 permitted by the DEPS files will fail. 10 permitted by the DEPS files will fail.
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if not (os.path.exists(os.path.join(dir_name, ".svn")) or 239 if not (os.path.exists(os.path.join(dir_name, ".svn")) or
240 (dir_name.lower() in GIT_SOURCE_DIRECTORY)): 240 (dir_name.lower() in GIT_SOURCE_DIRECTORY)):
241 return (None, []) 241 return (None, [])
242 242
243 # Check the DEPS file in this directory. 243 # Check the DEPS file in this directory.
244 if VERBOSE: 244 if VERBOSE:
245 print "Applying rules from", dir_name 245 print "Applying rules from", dir_name
246 def FromImpl(unused, unused2): 246 def FromImpl(unused, unused2):
247 pass # NOP function so "From" doesn't fail. 247 pass # NOP function so "From" doesn't fail.
248 248
249 def FileImpl(unused):
250 pass # NOP function so "File" doesn't fail.
251
249 class _VarImpl: 252 class _VarImpl:
250 def __init__(self, local_scope): 253 def __init__(self, local_scope):
251 self._local_scope = local_scope 254 self._local_scope = local_scope
252 255
253 def Lookup(self, var_name): 256 def Lookup(self, var_name):
254 """Implements the Var syntax.""" 257 """Implements the Var syntax."""
255 if var_name in self._local_scope.get("vars", {}): 258 if var_name in self._local_scope.get("vars", {}):
256 return self._local_scope["vars"][var_name] 259 return self._local_scope["vars"][var_name]
257 raise Error("Var is not defined: %s" % var_name) 260 raise Error("Var is not defined: %s" % var_name)
258 261
259 local_scope = {} 262 local_scope = {}
260 global_scope = {"From": FromImpl, "Var": _VarImpl(local_scope).Lookup} 263 global_scope = {
264 "File": FileImpl,
265 "From": FromImpl,
266 "Var": _VarImpl(local_scope).Lookup,
267 }
261 deps_file = os.path.join(dir_name, "DEPS") 268 deps_file = os.path.join(dir_name, "DEPS")
262 269
263 if os.path.isfile(deps_file): 270 if os.path.isfile(deps_file):
264 execfile(deps_file, global_scope, local_scope) 271 execfile(deps_file, global_scope, local_scope)
265 elif VERBOSE: 272 elif VERBOSE:
266 print " No deps file found in", dir_name 273 print " No deps file found in", dir_name
267 274
268 # Even if a DEPS file does not exist we still invoke ApplyRules 275 # Even if a DEPS file does not exist we still invoke ApplyRules
269 # to apply the implicit "allow" rule for the current directory 276 # to apply the implicit "allow" rule for the current directory
270 deps = local_scope.get(DEPS_VAR_NAME, {}) 277 deps = local_scope.get(DEPS_VAR_NAME, {})
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 if '__main__' == __name__: 498 if '__main__' == __name__:
492 option_parser = optparse.OptionParser() 499 option_parser = optparse.OptionParser()
493 option_parser.add_option("", "--root", default="", dest="base_directory", 500 option_parser.add_option("", "--root", default="", dest="base_directory",
494 help='Specifies the repository root. This defaults ' 501 help='Specifies the repository root. This defaults '
495 'to "../../.." relative to the script file, which ' 502 'to "../../.." relative to the script file, which '
496 'will normally be the repository root.') 503 'will normally be the repository root.')
497 option_parser.add_option("-v", "--verbose", action="store_true", 504 option_parser.add_option("-v", "--verbose", action="store_true",
498 default=False, help="Print debug logging") 505 default=False, help="Print debug logging")
499 options, args = option_parser.parse_args() 506 options, args = option_parser.parse_args()
500 main(options, args) 507 main(options, args)
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