| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import optparse | 7 import optparse |
| 8 import os | 8 import os |
| 9 import shutil | 9 import shutil |
| 10 import sys | 10 import sys |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 provider_configurations=provider_configurations, | 70 provider_configurations=provider_configurations, |
| 71 additional_files=additional_files) | 71 additional_files=additional_files) |
| 72 | 72 |
| 73 | 73 |
| 74 def main(): | 74 def main(): |
| 75 parser = optparse.OptionParser() | 75 parser = optparse.OptionParser() |
| 76 parser.add_option('--classes-dir', help='Directory containing .class files.') | 76 parser.add_option('--classes-dir', help='Directory containing .class files.') |
| 77 parser.add_option('--input-jar', help='Jar to include .class files from') | 77 parser.add_option('--input-jar', help='Jar to include .class files from') |
| 78 parser.add_option('--jar-path', help='Jar output path.') | 78 parser.add_option('--jar-path', help='Jar output path.') |
| 79 parser.add_option('--excluded-classes', | 79 parser.add_option('--excluded-classes', |
| 80 help='GYP list of .class file patterns to exclude from the jar.') | 80 help='GN list of .class file patterns to exclude from the jar.') |
| 81 parser.add_option('--strip-resource-classes-for', | 81 parser.add_option('--strip-resource-classes-for', |
| 82 help='GYP list of java package names exclude R.class files in.') | 82 help='GN list of java package names exclude R.class files in.') |
| 83 parser.add_option('--stamp', help='Path to touch on success.') | 83 parser.add_option('--stamp', help='Path to touch on success.') |
| 84 | 84 |
| 85 args = build_utils.ExpandFileArgs(sys.argv[1:]) | 85 args = build_utils.ExpandFileArgs(sys.argv[1:]) |
| 86 options, _ = parser.parse_args(args) | 86 options, _ = parser.parse_args(args) |
| 87 # Current implementation supports just one or the other of these: | 87 # Current implementation supports just one or the other of these: |
| 88 assert not options.classes_dir or not options.input_jar | 88 assert not options.classes_dir or not options.input_jar |
| 89 | 89 |
| 90 excluded_classes = [] | 90 excluded_classes = [] |
| 91 if options.excluded_classes: | 91 if options.excluded_classes: |
| 92 excluded_classes = build_utils.ParseGypList(options.excluded_classes) | 92 excluded_classes = build_utils.ParseGnList(options.excluded_classes) |
| 93 | 93 |
| 94 if options.strip_resource_classes_for: | 94 if options.strip_resource_classes_for: |
| 95 packages = build_utils.ParseGypList(options.strip_resource_classes_for) | 95 packages = build_utils.ParseGnList(options.strip_resource_classes_for) |
| 96 excluded_classes.extend(p.replace('.', '/') + '/' + f | 96 excluded_classes.extend(p.replace('.', '/') + '/' + f |
| 97 for p in packages for f in _RESOURCE_CLASSES) | 97 for p in packages for f in _RESOURCE_CLASSES) |
| 98 | 98 |
| 99 predicate = None | 99 predicate = None |
| 100 if excluded_classes: | 100 if excluded_classes: |
| 101 predicate = lambda f: not build_utils.MatchesGlob(f, excluded_classes) | 101 predicate = lambda f: not build_utils.MatchesGlob(f, excluded_classes) |
| 102 | 102 |
| 103 with build_utils.TempDir() as temp_dir: | 103 with build_utils.TempDir() as temp_dir: |
| 104 classes_dir = options.classes_dir | 104 classes_dir = options.classes_dir |
| 105 if options.input_jar: | 105 if options.input_jar: |
| 106 build_utils.ExtractAll(options.input_jar, temp_dir) | 106 build_utils.ExtractAll(options.input_jar, temp_dir) |
| 107 classes_dir = temp_dir | 107 classes_dir = temp_dir |
| 108 JarDirectory(classes_dir, options.jar_path, predicate=predicate) | 108 JarDirectory(classes_dir, options.jar_path, predicate=predicate) |
| 109 | 109 |
| 110 if options.stamp: | 110 if options.stamp: |
| 111 build_utils.Touch(options.stamp) | 111 build_utils.Touch(options.stamp) |
| 112 | 112 |
| 113 | 113 |
| 114 if __name__ == '__main__': | 114 if __name__ == '__main__': |
| 115 sys.exit(main()) | 115 sys.exit(main()) |
| 116 | 116 |
| OLD | NEW |