summaryrefslogtreecommitdiffstats
path: root/tools/checkdeps/checkdeps.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/checkdeps/checkdeps.py')
-rwxr-xr-xtools/checkdeps/checkdeps.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/checkdeps/checkdeps.py b/tools/checkdeps/checkdeps.py
index 4c00515..5ef4de3 100755
--- a/tools/checkdeps/checkdeps.py
+++ b/tools/checkdeps/checkdeps.py
@@ -241,18 +241,30 @@ def ApplyDirectoryRules(existing_rules, dir_name):
print "Applying rules from", dir_name
def FromImpl(unused):
pass # NOP function so "From" doesn't fail.
- scope = {"From": FromImpl}
+
+ class _VarImpl:
+ def __init__(self, local_scope):
+ self._local_scope = local_scope
+
+ def Lookup(self, var_name):
+ """Implements the Var syntax."""
+ if var_name in self._local_scope.get("vars", {}):
+ return self._local_scope["vars"][var_name]
+ raise Error("Var is not defined: %s" % var_name)
+
+ local_scope = {}
+ global_scope = {"From": FromImpl, "Var": _VarImpl(local_scope).Lookup}
deps_file = os.path.join(dir_name, "DEPS")
if not os.path.exists(deps_file):
if VERBOSE:
print " No deps file found in", dir_name
return (existing_rules, []) # Nothing to change from the input rules.
- execfile(deps_file, scope)
+ execfile(deps_file, global_scope, local_scope)
- deps = scope.get(DEPS_VAR_NAME, {})
- include_rules = scope.get(INCLUDE_RULES_VAR_NAME, [])
- skip_subdirs = scope.get(SKIP_SUBDIRS_VAR_NAME, [])
+ deps = local_scope.get(DEPS_VAR_NAME, {})
+ include_rules = local_scope.get(INCLUDE_RULES_VAR_NAME, [])
+ skip_subdirs = local_scope.get(SKIP_SUBDIRS_VAR_NAME, [])
return (ApplyRules(existing_rules, deps, include_rules, dir_name),
skip_subdirs)