tfarina | 2c77322 | 2016-04-05 18:43:35 | [diff] [blame^] | 1 | # Android Build Instructions |
| 2 | |
| 3 | [TOC] |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | A Linux build machine capable of building [Chrome for |
| 8 | Linux](https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_instructions_prerequisites.md). |
| 9 | Other (Mac/Windows) platforms are not supported for Android. |
| 10 | |
| 11 | ## Getting the code |
| 12 | |
| 13 | First, check out and install the [depot\_tools |
| 14 | package](https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up). |
| 15 | |
| 16 | Then, if you have no existing checkout, create your source directory and |
| 17 | get the code: |
| 18 | |
| 19 | ```shell |
| 20 | mkdir ~/chromium && cd ~/chromium |
| 21 | fetch --nohooks android # This will take 30 minutes on a fast connection |
| 22 | ``` |
| 23 | |
| 24 | If you have an existing Linux checkout, you can add Android support by |
| 25 | appending `target_os = ['android']` to your .gclient file (in the |
| 26 | directory above src): |
| 27 | |
| 28 | ```shell |
| 29 | cat > .gclient <<EOF |
| 30 | solutions = [ ...existing stuff in here... ] |
| 31 | target_os = [ 'android' ] # Add this to get Android stuff checked out. |
| 32 | EOF |
| 33 | ``` |
| 34 | |
| 35 | Then run gclient sync to get the Android stuff checked out: |
| 36 | |
| 37 | ```shell |
| 38 | gclient sync |
| 39 | ``` |
| 40 | |
| 41 | ## (Optional) Check out LKGR |
| 42 | |
| 43 | If you want a single build of Chromium in a known good state, sync to |
| 44 | the LKGR ("last known good revision"). You can find it |
| 45 | [here](http://chromium-status.appspot.com/lkgr), and the last 100 |
| 46 | [here](http://chromium-status.appspot.com/revisions). Run: |
| 47 | |
| 48 | ```shell |
| 49 | gclient sync --nohooks -r <lkgr-sha1> |
| 50 | ``` |
| 51 | |
| 52 | This is not needed for a typical developer workflow; only for one-time |
| 53 | builds of Chromium. |
| 54 | |
| 55 | ## Configure your build |
| 56 | |
| 57 | Android builds can be run with GN or GYP, though GN incremental builds |
| 58 | are the fastest option and GN will soon be the only supported option. |
| 59 | They are both meta-build systems that generate nina files for the |
| 60 | Android build. Both builds are regularly tested on the build waterfall. |
| 61 | |
| 62 | ### Configure GYP (deprecated -- use GN instead) |
| 63 | |
| 64 | If you are using GYP, next to the .gclient file, create a a file called |
| 65 | 'chromium.gyp_env' with the following contents: |
| 66 | |
| 67 | ```shell |
| 68 | echo "{ 'GYP_DEFINES': 'OS=android target_arch=arm', }" > chromium.gyp_env |
| 69 | ``` |
| 70 | |
| 71 | Note that "arm" is the default architecture and can be omitted. If |
| 72 | building for x86 or MIPS devices, change `target_arch` to "ia32" or |
| 73 | "mipsel". |
| 74 | |
| 75 | **NOTE:** If you are using the `GYP_DEFINES` environment variable, it |
| 76 | will override any settings in this file. Either clear it or set it to |
| 77 | the values above before running `gclient runhooks`. |