OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/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 """Utilities for formatting and writing DEPS files.""" | 6 """Utilities for formatting and writing DEPS files.""" |
7 | 7 |
8 import errno | 8 import errno |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
(...skipping 21 matching lines...) Expand all Loading... |
32 content = deps_file.read() | 32 content = deps_file.read() |
33 local_scope = {} | 33 local_scope = {} |
34 var = VarImpl(local_scope) | 34 var = VarImpl(local_scope) |
35 global_scope = { | 35 global_scope = { |
36 'Var': var.Lookup, | 36 'Var': var.Lookup, |
37 'deps': {}, | 37 'deps': {}, |
38 'deps_os': {}, | 38 'deps_os': {}, |
39 'include_rules': [], | 39 'include_rules': [], |
40 'skip_child_includes': [], | 40 'skip_child_includes': [], |
41 'hooks': [], | 41 'hooks': [], |
| 42 'vars': {}, |
42 } | 43 } |
43 exec(content, global_scope, local_scope) | 44 exec(content, global_scope, local_scope) |
44 local_scope.setdefault('deps', {}) | 45 local_scope.setdefault('deps', {}) |
45 local_scope.setdefault('deps_os', {}) | 46 local_scope.setdefault('deps_os', {}) |
46 local_scope.setdefault('include_rules', []) | 47 local_scope.setdefault('include_rules', []) |
47 local_scope.setdefault('skip_child_includes', []) | 48 local_scope.setdefault('skip_child_includes', []) |
48 local_scope.setdefault('hooks', []) | 49 local_scope.setdefault('hooks', []) |
| 50 local_scope.setdefault('vars', {}) |
49 | 51 |
50 return (local_scope['deps'], local_scope['deps_os'], | 52 return (local_scope['deps'], local_scope['deps_os'], |
51 local_scope['include_rules'], local_scope['skip_child_includes'], | 53 local_scope['include_rules'], local_scope['skip_child_includes'], |
52 local_scope['hooks']) | 54 local_scope['hooks'], local_scope['vars']) |
53 | 55 |
54 | 56 |
55 def PrettyDeps(deps, indent=0): | 57 def PrettyDeps(deps, indent=0): |
56 """Stringify a deps dictionary in a pretty way.""" | 58 """Stringify a deps dictionary in a pretty way.""" |
57 pretty = ' ' * indent | 59 pretty = ' ' * indent |
58 pretty += '{\n' | 60 pretty += '{\n' |
59 | 61 |
60 indent += 4 | 62 indent += 4 |
61 | 63 |
62 for item in sorted(deps): | 64 for item in sorted(deps): |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 # For POSIX: making the directory writable guarantees removability. | 207 # For POSIX: making the directory writable guarantees removability. |
206 # Windows will ignore the non-read-only bits in the chmod value. | 208 # Windows will ignore the non-read-only bits in the chmod value. |
207 os.chmod(root, 0770) | 209 os.chmod(root, 0770) |
208 for name in files: | 210 for name in files: |
209 remove_with_retry(os.remove, os.path.join(root, name)) | 211 remove_with_retry(os.remove, os.path.join(root, name)) |
210 for name in dirs: | 212 for name in dirs: |
211 remove_with_retry(lambda p: shutil.rmtree(p, onerror=RmTreeOnError), | 213 remove_with_retry(lambda p: shutil.rmtree(p, onerror=RmTreeOnError), |
212 os.path.join(root, name)) | 214 os.path.join(root, name)) |
213 | 215 |
214 remove_with_retry(os.rmdir, file_path) | 216 remove_with_retry(os.rmdir, file_path) |
OLD | NEW |