diff --git a/README.adoc b/README.adoc index a6c8a8f..44e28dc 100644 --- a/README.adoc +++ b/README.adoc @@ -11434,7 +11434,9 @@ Big new features that are not yet working. Remember: Android AOSP is a huge undocumented piece of bloatware. It's integration into this repo will likely never be super good. -https://stackoverflow.com/questions/1809774/how-to-compile-the-android-aosp-kernel-and-test-it-with-the-android-emulator/48310014#48310014 +Verbose setup description: https://stackoverflow.com/questions/1809774/how-to-compile-the-android-aosp-kernel-and-test-it-with-the-android-emulator/48310014#48310014 + +Download, build and run with the prebuilt AOSP QEMU emulator and the AOSP kernel: .... ./build-android \ @@ -11443,14 +11445,20 @@ https://stackoverflow.com/questions/1809774/how-to-compile-the-android-aosp-kern download \ build \ ; -./run \ +./run-android \ --android-base-dir /path/to/your/hd \ --android-version 8.1.0_r60 \ - --kvm \ ; .... -TODO hack the kernel and rebuild, hack userland and see message. +Sources: + +* link:build-android[] +* link:run-android[] + +TODO how to hack the AOSP kernel, userland and emulator? + +Other archs work as well as usual with `--arch` parameter. However, running in non-x86 is very slow due to the lack of KVM. == About this repo diff --git a/build-android b/build-android index c70d13f..c82565a 100755 --- a/build-android +++ b/build-android @@ -60,10 +60,12 @@ https://github.com/cirosantilli/linux-kernel-module-cheat#android # The crappy android build system requires # https://stackoverflow.com/questions/7040592/calling-the-source-command-from-subprocess-popen self.sh.run_cmd('''\ -. build/envsetup.sh -lunch aosp_{}-eng +{} USE_CCACHE=1 make -j {} -'''.format(self.env['android_arch'], self.env['nproc']), +'''.format( + self.env['android_shell_setup'], + self.env['nproc'] + ), cwd=self.env['android_dir'], executable=shutil.which('bash'), shell=True, diff --git a/common.py b/common.py index 29842bb..c6a8146 100644 --- a/common.py +++ b/common.py @@ -721,6 +721,12 @@ Valid emulators: {} env['image'] = env['linux_image'] env['disk_image'] = env['qcow2_file'] + # Android. + env['android_shell_setup'] = ''' +. build/envsetup.sh +lunch aosp_{}-eng +'''.format(self.env['android_arch']) + def add_argument(self, *args, **kwargs): ''' Also handle: diff --git a/run-android b/run-android new file mode 100755 index 0000000..e2b6f41 --- /dev/null +++ b/run-android @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +import shutil + +import common + +class Main(common.LkmcCliFunction): + def __init__(self): + super().__init__( + description='''\ +Run android AOSP on the AOSP pre-build emulator. + +https://github.com/cirosantilli/linux-kernel-module-cheat#android +''', + ) + self.add_argument('extra-emulator-args', default='', nargs='?') + + def timed_main(self): + self.sh.run_cmd('''\ +{} +emulator -show-kernel -verbose {} +'''.format( + self.env['android_shell_setup'], + self.env['extra_emulator_args'] + ), + cwd=self.env['android_dir'], + executable=shutil.which('bash'), + shell=True, + ) + +if __name__ == '__main__': + Main().cli()