diff options
author | satorux <satorux@chromium.org> | 2015-02-17 17:03:22 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-18 01:03:48 +0000 |
commit | b2f5702078dae0737d9e0f3841e30c5c5f16b8d5 (patch) | |
tree | 096ab75c27bdcc9e2a0936c1796a17c7082240a3 /tools/git | |
parent | d3ce5e2fd64397e0b461f96cffd836a88130f142 (diff) | |
download | chromium_src-b2f5702078dae0737d9e0f3841e30c5c5f16b8d5.zip chromium_src-b2f5702078dae0737d9e0f3841e30c5c5f16b8d5.tar.gz chromium_src-b2f5702078dae0737d9e0f3841e30c5c5f16b8d5.tar.bz2 |
move_source_file.py: Handle GYP files in deeper directories.
Previously, the script assumed that GYP files are located under
the first level directory (ex. chrome/chrome_browser.gypi), but
there are GYP files located in directories at a deeper level
(ex. extensions/shell/app_shell.gypi). The change is to handle
these GYP files correctly.
BUG=404616
TEST=1) rename files under extensions/shell with git mv
2) run tools/git/mass-rename.sh
3) confirm that extensions/shell/app_shell.gypi is updated
Review URL: https://codereview.chromium.org/935483002
Cr-Commit-Position: refs/heads/master@{#316720}
Diffstat (limited to 'tools/git')
-rwxr-xr-x | tools/git/move_source_file.py | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/tools/git/move_source_file.py b/tools/git/move_source_file.py index b5496fd..1a25e44 100755 --- a/tools/git/move_source_file.py +++ b/tools/git/move_source_file.py @@ -106,36 +106,27 @@ def UpdatePostMove(from_path, to_path): r'\1%s' % to_path, ['*.cc', '*.h', '*.m', '*.mm', '*.cpp']) - # Update references in .gyp(i) files. - def PathMinusFirstComponent(path): - """foo/bar/baz -> bar/baz""" - parts = re.split(r"[/\\]", path, 1) - if len(parts) == 2: - return parts[1] - else: - return parts[0] - mffr.MultiFileFindReplace( - r'([\'"])%s([\'"])' % re.escape(PathMinusFirstComponent(from_path)), - r'\1%s\2' % PathMinusFirstComponent(to_path), - ['*.gyp*']) - - # Update references in BUILD.gn files. + # Update references in GYP and BUILD.gn files. + # + # GYP files are mostly located under the first level directory (ex. + # chrome/chrome_browser.gypi), but sometimes they are located in + # directories at a deeper level (ex. extensions/shell/app_shell.gypi). On + # the other hand, BUILD.gn files can be placed in any directories. # - # Unlike .gyp(i) files, BUILD.gn files can be placed in any directories, - # and paths in a BUILD.gn file are relative to the directory where the - # BUILD.gn file is placed. + # Paths in a GYP or BUILD.gn file are relative to the directory where the + # file is placed. # # For instance, "chrome/browser/chromeos/device_uma.h" is listed as # "browser/chromeos/device_uma.h" in "chrome/chrome_browser_chromeos.gypi", # but it's listed as "device_uma.h" in "chrome/browser/chromeos/BUILD.gn". # # To handle this, the code here will visit directories from the top level - # src directory to the directory of |from_path| and try to update BUILD.gn - # in each directory. + # src directory to the directory of |from_path| and try to update GYP and + # BUILD.gn files in each directory. # - # The code only handles files moved/renamed within the same BUILD.gn - # file. If files are moved beyond the same BUILD.gn file, the affected - # BUILD.gn files should be fixed manually. + # The code only handles files moved/renamed within the same build file. If + # files are moved beyond the same build file, the affected build files + # should be fixed manually. def SplitByFirstComponent(path): """'foo/bar/baz' -> ('foo', 'bar/baz') 'bar' -> ('bar', '') @@ -154,7 +145,8 @@ def UpdatePostMove(from_path, to_path): mffr.MultiFileFindReplace( r'([\'"])%s([\'"])' % from_rest, r'\1%s\2' % to_rest, - [os.path.join(visiting_directory, 'BUILD.gn')]) + [os.path.join(visiting_directory, 'BUILD.gn'), + os.path.join(visiting_directory, '*.gyp*')]) from_first, from_rest = SplitByFirstComponent(from_rest) to_first, to_rest = SplitByFirstComponent(to_rest) visiting_directory = os.path.join(visiting_directory, from_first) |