| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 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 # On Android we build unit test bundles as shared libraries. To run | 7 # On Android we build unit test bundles as shared libraries. To run |
| 8 # tests, we launch a special "test runner" apk which loads the library | 8 # tests, we launch a special "test runner" apk which loads the library |
| 9 # then jumps into it. Since java is required for many tests | 9 # then jumps into it. Since java is required for many tests |
| 10 # (e.g. PathUtils.java), a "pure native" test bundle is inadequate. | 10 # (e.g. PathUtils.java), a "pure native" test bundle is inadequate. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 parser.add_option('--jars', | 155 parser.add_option('--jars', |
| 156 help='Space separated list of jars to be included') | 156 help='Space separated list of jars to be included') |
| 157 parser.add_option('--output', | 157 parser.add_option('--output', |
| 158 help='Output directory for generated files.') | 158 help='Output directory for generated files.') |
| 159 parser.add_option('--app_abi', default='armeabi', | 159 parser.add_option('--app_abi', default='armeabi', |
| 160 help='ABI for native shared library') | 160 help='ABI for native shared library') |
| 161 parser.add_option('--strip-binary', | 161 parser.add_option('--strip-binary', |
| 162 help='Binary to use for stripping the native libraries.') | 162 help='Binary to use for stripping the native libraries.') |
| 163 parser.add_option('--ant-args', action='append', | 163 parser.add_option('--ant-args', action='append', |
| 164 help='extra args for ant') | 164 help='extra args for ant') |
| 165 parser.add_option('--stamp-file', |
| 166 help='Path to file to touch on success.') |
| 167 parser.add_option('--no-compile', action='store_true', |
| 168 help='Use this flag to disable ant compilation.') |
| 165 | 169 |
| 166 options, _ = parser.parse_args(argv) | 170 options, _ = parser.parse_args(argv) |
| 167 | 171 |
| 168 # It is not an error to specify no native library; the apk should | 172 # It is not an error to specify no native library; the apk should |
| 169 # still be generated and build. It will, however, print | 173 # still be generated and build. It will, however, print |
| 170 # NATIVE_LOADER_FAILED when run. | 174 # NATIVE_LOADER_FAILED when run. |
| 171 if not options.output: | 175 if not options.output: |
| 172 raise Exception('No output directory specified for generated files') | 176 raise Exception('No output directory specified for generated files') |
| 173 | 177 |
| 174 if options.verbose: | 178 if options.verbose: |
| 175 logging.basicConfig(level=logging.DEBUG, format=' %(message)s') | 179 logging.basicConfig(level=logging.DEBUG, format=' %(message)s') |
| 176 | 180 |
| 177 if not options.strip_binary: | 181 if not options.strip_binary: |
| 178 options.strip_binary = os.getenv('STRIP') | 182 options.strip_binary = os.getenv('STRIP') |
| 179 if not options.strip_binary: | 183 if not options.strip_binary: |
| 180 raise Exception('No tool for stripping the libraries has been supplied') | 184 raise Exception('No tool for stripping the libraries has been supplied') |
| 181 | 185 |
| 182 # Remove all quotes from the jars string and pass the list to ant as | |
| 183 # INPUT_JARS_PATHS. | |
| 184 # TODO(cjhopman): Remove this when all targets pass the list of jars as an | |
| 185 # ant-arg directly. | |
| 186 jar_list = [] | |
| 187 if options.jars: | |
| 188 jar_list = options.jars.replace('"', '').split() | |
| 189 options.ant_args.append('-DINPUT_JARS_PATHS=' + " ".join(jar_list)) | |
| 190 | |
| 191 | |
| 192 ntag = NativeTestApkGenerator(native_library=options.native_library, | 186 ntag = NativeTestApkGenerator(native_library=options.native_library, |
| 193 strip_binary=options.strip_binary, | 187 strip_binary=options.strip_binary, |
| 194 output_directory=options.output, | 188 output_directory=options.output, |
| 195 target_abi=options.app_abi) | 189 target_abi=options.app_abi) |
| 190 |
| 196 ntag.CreateBundle() | 191 ntag.CreateBundle() |
| 197 ntag.Compile(options.ant_args) | 192 if not options.no_compile: |
| 193 ntag.Compile(options.ant_args) |
| 194 |
| 195 if options.stamp_file: |
| 196 with file(options.stamp_file, 'a'): |
| 197 os.utime(options.stamp_file, None) |
| 198 |
| 198 logging.info('COMPLETE.') | 199 logging.info('COMPLETE.') |
| 199 | 200 |
| 200 if __name__ == '__main__': | 201 if __name__ == '__main__': |
| 201 sys.exit(main(sys.argv)) | 202 sys.exit(main(sys.argv)) |
| OLD | NEW |