Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: testing/android/generate_native_test.py

Issue 10855147: Remove uses of Android's test runner's --ant-compile, as well as the flag itself. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/apk_test.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)
159 159
160 def CompileAndroidMk(self): 160 def CompileAndroidMk(self):
161 """Build the generated apk within Android source tree using Android.mk.""" 161 """Build the generated apk within Android source tree using Android.mk."""
162 try: 162 try:
163 import compile_android_mk # pylint: disable=F0401 163 import compile_android_mk # pylint: disable=F0401
164 except: 164 except:
165 raise AssertionError('Not in Android source tree. ' 165 raise AssertionError('Not in Android source tree. '
166 'Please use --ant-compile.') 166 'Please use --sdk-build.')
167 compile_android_mk.CompileAndroidMk(self._native_library, 167 compile_android_mk.CompileAndroidMk(self._native_library,
168 self._output_directory) 168 self._output_directory)
169 169
170 170
171 def main(argv): 171 def main(argv):
172 parser = optparse.OptionParser() 172 parser = optparse.OptionParser()
173 parser.add_option('--verbose', 173 parser.add_option('--verbose',
174 help='Be verbose') 174 help='Be verbose')
175 parser.add_option('--native_library', 175 parser.add_option('--native_library',
176 help='Full name of native shared library test bundle') 176 help='Full name of native shared library test bundle')
177 parser.add_option('--jars', 177 parser.add_option('--jars',
178 help='Space separated list of jars to be included') 178 help='Space separated list of jars to be included')
179 parser.add_option('--output', 179 parser.add_option('--output',
180 help='Output directory for generated files.') 180 help='Output directory for generated files.')
181 parser.add_option('--app_abi', default='armeabi', 181 parser.add_option('--app_abi', default='armeabi',
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.
188 parser.add_option('--ant-compile', action='store_true',
189 help=('If specified, build the generated apk with ant. '
190 'Otherwise assume compiling within the Android '
191 'source tree using Android.mk.'))
192 parser.add_option('--ant-args', action='append', 187 parser.add_option('--ant-args', action='append',
193 help='extra args for ant') 188 help='extra args for ant')
194 189
195 options, _ = parser.parse_args(argv) 190 options, _ = parser.parse_args(argv)
196 191
197 # It is not an error to specify no native library; the apk should 192 # It is not an error to specify no native library; the apk should
198 # still be generated and build. It will, however, print 193 # still be generated and build. It will, however, print
199 # NATIVE_LOADER_FAILED when run. 194 # NATIVE_LOADER_FAILED when run.
200 if not options.output: 195 if not options.output:
201 raise Exception('No output directory specified for generated files') 196 raise Exception('No output directory specified for generated files')
202 197
203 if options.verbose: 198 if options.verbose:
204 logging.basicConfig(level=logging.DEBUG, format=' %(message)s') 199 logging.basicConfig(level=logging.DEBUG, format=' %(message)s')
205 200
206 # Remove all quotes from the jars string 201 # Remove all quotes from the jars string
207 jar_list = [] 202 jar_list = []
208 if options.jars: 203 if options.jars:
209 jar_list = options.jars.replace('"', '').split() 204 jar_list = options.jars.replace('"', '').split()
210 205
211 ntag = NativeTestApkGenerator(native_library=options.native_library, 206 ntag = NativeTestApkGenerator(native_library=options.native_library,
212 jars=jar_list, 207 jars=jar_list,
213 output_directory=options.output, 208 output_directory=options.output,
214 target_abi=options.app_abi) 209 target_abi=options.app_abi)
215 ntag.CreateBundle(options.sdk_build or options.ant_compile) 210 ntag.CreateBundle(options.sdk_build)
216 211
217 if options.sdk_build or options.ant_compile: 212 if options.sdk_build:
218 ntag.Compile(options.ant_args) 213 ntag.Compile(options.ant_args)
219 else: 214 else:
220 ntag.CompileAndroidMk() 215 ntag.CompileAndroidMk()
221 216
222 logging.warn('COMPLETE.') 217 logging.warn('COMPLETE.')
223 218
224 if __name__ == '__main__': 219 if __name__ == '__main__':
225 sys.exit(main(sys.argv)) 220 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/apk_test.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698