| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/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 # On Android we build unit test bundles as shared libraries. To run | 6 # On Android we build unit test bundles as shared libraries. To run |
| 7 # tests, we launch a special "test runner" apk which loads the library | 7 # tests, we launch a special "test runner" apk which loads the library |
| 8 # then jumps into it. Since java is required for many tests | 8 # then jumps into it. Since java is required for many tests |
| 9 # (e.g. PathUtils.java), a "pure native" test bundle is inadequate. | 9 # (e.g. PathUtils.java), a "pure native" test bundle is inadequate. |
| 10 # | 10 # |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 logging.error('Ant return code %d' % p.returncode) | 161 logging.error('Ant return code %d' % p.returncode) |
| 162 sys.exit(p.returncode) | 162 sys.exit(p.returncode) |
| 163 | 163 |
| 164 | 164 |
| 165 def main(argv): | 165 def main(argv): |
| 166 parser = optparse.OptionParser() | 166 parser = optparse.OptionParser() |
| 167 parser.add_option('--verbose', | 167 parser.add_option('--verbose', |
| 168 help='Be verbose') | 168 help='Be verbose') |
| 169 parser.add_option('--native_library', | 169 parser.add_option('--native_library', |
| 170 help='Full name of native shared library test bundle') | 170 help='Full name of native shared library test bundle') |
| 171 parser.add_option('--jar', action='append', | 171 parser.add_option('--jars', |
| 172 help='Include this jar; can be specified multiple times') | 172 help='Space separated list of jars to be included') |
| 173 parser.add_option('--output', | 173 parser.add_option('--output', |
| 174 help='Output directory for generated files.') | 174 help='Output directory for generated files.') |
| 175 parser.add_option('--ant-compile', action='store_true', | 175 parser.add_option('--ant-compile', action='store_true', |
| 176 help='If specified, build the generated apk with ant') | 176 help='If specified, build the generated apk with ant') |
| 177 parser.add_option('--ant-args', | 177 parser.add_option('--ant-args', |
| 178 help='extra args for ant') | 178 help='extra args for ant') |
| 179 | 179 |
| 180 options, _ = parser.parse_args(argv) | 180 options, _ = parser.parse_args(argv) |
| 181 | 181 |
| 182 # It is not an error to specify no native library; the apk should | 182 # It is not an error to specify no native library; the apk should |
| 183 # still be generated and build. It will, however, print | 183 # still be generated and build. It will, however, print |
| 184 # NATIVE_LOADER_FAILED when run. | 184 # NATIVE_LOADER_FAILED when run. |
| 185 if not options.output: | 185 if not options.output: |
| 186 raise Exception('No output directory specified for generated files') | 186 raise Exception('No output directory specified for generated files') |
| 187 | 187 |
| 188 if options.verbose: | 188 if options.verbose: |
| 189 logging.basicConfig(level=logging.DEBUG, format=' %(message)s') | 189 logging.basicConfig(level=logging.DEBUG, format=' %(message)s') |
| 190 | 190 |
| 191 # Remove all quotes from the jars string |
| 192 jar_list = [] |
| 193 if options.jars: |
| 194 jar_list = options.jars.replace('"', '').split() |
| 191 ntag = NativeTestApkGenerator(native_library=options.native_library, | 195 ntag = NativeTestApkGenerator(native_library=options.native_library, |
| 192 jars=options.jar, | 196 jars=jar_list, |
| 193 output_directory=options.output) | 197 output_directory=options.output) |
| 194 ntag.CreateBundle() | 198 ntag.CreateBundle() |
| 195 if options.ant_compile: | 199 if options.ant_compile: |
| 196 ntag.Compile(options.ant_args) | 200 ntag.Compile(options.ant_args) |
| 197 | 201 |
| 198 logging.warn('COMPLETE.') | 202 logging.warn('COMPLETE.') |
| 199 | 203 |
| 200 if __name__ == '__main__': | 204 if __name__ == '__main__': |
| 201 sys.exit(main(sys.argv)) | 205 sys.exit(main(sys.argv)) |
| OLD | NEW |