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

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

Issue 10383263: Add the target ABI option for apk based test runner (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix the conflict of AUTHORS again Created 8 years, 6 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/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 ] 44 ]
45 45
46 # Files in the destion directory that have a "replaceme" string 46 # Files in the destion directory that have a "replaceme" string
47 # which should be replaced by the basename of the shared library. 47 # which should be replaced by the basename of the shared library.
48 # Note we also update the filename if 'replaceme' is itself found in 48 # Note we also update the filename if 'replaceme' is itself found in
49 # the filename. 49 # the filename.
50 _REPLACEME_FILES = ['AndroidManifest.xml', 50 _REPLACEME_FILES = ['AndroidManifest.xml',
51 'native_test_apk.xml', 51 'native_test_apk.xml',
52 'res/values/strings.xml'] 52 'res/values/strings.xml']
53 53
54 def __init__(self, native_library, jars, output_directory): 54 def __init__(self, native_library, jars, output_directory, target_abi):
55 self._native_library = native_library 55 self._native_library = native_library
56 self._jars = jars 56 self._jars = jars
57 self._output_directory = output_directory 57 self._output_directory = output_directory
58 self._target_abi = target_abi
58 self._root_name = None 59 self._root_name = None
59 if self._native_library: 60 if self._native_library:
60 self._root_name = self._LibraryRoot() 61 self._root_name = self._LibraryRoot()
61 logging.warn('root name: %s' % self._root_name) 62 logging.warn('root name: %s' % self._root_name)
62 63
63 64
64 def _LibraryRoot(self): 65 def _LibraryRoot(self):
65 """Return a root name for a shared library. 66 """Return a root name for a shared library.
66 67
67 The root name should be suitable for substitution in apk files 68 The root name should be suitable for substitution in apk files
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 for f in self._REPLACEME_FILES: 113 for f in self._REPLACEME_FILES:
113 dest = os.path.join(self._output_directory, f) 114 dest = os.path.join(self._output_directory, f)
114 contents = open(dest).read() 115 contents = open(dest).read()
115 contents = contents.replace('replaceme', self._root_name) 116 contents = contents.replace('replaceme', self._root_name)
116 dest = dest.replace('replaceme', self._root_name) # update the filename! 117 dest = dest.replace('replaceme', self._root_name) # update the filename!
117 open(dest, "w").write(contents) 118 open(dest, "w").write(contents)
118 119
119 def _CopyLibraryAndJars(self): 120 def _CopyLibraryAndJars(self):
120 """Copy the shlib and jars into the apk source tree (if relevant)""" 121 """Copy the shlib and jars into the apk source tree (if relevant)"""
121 if self._native_library: 122 if self._native_library:
122 destdir = os.path.join(self._output_directory, 'libs/armeabi') 123 destdir = os.path.join(self._output_directory, 'libs/' + self._target_abi)
123 if not os.path.exists(destdir): 124 if not os.path.exists(destdir):
124 os.makedirs(destdir) 125 os.makedirs(destdir)
125 dest = os.path.join(destdir, os.path.basename(self._native_library)) 126 dest = os.path.join(destdir, os.path.basename(self._native_library))
126 logging.warn('strip %s --> %s' % (self._native_library, dest)) 127 logging.warn('strip %s --> %s' % (self._native_library, dest))
127 strip = os.environ['STRIP'] 128 strip = os.environ['STRIP']
128 cmd_helper.RunCmd( 129 cmd_helper.RunCmd(
129 [strip, '--strip-unneeded', self._native_library, '-o', dest]) 130 [strip, '--strip-unneeded', self._native_library, '-o', dest])
130 if self._jars: 131 if self._jars:
131 destdir = os.path.join(self._output_directory, 'libs') 132 destdir = os.path.join(self._output_directory, 'libs')
132 if not os.path.exists(destdir): 133 if not os.path.exists(destdir):
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 def main(argv): 166 def main(argv):
166 parser = optparse.OptionParser() 167 parser = optparse.OptionParser()
167 parser.add_option('--verbose', 168 parser.add_option('--verbose',
168 help='Be verbose') 169 help='Be verbose')
169 parser.add_option('--native_library', 170 parser.add_option('--native_library',
170 help='Full name of native shared library test bundle') 171 help='Full name of native shared library test bundle')
171 parser.add_option('--jars', 172 parser.add_option('--jars',
172 help='Space separated list of jars to be included') 173 help='Space separated list of jars to be included')
173 parser.add_option('--output', 174 parser.add_option('--output',
174 help='Output directory for generated files.') 175 help='Output directory for generated files.')
176 parser.add_option('--app_abi', default='armeabi',
177 help='ABI for native shared library')
175 parser.add_option('--ant-compile', action='store_true', 178 parser.add_option('--ant-compile', action='store_true',
176 help='If specified, build the generated apk with ant') 179 help='If specified, build the generated apk with ant')
177 parser.add_option('--ant-args', 180 parser.add_option('--ant-args',
178 help='extra args for ant') 181 help='extra args for ant')
179 182
180 options, _ = parser.parse_args(argv) 183 options, _ = parser.parse_args(argv)
181 184
182 # It is not an error to specify no native library; the apk should 185 # It is not an error to specify no native library; the apk should
183 # still be generated and build. It will, however, print 186 # still be generated and build. It will, however, print
184 # NATIVE_LOADER_FAILED when run. 187 # NATIVE_LOADER_FAILED when run.
185 if not options.output: 188 if not options.output:
186 raise Exception('No output directory specified for generated files') 189 raise Exception('No output directory specified for generated files')
187 190
188 if options.verbose: 191 if options.verbose:
189 logging.basicConfig(level=logging.DEBUG, format=' %(message)s') 192 logging.basicConfig(level=logging.DEBUG, format=' %(message)s')
190 193
191 # Remove all quotes from the jars string 194 # Remove all quotes from the jars string
192 jar_list = [] 195 jar_list = []
193 if options.jars: 196 if options.jars:
194 jar_list = options.jars.replace('"', '').split() 197 jar_list = options.jars.replace('"', '').split()
195 ntag = NativeTestApkGenerator(native_library=options.native_library, 198 ntag = NativeTestApkGenerator(native_library=options.native_library,
196 jars=jar_list, 199 jars=jar_list,
197 output_directory=options.output) 200 output_directory=options.output,
201 target_abi=options.app_abi)
198 ntag.CreateBundle() 202 ntag.CreateBundle()
199 if options.ant_compile: 203 if options.ant_compile:
200 ntag.Compile(options.ant_args) 204 ntag.Compile(options.ant_args)
201 205
202 logging.warn('COMPLETE.') 206 logging.warn('COMPLETE.')
203 207
204 if __name__ == '__main__': 208 if __name__ == '__main__':
205 sys.exit(main(sys.argv)) 209 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