| 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 """ Creates a zip file in the staging dir with the result of a compile. | 6 """ Creates a zip file in the staging dir with the result of a compile. |
| 7 It can be sent to other machines for testing. | 7 It can be sent to other machines for testing. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import csv | 10 import csv |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return r'^.+\.(a)$' | 134 return r'^.+\.(a)$' |
| 135 else: | 135 else: |
| 136 return r'^.+\.(a|dSYM)$' | 136 return r'^.+\.(a|dSYM)$' |
| 137 if chromium_utils.IsLinux(): | 137 if chromium_utils.IsLinux(): |
| 138 # object files, archives, and gcc (make build) dependency info. | 138 # object files, archives, and gcc (make build) dependency info. |
| 139 return r'^.+\.(o|a|d)$' | 139 return r'^.+\.(o|a|d)$' |
| 140 | 140 |
| 141 return '$NO_FILTER^' | 141 return '$NO_FILTER^' |
| 142 | 142 |
| 143 | 143 |
| 144 def MojomJSFiles(build_dir): | 144 def _MojomFiles(build_dir, suffixes): |
| 145 """Lists all mojom JavaScript files that need to be included in the archive. | 145 """Lists all mojom files that need to be included in the archive. |
| 146 | 146 |
| 147 Args: | 147 Args: |
| 148 build_dir: The build directory. | 148 build_dir: The build directory. |
| 149 | 149 |
| 150 Returns: | 150 Returns: |
| 151 A list of mojom JavaScript file paths which are relative to the build | 151 A list of mojom file paths which are relative to the build |
| 152 directory. | 152 directory. |
| 153 """ | 153 """ |
| 154 walk_dirs = [ | 154 walk_dirs = [ |
| 155 'gen/mojo', | 155 'gen/mojo', |
| 156 'gen/content/test/data', | 156 'gen/content/test/data', |
| 157 ] | 157 ] |
| 158 mojom_js_files = [] | 158 mojom_files = [] |
| 159 for walk_dir in walk_dirs: | 159 for walk_dir in walk_dirs: |
| 160 walk_dir = os.path.join(build_dir, walk_dir) | 160 walk_dir = os.path.join(build_dir, walk_dir) |
| 161 for path, _, files in os.walk(walk_dir): | 161 for path, _, files in os.walk(walk_dir): |
| 162 rel_path = os.path.relpath(path, build_dir) | 162 rel_path = os.path.relpath(path, build_dir) |
| 163 for mojom_js_file in fnmatch.filter(files, '*.mojom.js'): | 163 for suffix in suffixes or []: |
| 164 mojom_js_files.append(os.path.join(rel_path, mojom_js_file)) | 164 for mojom_file in fnmatch.filter(files, '*%s' % suffix): |
| 165 return mojom_js_files | 165 mojom_files.append(os.path.join(rel_path, mojom_file)) |
| 166 return mojom_files |
| 166 | 167 |
| 167 | 168 |
| 168 def WriteRevisionFile(dirname, build_revision): | 169 def WriteRevisionFile(dirname, build_revision): |
| 169 """Writes a file containing revision number to given directory. | 170 """Writes a file containing revision number to given directory. |
| 170 Replaces the target file in place. | 171 Replaces the target file in place. |
| 171 | 172 |
| 172 Args: | 173 Args: |
| 173 dirname: Directory to write the file in. | 174 dirname: Directory to write the file in. |
| 174 build_revision: Revision number or hash. | 175 build_revision: Revision number or hash. |
| 175 | 176 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 365 |
| 365 path_filter = PathMatcher(options) | 366 path_filter = PathMatcher(options) |
| 366 print path_filter | 367 print path_filter |
| 367 print ('\nActually excluded: %s' % | 368 print ('\nActually excluded: %s' % |
| 368 [f for f in root_files if not path_filter.Match(f)]) | 369 [f for f in root_files if not path_filter.Match(f)]) |
| 369 | 370 |
| 370 zip_file_list = [f for f in root_files if path_filter.Match(f)] | 371 zip_file_list = [f for f in root_files if path_filter.Match(f)] |
| 371 | 372 |
| 372 # TODO(yzshen): Once we have swarming support ready, we could use it to | 373 # TODO(yzshen): Once we have swarming support ready, we could use it to |
| 373 # archive run time dependencies of tests and remove this step. | 374 # archive run time dependencies of tests and remove this step. |
| 374 mojom_js_files = MojomJSFiles(build_dir) | 375 mojom_files = _MojomFiles(build_dir, ['.mojom.js', '_mojom.py']) |
| 375 print 'Include mojom JavaScript files: %s' % mojom_js_files | 376 print 'Include mojom files: %s' % mojom_files |
| 376 zip_file_list.extend(mojom_js_files) | 377 zip_file_list.extend(mojom_files) |
| 377 | 378 |
| 378 zip_file = MakeUnversionedArchive(build_dir, staging_dir, zip_file_list, | 379 zip_file = MakeUnversionedArchive(build_dir, staging_dir, zip_file_list, |
| 379 unversioned_base_name, options.path_filter) | 380 unversioned_base_name, options.path_filter) |
| 380 | 381 |
| 381 zip_base, zip_ext, versioned_file = MakeVersionedArchive( | 382 zip_base, zip_ext, versioned_file = MakeVersionedArchive( |
| 382 zip_file, version_suffix, options) | 383 zip_file, version_suffix, options) |
| 383 | 384 |
| 384 prune_limit = max(0, int(options.factory_properties.get('prune_limit', 10))) | 385 prune_limit = max(0, int(options.factory_properties.get('prune_limit', 10))) |
| 385 PruneOldArchives(staging_dir, zip_base, zip_ext, prune_limit=prune_limit) | 386 PruneOldArchives(staging_dir, zip_base, zip_ext, prune_limit=prune_limit) |
| 386 | 387 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 466 |
| 466 if options.path_filter: | 467 if options.path_filter: |
| 467 options.path_filter = PATH_FILTERS[options.path_filter]( | 468 options.path_filter = PATH_FILTERS[options.path_filter]( |
| 468 build_directory.GetBuildOutputDirectory(), options.target) | 469 build_directory.GetBuildOutputDirectory(), options.target) |
| 469 | 470 |
| 470 return Archive(options) | 471 return Archive(options) |
| 471 | 472 |
| 472 | 473 |
| 473 if '__main__' == __name__: | 474 if '__main__' == __name__: |
| 474 sys.exit(main(sys.argv)) | 475 sys.exit(main(sys.argv)) |
| OLD | NEW |