| 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 _MojomFiles(build_dir, suffixes): | 144 def MojomJSFiles(build_dir): |
| 145 """Lists all mojom files that need to be included in the archive. | 145 """Lists all mojom JavaScript 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 file paths which are relative to the build | 151 A list of mojom JavaScript 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_files = [] | 158 mojom_js_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 suffix in suffixes or []: | 163 for mojom_js_file in fnmatch.filter(files, '*.mojom.js'): |
| 164 for mojom_file in fnmatch.filter(files, '*%s' % suffix): | 164 mojom_js_files.append(os.path.join(rel_path, mojom_js_file)) |
| 165 mojom_files.append(os.path.join(rel_path, mojom_file)) | 165 return mojom_js_files |
| 166 return mojom_files | |
| 167 | 166 |
| 168 | 167 |
| 169 def WriteRevisionFile(dirname, build_revision): | 168 def WriteRevisionFile(dirname, build_revision): |
| 170 """Writes a file containing revision number to given directory. | 169 """Writes a file containing revision number to given directory. |
| 171 Replaces the target file in place. | 170 Replaces the target file in place. |
| 172 | 171 |
| 173 Args: | 172 Args: |
| 174 dirname: Directory to write the file in. | 173 dirname: Directory to write the file in. |
| 175 build_revision: Revision number or hash. | 174 build_revision: Revision number or hash. |
| 176 | 175 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 365 |
| 367 path_filter = PathMatcher(options) | 366 path_filter = PathMatcher(options) |
| 368 print path_filter | 367 print path_filter |
| 369 print ('\nActually excluded: %s' % | 368 print ('\nActually excluded: %s' % |
| 370 [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)]) |
| 371 | 370 |
| 372 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)] |
| 373 | 372 |
| 374 # 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 |
| 375 # archive run time dependencies of tests and remove this step. | 374 # archive run time dependencies of tests and remove this step. |
| 376 mojom_files = _MojomFiles(build_dir, ['.mojom.js', '_mojom.py']) | 375 mojom_js_files = MojomJSFiles(build_dir) |
| 377 print 'Include mojom files: %s' % mojom_files | 376 print 'Include mojom JavaScript files: %s' % mojom_js_files |
| 378 zip_file_list.extend(mojom_files) | 377 zip_file_list.extend(mojom_js_files) |
| 379 | 378 |
| 380 zip_file = MakeUnversionedArchive(build_dir, staging_dir, zip_file_list, | 379 zip_file = MakeUnversionedArchive(build_dir, staging_dir, zip_file_list, |
| 381 unversioned_base_name, options.path_filter) | 380 unversioned_base_name, options.path_filter) |
| 382 | 381 |
| 383 zip_base, zip_ext, versioned_file = MakeVersionedArchive( | 382 zip_base, zip_ext, versioned_file = MakeVersionedArchive( |
| 384 zip_file, version_suffix, options) | 383 zip_file, version_suffix, options) |
| 385 | 384 |
| 386 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))) |
| 387 PruneOldArchives(staging_dir, zip_base, zip_ext, prune_limit=prune_limit) | 386 PruneOldArchives(staging_dir, zip_base, zip_ext, prune_limit=prune_limit) |
| 388 | 387 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 if options.path_filter: | 471 if options.path_filter: |
| 473 options.path_filter = PATH_FILTERS[options.path_filter]( | 472 options.path_filter = PATH_FILTERS[options.path_filter]( |
| 474 build_directory.GetBuildOutputDirectory(cros_board=options.cros_board), | 473 build_directory.GetBuildOutputDirectory(cros_board=options.cros_board), |
| 475 options.target) | 474 options.target) |
| 476 | 475 |
| 477 return Archive(options) | 476 return Archive(options) |
| 478 | 477 |
| 479 | 478 |
| 480 if '__main__' == __name__: | 479 if '__main__' == __name__: |
| 481 sys.exit(main(sys.argv)) | 480 sys.exit(main(sys.argv)) |
| OLD | NEW |