OLD | NEW |
(Empty) | |
| 1 Android |
| 2 ======= |
| 3 |
| 4 Prerequisites |
| 5 ------------- |
| 6 |
| 7 _Currently we only support building Skia for Android on a Linux or Mac host!_ |
| 8 |
| 9 The following libraries/utilities are required in addition to those needed for a
standard skia checkout: |
| 10 |
| 11 * Apache Ant |
| 12 * The Android SDK: http://developer.android.com/sdk/ |
| 13 |
| 14 ~~~~ |
| 15 $ sudo apt-get install ant git |
| 16 ~~~~ |
| 17 |
| 18 Check out the source code |
| 19 ------------------------- |
| 20 |
| 21 Follow the instructions [here](../download) for downloading the Skia source. Mod
ify .gclient to add the following line to |
| 22 the bottom, and then run gclient sync again: |
| 23 |
| 24 target_os = ["android"] |
| 25 |
| 26 Inside your Skia checkout, `platform_tools/android` contains the Android setup |
| 27 scripts, Android specific dependencies, and the Android Sample App. |
| 28 |
| 29 Setup the Android SDK |
| 30 --------------------- |
| 31 |
| 32 To finish setting up the Android SDK you need to download use the SDK to |
| 33 download the appropriate API level. To do this simply go to the directory |
| 34 where you installed the SDK and run the following commands |
| 35 |
| 36 # You may want to add this export to your shell's .bash_profile or .profile |
| 37 export ANDROID_SDK_ROOT=/path/to/android/sdk |
| 38 |
| 39 $ ANDROID_SDK_ROOT/tools/android update sdk --no-ui --filter android-19 |
| 40 |
| 41 From here you will need to type 'y' to approve the license agreement and that |
| 42 is all. You will then have downloaded the SDK for API level 19 (Android 4.4 |
| 43 KitKat) which will be used to build the Skia SampleApp. You can download as |
| 44 many other Android add-ons or APIs as you want, but you only are required to |
| 45 have this one in order to complete the Skia build process. |
| 46 |
| 47 Setup Environment for Android |
| 48 ----------------------------- |
| 49 |
| 50 The Android build needs to set up some specific variables needed by both GYP |
| 51 and Make. We make this setup easy for developers by encapsulating all the |
| 52 details into a custom script that acts as a replacement for make. |
| 53 |
| 54 Custom Android Build Script |
| 55 --------------------------- |
| 56 |
| 57 The android_ninja script is a wrapper for the ninja command (provided by |
| 58 depot_tools) and is specifically designed to work with the Skia's build |
| 59 system. To use the script you need to call it from Skia's trunk directory with |
| 60 the -d option plus any of the options or arguments you would normally pass to |
| 61 ninja (see descriptions of some of the other flags here). |
| 62 |
| 63 export ANDROID_SDK_ROOT=/path/to/android/sdk |
| 64 export PATH=$PATH:/path/to/depot_tools |
| 65 |
| 66 cd skia |
| 67 ./platform_tools/android/bin/android_ninja -d nexus_10 # or nexus_7, galaxy_
nexus, etc... |
| 68 |
| 69 The -d option enables the build system to target the build to a specific |
| 70 architecture such as MIPS (generic), x86 (generic) and ARM (generic and device |
| 71 specific flavors for Nexus devices). This in turn allows Skia to take |
| 72 advantage of specific device optimizations (e.g. NEON instructions). |
| 73 |
| 74 Generate build file from GYP |
| 75 ---------------------------- |
| 76 |
| 77 We use the open-source gyp tool to generate build files from our multiplatform |
| 78 "gyp" files. While most other platforms enable you to regenerate these files |
| 79 using `./gyp_skia` it is recommend that you do NOT do this for Android. Instead |
| 80 you can rely on it being run automatically by android_ninja. |
| 81 |
| 82 Faster rebuilds |
| 83 --------------- |
| 84 |
| 85 You can use ccache to improve the speed of rebuilding: |
| 86 |
| 87 # You may want to add this export to your shell's .bash_profile or .profile |
| 88 export ANDROID_MAKE_CCACHE=[ccache] |
| 89 |
| 90 Build and run executables on the device |
| 91 --------------------------------------- |
| 92 |
| 93 The build system packages the Skia executables as shared libraries. As such, |
| 94 in order to run any executable on the device you must install the library and |
| 95 a launcher executable on your device. To assist in this process there is a |
| 96 script called `android_run_skia` that is located in the |
| 97 `platform_tools/android/bin` directory. |
| 98 |
| 99 Run correctness tests |
| 100 --------------------- |
| 101 |
| 102 First build the app and then run it on an attached device: |
| 103 |
| 104 ./platform_tools/android/bin/android_ninja [-d device_id] dm |
| 105 ./platform_tools/android/bin/android_run_skia dm # uploads and runs the dm b
inary on the attached device |
| 106 |
| 107 Run performance tests |
| 108 --------------------- |
| 109 |
| 110 Since nanobench tests performance, it usually makes more sense to run it in |
| 111 Release mode. |
| 112 |
| 113 BUILDTYPE=Release ./platform_tools/android/bin/android_ninja [-d device_id]
nanobench |
| 114 |
| 115 # uploads and runs the nanobench binary on the attached device |
| 116 ./platform_tools/android/bin/android_run_skia --release nanobench |
| 117 |
| 118 If you pass nanobench SKP files, it will benchmark them too. |
| 119 |
| 120 ./platform_tools/android/bin/[linux/mac]/adb push ../skp <dst> # <dst> is di
r on device |
| 121 |
| 122 Finally to run the executable there are two approaches. The simplest of the |
| 123 two run the app on the device like you would do for gm or tests, however this |
| 124 approach will also produce the noisiest results. |
| 125 |
| 126 # <input> is file/dir on device |
| 127 ./platform_tools/android/bin/android_run_skia --release nanobench --skps <in
put> |
| 128 |
| 129 Build and run SampleApp |
| 130 ----------------------- |
| 131 |
| 132 The SampleApp on Android provides a simple UI for viewing sample slides and gm i
mages. |
| 133 |
| 134 BUILDTYPE=Debug ./platform_tools/android/bin/android_ninja -d $TARGET_DEVICE |
| 135 |
| 136 Then, install the app onto the device: |
| 137 |
| 138 ./platform_tools/android/bin/android_install_apk |
| 139 |
| 140 Finally to run the application you must navigate to the Skia Samples |
| 141 application using the application launcher on your device. |
| 142 |
| 143 Build tools |
| 144 ----------- |
| 145 |
| 146 The Android platform does not support skdiff at this time. |
| 147 |
| 148 Clean up all generated files |
| 149 ---------------------------- |
| 150 |
| 151 make clean |
| 152 |
| 153 Debugging on Android |
| 154 -------------------- |
| 155 |
| 156 We support debugging on using a GDB wrapper script. The script loads the app |
| 157 onto the device, starts a gdbserver instance with that app, and then enters a |
| 158 GDB client shell on the host. Necessary symbol files are pulled from the |
| 159 device and placed into a temporary folder. The script does not build the app - |
| 160 you'll have to do that first. |
| 161 |
| 162 # you can include additional arguments in quotes (e.g. "dm --nopdf") |
| 163 ./platform_tools/android/bin/android_gdb_exe dm |
| 164 |
| 165 When the gdb client is ready, insert a breakpoint, and continue to let the |
| 166 program resume execution. |
| 167 |
OLD | NEW |