Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env 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 """Moves C++ files to a new location, updating any include paths that point | 6 """Moves C++ files to a new location, updating any include paths that point |
| 7 to them, and re-ordering headers as needed. If multiple source files are | 7 to them, and re-ordering headers as needed. If multiple source files are |
| 8 specified, the destination must be a directory. Updates include guards in | 8 specified, the destination must be a directory. Updates include guards in |
| 9 moved header files. Assumes Chromium coding style. | 9 moved header files. Assumes Chromium coding style. |
| 10 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 def PathMinusFirstComponent(path): | 110 def PathMinusFirstComponent(path): |
| 111 """foo/bar/baz -> bar/baz""" | 111 """foo/bar/baz -> bar/baz""" |
| 112 parts = re.split(r"[/\\]", path, 1) | 112 parts = re.split(r"[/\\]", path, 1) |
| 113 if len(parts) == 2: | 113 if len(parts) == 2: |
| 114 return parts[1] | 114 return parts[1] |
| 115 else: | 115 else: |
| 116 return parts[0] | 116 return parts[0] |
| 117 mffr.MultiFileFindReplace( | 117 mffr.MultiFileFindReplace( |
| 118 r'([\'"])%s([\'"])' % re.escape(PathMinusFirstComponent(from_path)), | 118 r'([\'"])%s([\'"])' % re.escape(PathMinusFirstComponent(from_path)), |
| 119 r'\1%s\2' % PathMinusFirstComponent(to_path), | 119 r'\1%s\2' % PathMinusFirstComponent(to_path), |
| 120 ['*.gyp*']) | 120 ['*.gyp*', '*.gn']) |
|
Daniel Erat
2015/02/03 15:19:56
can this be BUILD.gn instead of *.gn? i think that
satorux1
2015/02/04 05:13:18
Good point. It had to be */BUILD.gn for git grep t
| |
| 121 | 121 |
| 122 | 122 |
| 123 def MakeIncludeGuardName(path_from_root): | 123 def MakeIncludeGuardName(path_from_root): |
| 124 """Returns an include guard name given a path from root.""" | 124 """Returns an include guard name given a path from root.""" |
| 125 guard = path_from_root.replace('/', '_') | 125 guard = path_from_root.replace('/', '_') |
| 126 guard = guard.replace('\\', '_') | 126 guard = guard.replace('\\', '_') |
| 127 guard = guard.replace('.', '_') | 127 guard = guard.replace('.', '_') |
| 128 guard += '_' | 128 guard += '_' |
| 129 return guard.upper() | 129 return guard.upper() |
| 130 | 130 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 continue | 189 continue |
| 190 to_path = MakeDestinationPath(from_path, orig_to_path) | 190 to_path = MakeDestinationPath(from_path, orig_to_path) |
| 191 if not opts.already_moved: | 191 if not opts.already_moved: |
| 192 MoveFile(from_path, to_path) | 192 MoveFile(from_path, to_path) |
| 193 UpdatePostMove(from_path, to_path) | 193 UpdatePostMove(from_path, to_path) |
| 194 return 0 | 194 return 0 |
| 195 | 195 |
| 196 | 196 |
| 197 if __name__ == '__main__': | 197 if __name__ == '__main__': |
| 198 sys.exit(main()) | 198 sys.exit(main()) |
| OLD | NEW |