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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 self._CopyLibraryAndJars() | 138 self._CopyLibraryAndJars() |
139 | 139 |
140 def Compile(self, ant_args): | 140 def Compile(self, ant_args): |
141 """Build the generated apk with ant. | 141 """Build the generated apk with ant. |
142 | 142 |
143 Args: | 143 Args: |
144 ant_args: extra args to pass to ant | 144 ant_args: extra args to pass to ant |
145 """ | 145 """ |
146 cmd = ['ant'] | 146 cmd = ['ant'] |
147 if ant_args: | 147 if ant_args: |
148 cmd.append(ant_args) | 148 cmd.extend(ant_args) |
149 cmd.append("-DAPP_ABI=" + self._target_abi) | 149 cmd.append("-DAPP_ABI=" + self._target_abi) |
150 cmd.extend(['-buildfile', | 150 cmd.extend(['-buildfile', |
151 os.path.join(self._output_directory, 'native_test_apk.xml')]) | 151 os.path.join(self._output_directory, 'native_test_apk.xml')]) |
152 logging.warn(cmd) | 152 logging.warn(cmd) |
153 p = subprocess.Popen(cmd, stderr=subprocess.STDOUT) | 153 p = subprocess.Popen(cmd, stderr=subprocess.STDOUT) |
154 (stdout, _) = p.communicate() | 154 (stdout, _) = p.communicate() |
155 logging.warn(stdout) | 155 logging.warn(stdout) |
156 if p.returncode != 0: | 156 if p.returncode != 0: |
157 logging.error('Ant return code %d', p.returncode) | 157 logging.error('Ant return code %d', p.returncode) |
158 sys.exit(p.returncode) | 158 sys.exit(p.returncode) |
(...skipping 23 matching lines...) Expand all Loading... |
182 help='ABI for native shared library') | 182 help='ABI for native shared library') |
183 parser.add_option('--sdk-build', type='int', default=1, | 183 parser.add_option('--sdk-build', type='int', default=1, |
184 help='Unless set to 0, build the generated apk with ant. ' | 184 help='Unless set to 0, build the generated apk with ant. ' |
185 'Otherwise assume compiling within the Android ' | 185 'Otherwise assume compiling within the Android ' |
186 'source tree using Android.mk.') | 186 'source tree using Android.mk.') |
187 # FIXME(beverloo): Remove --ant-compile when all users adopted. | 187 # FIXME(beverloo): Remove --ant-compile when all users adopted. |
188 parser.add_option('--ant-compile', action='store_true', | 188 parser.add_option('--ant-compile', action='store_true', |
189 help=('If specified, build the generated apk with ant. ' | 189 help=('If specified, build the generated apk with ant. ' |
190 'Otherwise assume compiling within the Android ' | 190 'Otherwise assume compiling within the Android ' |
191 'source tree using Android.mk.')) | 191 'source tree using Android.mk.')) |
192 parser.add_option('--ant-args', | 192 parser.add_option('--ant-args', action='append', |
193 help='extra args for ant') | 193 help='extra args for ant') |
194 | 194 |
195 options, _ = parser.parse_args(argv) | 195 options, _ = parser.parse_args(argv) |
196 | 196 |
197 # It is not an error to specify no native library; the apk should | 197 # It is not an error to specify no native library; the apk should |
198 # still be generated and build. It will, however, print | 198 # still be generated and build. It will, however, print |
199 # NATIVE_LOADER_FAILED when run. | 199 # NATIVE_LOADER_FAILED when run. |
200 if not options.output: | 200 if not options.output: |
201 raise Exception('No output directory specified for generated files') | 201 raise Exception('No output directory specified for generated files') |
202 | 202 |
(...skipping 13 matching lines...) Expand all Loading... |
216 | 216 |
217 if options.sdk_build or options.ant_compile: | 217 if options.sdk_build or options.ant_compile: |
218 ntag.Compile(options.ant_args) | 218 ntag.Compile(options.ant_args) |
219 else: | 219 else: |
220 ntag.CompileAndroidMk() | 220 ntag.CompileAndroidMk() |
221 | 221 |
222 logging.warn('COMPLETE.') | 222 logging.warn('COMPLETE.') |
223 | 223 |
224 if __name__ == '__main__': | 224 if __name__ == '__main__': |
225 sys.exit(main(sys.argv)) | 225 sys.exit(main(sys.argv)) |
OLD | NEW |