Index: deps_utils.py |
=================================================================== |
--- deps_utils.py (revision 292133) |
+++ deps_utils.py (working copy) |
@@ -16,22 +16,26 @@ |
class VarImpl(object): |
"""Implement the Var function used within the DEPS file.""" |
- def __init__(self, local_scope): |
+ def __init__(self, local_scope, var_overrides=None): |
self._local_scope = local_scope |
+ self._var_overrides = var_overrides or {} |
def Lookup(self, var_name): |
"""Implements the Var syntax.""" |
+ if var_name in self._var_overrides: |
+ return self._var_overrides[var_name] |
if var_name in self._local_scope.get('vars', {}): |
return self._local_scope['vars'][var_name] |
raise Exception('Var is not defined: %s' % var_name) |
-def GetDepsContent(deps_path): |
+def GetDepsContent(deps_path, var_overrides=None): |
"""Read a DEPS file and return all the sections.""" |
deps_file = open(deps_path, 'rU') |
+ var_overrides = var_overrides or {} |
content = deps_file.read() |
local_scope = {} |
- var = VarImpl(local_scope) |
+ var = VarImpl(local_scope, var_overrides) |
global_scope = { |
'Var': var.Lookup, |
'deps': {}, |
@@ -48,6 +52,7 @@ |
local_scope.setdefault('skip_child_includes', []) |
local_scope.setdefault('hooks', []) |
local_scope.setdefault('vars', {}) |
+ local_scope['vars'].update(var_overrides) |
return (local_scope['deps'], local_scope['deps_os'], |
local_scope['include_rules'], local_scope['skip_child_includes'], |