Chromium Code Reviews| 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, custom_vars=None): |
|
szager1
2014/10/02 21:16:22
Can you use a different name than custom_vars, her
kjellander_chromium
2014/10/03 07:13:31
You're absolutely right. I forgot that custom_vars
|
| self._local_scope = local_scope |
| + self._custom_vars = custom_vars or {} |
| def Lookup(self, var_name): |
| """Implements the Var syntax.""" |
| + if var_name in self._custom_vars: |
| + return self._custom_vars[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, custom_vars=None): |
| """Read a DEPS file and return all the sections.""" |
| deps_file = open(deps_path, 'rU') |
| + custom_vars = custom_vars or {} |
| content = deps_file.read() |
| local_scope = {} |
| - var = VarImpl(local_scope) |
| + var = VarImpl(local_scope, custom_vars) |
| 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(custom_vars) |
| return (local_scope['deps'], local_scope['deps_os'], |
| local_scope['include_rules'], local_scope['skip_child_includes'], |