| 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 """ | 6 """ |
| 7 This tool creates a tarball with all the sources, but without .svn directories. | 7 This tool creates a tarball with all the sources, but without .svn directories. |
| 8 | 8 |
| 9 It can also remove files which are not strictly required for build, so that | 9 It can also remove files which are not strictly required for build, so that |
| 10 the resulting tarball can be reasonably small (last time it was ~110 MB). | 10 the resulting tarball can be reasonably small (last time it was ~110 MB). |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 'webkit/tools/test/reference_build', | 67 'webkit/tools/test/reference_build', |
| 68 ) | 68 ) |
| 69 | 69 |
| 70 TESTDIRS = ( | 70 TESTDIRS = ( |
| 71 'chrome/test/data', | 71 'chrome/test/data', |
| 72 'content/test/data', | 72 'content/test/data', |
| 73 'media/test/data', | 73 'media/test/data', |
| 74 'net/data', | 74 'net/data', |
| 75 ) | 75 ) |
| 76 | 76 |
| 77 PRUNEDDIRS = ( | |
| 78 'courgette', | |
| 79 ) | |
| 80 | |
| 81 | 77 |
| 82 def GetSourceDirectory(): | 78 def GetSourceDirectory(): |
| 83 return os.path.realpath( | 79 return os.path.realpath( |
| 84 os.path.join(os.path.dirname(__file__), '..', '..', '..', 'src')) | 80 os.path.join(os.path.dirname(__file__), '..', '..', '..', 'src')) |
| 85 | 81 |
| 86 | 82 |
| 87 # Workaround lack of the exclude parameter in add method in python-2.4. | 83 # Workaround lack of the exclude parameter in add method in python-2.4. |
| 88 # TODO(phajdan.jr): remove the workaround when it's not needed on the bot. | 84 # TODO(phajdan.jr): remove the workaround when it's not needed on the bot. |
| 89 class MyTarFile(tarfile.TarFile): | 85 class MyTarFile(tarfile.TarFile): |
| 90 def set_remove_nonessential_files(self, remove): | 86 def set_remove_nonessential_files(self, remove): |
| 91 self.__remove_nonessential_files = remove | 87 self.__remove_nonessential_files = remove |
| 92 | 88 |
| 93 def add(self, name, arcname=None, recursive=True, exclude=None, filter=None): | 89 def add(self, name, arcname=None, recursive=True, exclude=None, filter=None): |
| 94 head, tail = os.path.split(name) | 90 head, tail = os.path.split(name) |
| 95 if tail in ('.svn', '.git'): | 91 if tail in ('.svn', '.git'): |
| 96 return | 92 return |
| 97 | 93 |
| 98 if self.__remove_nonessential_files: | 94 if self.__remove_nonessential_files: |
| 99 # WebKit change logs take quite a lot of space. This saves ~10 MB | 95 # WebKit change logs take quite a lot of space. This saves ~10 MB |
| 100 # in a bzip2-compressed tarball. | 96 # in a bzip2-compressed tarball. |
| 101 if 'ChangeLog' in name: | 97 if 'ChangeLog' in name: |
| 102 return | 98 return |
| 103 | 99 |
| 104 # Remove contents of non-essential directories, but preserve gyp files, | 100 # Remove contents of non-essential directories, but preserve gyp files, |
| 105 # so that build/gyp_chromium can work. | 101 # so that build/gyp_chromium can work. |
| 106 for nonessential_dir in (NONESSENTIAL_DIRS + TESTDIRS + PRUNEDDIRS): | 102 for nonessential_dir in (NONESSENTIAL_DIRS + TESTDIRS): |
| 107 dir_path = os.path.join(GetSourceDirectory(), nonessential_dir) | 103 dir_path = os.path.join(GetSourceDirectory(), nonessential_dir) |
| 108 if (name.startswith(dir_path) and | 104 if (name.startswith(dir_path) and |
| 109 os.path.isfile(name) and | 105 os.path.isfile(name) and |
| 110 'gyp' not in name): | 106 'gyp' not in name): |
| 111 return | 107 return |
| 112 | 108 |
| 113 tarfile.TarFile.add(self, name, arcname=arcname, recursive=recursive) | 109 tarfile.TarFile.add(self, name, arcname=arcname, recursive=recursive) |
| 114 | 110 |
| 115 | 111 |
| 116 def main(argv): | 112 def main(argv): |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 159 |
| 164 if subprocess.call(['xz', '-9', output_fullname]) != 0: | 160 if subprocess.call(['xz', '-9', output_fullname]) != 0: |
| 165 print 'xz -9 failed!' | 161 print 'xz -9 failed!' |
| 166 return 1 | 162 return 1 |
| 167 | 163 |
| 168 return 0 | 164 return 0 |
| 169 | 165 |
| 170 | 166 |
| 171 if __name__ == "__main__": | 167 if __name__ == "__main__": |
| 172 sys.exit(main(sys.argv[1:])) | 168 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |