Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: deps_utils.py

Issue 190853003: Remove special case svn to git translations for FFmpeg. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/deps2git/
Patch Set: Rebase. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « deps2git.py ('k') | svn_to_git_public.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 re
11 import shutil 10 import shutil
12 import subprocess 11 import subprocess
13 import sys 12 import sys
14 import time 13 import time
15 14
16 # Used by Varify() to automatically convert variable names tagged with this
17 # prefix into Var('<variable name>').
18 VARIFY_MARKER_TAG_PREFIX = 'VARIFY_MARKER_TAG_'
19
20 15
21 class VarImpl(object): 16 class VarImpl(object):
22 """Implement the Var function used within the DEPS file.""" 17 """Implement the Var function used within the DEPS file."""
23 18
24 def __init__(self, local_scope): 19 def __init__(self, local_scope):
25 self._local_scope = local_scope 20 self._local_scope = local_scope
26 21
27 def Lookup(self, var_name): 22 def Lookup(self, var_name):
28 """Implements the Var syntax.""" 23 """Implements the Var syntax."""
29 if var_name in self._local_scope.get('vars', {}): 24 if var_name in self._local_scope.get('vars', {}):
(...skipping 14 matching lines...) Expand all
44 'include_rules': [], 39 'include_rules': [],
45 'skip_child_includes': [], 40 'skip_child_includes': [],
46 'hooks': [], 41 'hooks': [],
47 } 42 }
48 exec(content, global_scope, local_scope) 43 exec(content, global_scope, local_scope)
49 local_scope.setdefault('deps', {}) 44 local_scope.setdefault('deps', {})
50 local_scope.setdefault('deps_os', {}) 45 local_scope.setdefault('deps_os', {})
51 local_scope.setdefault('include_rules', []) 46 local_scope.setdefault('include_rules', [])
52 local_scope.setdefault('skip_child_includes', []) 47 local_scope.setdefault('skip_child_includes', [])
53 local_scope.setdefault('hooks', []) 48 local_scope.setdefault('hooks', [])
54 local_scope.setdefault('vars', {})
55 49
56 return (local_scope['deps'], local_scope['deps_os'], 50 return (local_scope['deps'], local_scope['deps_os'],
57 local_scope['include_rules'], local_scope['skip_child_includes'], 51 local_scope['include_rules'], local_scope['skip_child_includes'],
58 local_scope['hooks'], local_scope['vars']) 52 local_scope['hooks'])
59 53
60 54
61 def PrettyDeps(deps, indent=0): 55 def PrettyDeps(deps, indent=0):
62 """Stringify a deps dictionary in a pretty way.""" 56 """Stringify a deps dictionary in a pretty way."""
63 pretty = ' ' * indent 57 pretty = ' ' * indent
64 pretty += '{\n' 58 pretty += '{\n'
65 59
66 indent += 4 60 indent += 4
67 61
68 for item in sorted(deps): 62 for item in sorted(deps):
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 deps = deps.replace( 94 deps = deps.replace(
101 '\'https://chromium.googlesource.com/chromium/blink.git', 95 '\'https://chromium.googlesource.com/chromium/blink.git',
102 'Var(\'webkit_url\') + \'') 96 'Var(\'webkit_url\') + \'')
103 deps = deps.replace( 97 deps = deps.replace(
104 '\'https://chromium.googlesource.com', 'Var(\'git_url\') + \'') 98 '\'https://chromium.googlesource.com', 'Var(\'git_url\') + \'')
105 deps = deps.replace( 99 deps = deps.replace(
106 '\'https://git.chromium.org', 'Var(\'git_url\') + \'') 100 '\'https://git.chromium.org', 'Var(\'git_url\') + \'')
107 deps = deps.replace('VAR_WEBKIT_REV\'', '\' + Var(\'webkit_rev\')') 101 deps = deps.replace('VAR_WEBKIT_REV\'', '\' + Var(\'webkit_rev\')')
108 deps = deps.replace('VAR_ANGLE_REVISION\'', 102 deps = deps.replace('VAR_ANGLE_REVISION\'',
109 '\' + \'@\' + Var(\'angle_revision\')') 103 '\' + \'@\' + Var(\'angle_revision\')')
110
111 # Try to replace all instances of form "marker_prefix_<name>'" with
112 # "' + Var('<name>')". If there are no matches, nothing is done.
113 deps = re.sub(VARIFY_MARKER_TAG_PREFIX + '_(\w+)\'',
114 lambda match: '\' + Var(\'%s\')' % match.group(1), deps)
115 return deps 104 return deps
116 105
117 106
118 def WriteDeps(deps_file_name, deps_vars, deps, deps_os, include_rules, 107 def WriteDeps(deps_file_name, deps_vars, deps, deps_os, include_rules,
119 skip_child_includes, hooks): 108 skip_child_includes, hooks):
120 """Given all the sections in a DEPS file, write it to disk.""" 109 """Given all the sections in a DEPS file, write it to disk."""
121 new_deps = ('# DO NOT EDIT EXCEPT FOR LOCAL TESTING.\n' 110 new_deps = ('# DO NOT EDIT EXCEPT FOR LOCAL TESTING.\n'
122 '# THIS IS A GENERATED FILE.\n', 111 '# THIS IS A GENERATED FILE.\n',
123 '# ALL MANUAL CHANGES WILL BE OVERWRITTEN.\n', 112 '# ALL MANUAL CHANGES WILL BE OVERWRITTEN.\n',
124 '# SEE http://code.google.com/p/chromium/wiki/UsingGit\n', 113 '# SEE http://code.google.com/p/chromium/wiki/UsingGit\n',
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 # For POSIX: making the directory writable guarantees removability. 205 # For POSIX: making the directory writable guarantees removability.
217 # Windows will ignore the non-read-only bits in the chmod value. 206 # Windows will ignore the non-read-only bits in the chmod value.
218 os.chmod(root, 0770) 207 os.chmod(root, 0770)
219 for name in files: 208 for name in files:
220 remove_with_retry(os.remove, os.path.join(root, name)) 209 remove_with_retry(os.remove, os.path.join(root, name))
221 for name in dirs: 210 for name in dirs:
222 remove_with_retry(lambda p: shutil.rmtree(p, onerror=RmTreeOnError), 211 remove_with_retry(lambda p: shutil.rmtree(p, onerror=RmTreeOnError),
223 os.path.join(root, name)) 212 os.path.join(root, name))
224 213
225 remove_with_retry(os.rmdir, file_path) 214 remove_with_retry(os.rmdir, file_path)
OLDNEW
« no previous file with comments | « deps2git.py ('k') | svn_to_git_public.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698