| Index: testing/android/generate_native_test.py
|
| diff --git a/testing/android/generate_native_test.py b/testing/android/generate_native_test.py
|
| index bd7c136b68e5927d1bceda07be8c5312e200d017..a72dcd7344bf86c8924d9317cb6f935cfc66b593 100755
|
| --- a/testing/android/generate_native_test.py
|
| +++ b/testing/android/generate_native_test.py
|
| @@ -136,8 +136,11 @@ class NativeTestApkGenerator(object):
|
| logging.warn('%s --> %s' % (jar, dest))
|
| shutil.copyfile(jar, dest)
|
|
|
| - def CreateBundle(self):
|
| + def CreateBundle(self, ant_compile):
|
| """Create the apk bundle source and assemble components."""
|
| + if not ant_compile:
|
| + self._SOURCE_FILES.append('Android.mk')
|
| + self._REPLACEME_FILES.append('Android.mk')
|
| self._CopyTemplateFiles()
|
| self._ReplaceStrings()
|
| self._CopyLibraryAndJars()
|
| @@ -161,6 +164,16 @@ class NativeTestApkGenerator(object):
|
| logging.error('Ant return code %d' % p.returncode)
|
| sys.exit(p.returncode)
|
|
|
| + def CompileAndroidMk(self):
|
| + """Build the generated apk within Android source tree using Android.mk."""
|
| + try:
|
| + import compile_android_mk # pylint: disable=F0401
|
| + except:
|
| + raise AssertionError('Not in Android source tree. '
|
| + 'Please use --ant-compile.')
|
| + compile_android_mk.CompileAndroidMk(self._native_library,
|
| + self._output_directory)
|
| +
|
|
|
| def main(argv):
|
| parser = optparse.OptionParser()
|
| @@ -173,7 +186,9 @@ def main(argv):
|
| parser.add_option('--output',
|
| help='Output directory for generated files.')
|
| parser.add_option('--ant-compile', action='store_true',
|
| - help='If specified, build the generated apk with ant')
|
| + help='If specified, build the generated apk with ant. '
|
| + 'Otherwise assume compiling within the Android '
|
| + 'source tree using Android.mk.')
|
| parser.add_option('--ant-args',
|
| help='extra args for ant')
|
|
|
| @@ -192,12 +207,20 @@ def main(argv):
|
| jar_list = []
|
| if options.jars:
|
| jar_list = options.jars.replace('"', '').split()
|
| +
|
| + # Ignore --ant-compile when building with Android source.
|
| + if 'ANDROID_BUILD_TOP' in os.environ:
|
| + options.ant_compile = False
|
| +
|
| ntag = NativeTestApkGenerator(native_library=options.native_library,
|
| jars=jar_list,
|
| output_directory=options.output)
|
| - ntag.CreateBundle()
|
| + ntag.CreateBundle(options.ant_compile)
|
| +
|
| if options.ant_compile:
|
| ntag.Compile(options.ant_args)
|
| + else:
|
| + ntag.CompileAndroidMk()
|
|
|
| logging.warn('COMPLETE.')
|
|
|
|
|