본문 바로가기

Programming

Building Android QEMU from source

Rebuilding the Android emulator from sources

============================================


I. Getting the sources:

-----------------------


At the moment, you'll need a full AOSP source checkout to rebuild the

emulator from sources. See the instructions at http://source.android.com on

how to download the platform sources.


The following directories will be relevant:


  $AOSP/external/qemu        -> The emulator itself.

  $AOSP/external/getst       -> The GoogleTest sources.

  $AOSP/sdk/emulator/opengl  -> Host GPU emulation libraries.


  $AOSP/prebuilts/tools/gcc-sdk           -> host toolchains for SDK tools.

  $AOSP/prebuilts/gcc/linux-x86/host/

  $AOSP/prebuilts/gcc/darwin-x86/host/



II. Building:

-------------


You can only build the emulator on Linux or Darwin. Windows binaries are

always generated on Linux, and actually run under Wine (more on this later).


There are currently two ways to build the emulator:


1) Using the standalone build-system:


As long as the directories listed in section I. exist, you can build the

emulator binaries from sources directly by using the android-rebuild.sh

script, i.e.:


  cd $AOSP/external/qemu

  ./android-rebuild.sh


This will build all related binaries, and run the small GoogleTest-based

unit test suite for your host system.


This places everything under the 'objs/' sub-directory, and you can launch

the emulator directly with something like:


  export ANDROID_SDK_ROOT=/path/to/sdk

  objs/emulator @<avd-name>  [<other-options>...]


Use ./android-rebuild.sh --help for more details and command-line options.



2) Using the Android platform build:


If you have a full checkout of the AOSP source tree, the emulator will be

built as part of a regular "make" invokation, and the binaries placed under

out/host/<system>/bin/, allowing you to just run 'emulator' after the build.

For example, for an ARM-based SDK system image build:


  cd $AOSP

  . build/envsetup.sh

  lunch sdk-eng

  make -j$NUM_CORES

  emulator


Note that this scheme is _much_slower though, but once you have performed

a full build, you will be able to only rebuild the emulator quickly by

doing the following (after the commands above):


  cd external/qemu

  mm -j$NUM_CORES


The 'mm' command is a special function sourced into your environment by

envsetup.sh


Note: The default SDK system image maps to an ARMv7-based virtual CPU,

      use 'sdk_x86-eng' or 'sdk_mips-eng' to build x86 or MIPS based ones.


In all cases, several binaries will be generated:


    emulator         -> 32-bit launcher program.

    emulator-<cpu>   -> 32-bit emulator for Android <cpu> images.

    emulator64-<cpu> -> 64-bit emulator for Android <cpu> images.


With <cpu> being one of the CPU architectures supported by the

Android emulator (e.g. 'arm', 'x86' or 'mips').


The 'emulator' executable is a very small program used to probe

the host system and the AVD you want to launch, in order to

invoke the appropriate 'real' emulator program. It also adjusts

library search paths to ensure that the emulator can load the

GPU emulation libraries from the right location.


Note that there are no emulator64-<cpu> executables generated on

Windows at the moment, due to issues with the mingw32-w64 cross-toolchains.


Define ANDROID_SDK_ROOT in your environment to point to your SDK installation

and be able to start AVDs with your freshly built emulator.


'Programming' 카테고리의 다른 글

CVE-2014-3153 on x86 Ubuntu 13.04  (0) 2014.07.24
Mounting / Unmounting ASCII cpio archive in Linux  (6) 2014.06.25
QEMU monitor console  (0) 2014.06.16
OS Kernel Debugging with VMWare  (0) 2014.06.10
Python signed/unsigned 처리  (0) 2014.06.02