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 22 matching lines...) Expand all Loading... |
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 'vars': {}, |
| 43 'recursedeps': [], |
43 } | 44 } |
44 exec(content, global_scope, local_scope) | 45 exec(content, global_scope, local_scope) |
45 local_scope.setdefault('deps', {}) | 46 local_scope.setdefault('deps', {}) |
46 local_scope.setdefault('deps_os', {}) | 47 local_scope.setdefault('deps_os', {}) |
47 local_scope.setdefault('include_rules', []) | 48 local_scope.setdefault('include_rules', []) |
48 local_scope.setdefault('skip_child_includes', []) | 49 local_scope.setdefault('skip_child_includes', []) |
49 local_scope.setdefault('hooks', []) | 50 local_scope.setdefault('hooks', []) |
50 local_scope.setdefault('vars', {}) | 51 local_scope.setdefault('vars', {}) |
| 52 local_scope.setdefault('recursedeps', []) |
51 | 53 |
52 return (local_scope['deps'], local_scope['deps_os'], | 54 return (local_scope['deps'], local_scope['deps_os'], |
53 local_scope['include_rules'], local_scope['skip_child_includes'], | 55 local_scope['include_rules'], local_scope['skip_child_includes'], |
54 local_scope['hooks'], local_scope['vars']) | 56 local_scope['hooks'], local_scope['vars'], local_scope['recursedeps']) |
55 | 57 |
56 | 58 |
57 def PrettyDeps(deps, indent=0): | 59 def PrettyDeps(deps, indent=0): |
58 """Stringify a deps dictionary in a pretty way.""" | 60 """Stringify a deps dictionary in a pretty way.""" |
59 pretty = ' ' * indent | 61 pretty = ' ' * indent |
60 pretty += '{\n' | 62 pretty += '{\n' |
61 | 63 |
62 indent += 4 | 64 indent += 4 |
63 | 65 |
64 for item in sorted(deps): | 66 for item in sorted(deps): |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 '\'https://chromium.googlesource.com', 'Var(\'git_url\') + \'') | 102 '\'https://chromium.googlesource.com', 'Var(\'git_url\') + \'') |
101 deps = deps.replace( | 103 deps = deps.replace( |
102 '\'https://git.chromium.org', 'Var(\'git_url\') + \'') | 104 '\'https://git.chromium.org', 'Var(\'git_url\') + \'') |
103 deps = deps.replace('VAR_WEBKIT_REV\'', '\' + Var(\'webkit_rev\')') | 105 deps = deps.replace('VAR_WEBKIT_REV\'', '\' + Var(\'webkit_rev\')') |
104 deps = deps.replace('VAR_ANGLE_REVISION\'', | 106 deps = deps.replace('VAR_ANGLE_REVISION\'', |
105 '\' + \'@\' + Var(\'angle_revision\')') | 107 '\' + \'@\' + Var(\'angle_revision\')') |
106 return deps | 108 return deps |
107 | 109 |
108 | 110 |
109 def WriteDeps(deps_file_name, deps_vars, deps, deps_os, include_rules, | 111 def WriteDeps(deps_file_name, deps_vars, deps, deps_os, include_rules, |
110 skip_child_includes, hooks): | 112 skip_child_includes, hooks, recursedeps): |
111 """Given all the sections in a DEPS file, write it to disk.""" | 113 """Given all the sections in a DEPS file, write it to disk.""" |
112 new_deps = ('# DO NOT EDIT EXCEPT FOR LOCAL TESTING.\n' | 114 new_deps = ('# DO NOT EDIT EXCEPT FOR LOCAL TESTING.\n' |
113 '# THIS IS A GENERATED FILE.\n', | 115 '# THIS IS A GENERATED FILE.\n', |
114 '# ALL MANUAL CHANGES WILL BE OVERWRITTEN.\n', | 116 '# ALL MANUAL CHANGES WILL BE OVERWRITTEN.\n', |
115 '# SEE http://code.google.com/p/chromium/wiki/UsingGit\n', | 117 '# SEE http://code.google.com/p/chromium/wiki/UsingGit\n', |
116 '# FOR HOW TO ROLL DEPS\n' | 118 '# FOR HOW TO ROLL DEPS\n' |
117 'vars = %s\n\n' % PrettyObj(deps_vars), | 119 'vars = %s\n\n' % PrettyObj(deps_vars), |
118 'deps = %s\n\n' % Varify(PrettyDeps(deps)), | 120 'deps = %s\n\n' % Varify(PrettyDeps(deps)), |
119 'deps_os = %s\n\n' % Varify(PrettyDeps(deps_os)), | 121 'deps_os = %s\n\n' % Varify(PrettyDeps(deps_os)), |
120 'include_rules = %s\n\n' % PrettyObj(include_rules), | 122 'include_rules = %s\n\n' % PrettyObj(include_rules), |
121 'skip_child_includes = %s\n\n' % PrettyObj(skip_child_includes), | 123 'skip_child_includes = %s\n\n' % PrettyObj(skip_child_includes), |
122 'hooks = %s\n' % PrettyObj(hooks)) | 124 'hooks = %s\n' % PrettyObj(hooks), |
| 125 'recursedeps = %s\n' % PrettyObj(recursedeps)) |
123 new_deps = ''.join(new_deps) | 126 new_deps = ''.join(new_deps) |
124 if deps_file_name: | 127 if deps_file_name: |
125 deps_file = open(deps_file_name, 'wb') | 128 deps_file = open(deps_file_name, 'wb') |
126 else: | 129 else: |
127 deps_file = sys.stdout | 130 deps_file = sys.stdout |
128 | 131 |
129 try: | 132 try: |
130 deps_file.write(new_deps) | 133 deps_file.write(new_deps) |
131 finally: | 134 finally: |
132 if deps_file_name: | 135 if deps_file_name: |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 # For POSIX: making the directory writable guarantees removability. | 210 # For POSIX: making the directory writable guarantees removability. |
208 # Windows will ignore the non-read-only bits in the chmod value. | 211 # Windows will ignore the non-read-only bits in the chmod value. |
209 os.chmod(root, 0770) | 212 os.chmod(root, 0770) |
210 for name in files: | 213 for name in files: |
211 remove_with_retry(os.remove, os.path.join(root, name)) | 214 remove_with_retry(os.remove, os.path.join(root, name)) |
212 for name in dirs: | 215 for name in dirs: |
213 remove_with_retry(lambda p: shutil.rmtree(p, onerror=RmTreeOnError), | 216 remove_with_retry(lambda p: shutil.rmtree(p, onerror=RmTreeOnError), |
214 os.path.join(root, name)) | 217 os.path.join(root, name)) |
215 | 218 |
216 remove_with_retry(os.rmdir, file_path) | 219 remove_with_retry(os.rmdir, file_path) |
OLD | NEW |