Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 1 | # Checking out and building on Fuchsia |
| 2 | |
| 3 | ***Note that the Fuchsia port is in the early stages, and things are likely to |
| 4 | frequently be broken. Try #cr-fuchsia on Freenode if something seems awry.*** |
| 5 | |
| 6 | There are instructions for other platforms linked from the |
| 7 | [get the code](get_the_code.md) page. |
| 8 | |
| 9 | ## System requirements |
| 10 | |
| 11 | * A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly |
| 12 | recommended. |
| 13 | * At least 100GB of free disk space. |
| 14 | * You must have Git and Python installed already. |
| 15 | |
| 16 | Most development is done on Ubuntu. |
| 17 | |
| 18 | ## Install `depot_tools` |
| 19 | |
| 20 | Clone the `depot_tools` repository: |
| 21 | |
| 22 | ```shell |
| 23 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 24 | ``` |
| 25 | |
| 26 | Add `depot_tools` to the end of your PATH (you will probably want to put this |
| 27 | in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to |
| 28 | `/path/to/depot_tools`: |
| 29 | |
| 30 | ```shell |
| 31 | $ export PATH="$PATH:/path/to/depot_tools" |
| 32 | ``` |
| 33 | |
| 34 | ## Get the code |
| 35 | |
| 36 | Create a `chromium` directory for the checkout and change to it (you can call |
| 37 | this whatever you like and put it wherever you like, as long as the full path |
| 38 | has no spaces): |
| 39 | |
| 40 | ```shell |
| 41 | $ mkdir ~/chromium && cd ~/chromium |
| 42 | ``` |
| 43 | |
| 44 | Run the `fetch` tool from depot_tools to check out the code and its |
| 45 | dependencies. |
| 46 | |
| 47 | ```shell |
| 48 | $ fetch --nohooks chromium |
| 49 | ``` |
| 50 | |
| 51 | If you don't want the full repo history, you can save a lot of time by |
| 52 | adding the `--no-history` flag to `fetch`. |
| 53 | |
| 54 | Expect the command to take 30 minutes on even a fast connection, and many |
| 55 | hours on slower ones. |
| 56 | |
| 57 | If you've already installed the build dependencies on the machine (from another |
| 58 | checkout, for example), you can omit the `--nohooks` flag and `fetch` |
| 59 | will automatically execute `gclient runhooks` at the end. |
| 60 | |
| 61 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
Adam MacBeth | c6fc88b5 | 2017-06-30 17:26:31 | [diff] [blame] | 62 | directory called `src` in the working directory. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 63 | |
| 64 | ### Configure for building on Fuchsia |
| 65 | |
| 66 | Edit `.gclient` to include (this is a list, so it could also include `android`, |
| 67 | etc. if necessary.) |
| 68 | |
| 69 | ``` |
| 70 | target_os = ['fuchsia'] |
| 71 | ``` |
| 72 | |
Scott Graham | 9ffcea6 | 2017-06-30 21:31:37 | [diff] [blame] | 73 | Note that this should be added as a top-level statement in the `.gclient` file, |
| 74 | not an entry inside the `solutions` dict. |
| 75 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 76 | You will then need to re-run `gclient runhooks`. This makes sure the Fuchsia SDK |
| 77 | is available in third\_party and keeps it up to date. |
| 78 | |
Adam MacBeth | c6fc88b5 | 2017-06-30 17:26:31 | [diff] [blame] | 79 | The remaining instructions assume you have switched to the `src` directory: |
| 80 | |
| 81 | ```shell |
| 82 | $ cd src |
| 83 | ``` |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 84 | |
| 85 | ## Setting up the build |
| 86 | |
| 87 | Chromium uses [Ninja](https://ninja-build.org) as its main build tool along |
| 88 | with a tool called [GN](../tools/gn/docs/quick_start.md) to generate `.ninja` |
| 89 | files. You can create any number of *build directories* with different |
| 90 | configurations. To create a build directory, run: |
| 91 | |
| 92 | ```shell |
Adam MacBeth | ddd50f3 | 2017-07-10 01:42:26 | [diff] [blame^] | 93 | $ gn gen out/fuchsia --args="is_debug=false dcheck_always_on=true is_component_build=false target_os=\"fuchsia\"" |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 94 | ``` |
| 95 | |
Scott Graham | b69a2f6 | 2017-06-26 19:32:20 | [diff] [blame] | 96 | `use_goma=true` is fine to use also if you're a Googler. |
| 97 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 98 | ## Build |
| 99 | |
| 100 | Currently, not all targets build on Fuchsia. You can build base\_unittests, for |
| 101 | example: |
| 102 | |
| 103 | ```shell |
Adam MacBeth | ddd50f3 | 2017-07-10 01:42:26 | [diff] [blame^] | 104 | $ ninja -C out/fuchsia base_unittests |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 105 | ``` |
| 106 | |
| 107 | ## Run |
| 108 | |
| 109 | Once it is built, you can run by: |
| 110 | |
| 111 | ```shell |
| 112 | $ out/fuch/bin/run_base_unittests |
| 113 | ``` |
| 114 | |
| 115 | This packages the built binary and test data into a disk image, and runs a QEMU |
| 116 | instance from the Fuchsia SDK, outputting to the console. |
| 117 | |
| 118 | Common gtest arguments such as `--gtest_filter=...` are supported by the run |
| 119 | script. |
| 120 | |
| 121 | The run script also symbolizes backtraces. |
Scott Graham | b69a2f6 | 2017-06-26 19:32:20 | [diff] [blame] | 122 | |
| 123 | A useful alias (for "Build And Run Filtered") is: |
| 124 | ```shell |
Adam MacBeth | ddd50f3 | 2017-07-10 01:42:26 | [diff] [blame^] | 125 | alias barf='ninja -C out/fuchsia base_unittests -j1000 && out/fuch/bin/run_base_unittests --test-launcher-filter-file=../../testing/buildbot/filters/fuchsia.base_unittests.filter' |
Scott Graham | b69a2f6 | 2017-06-26 19:32:20 | [diff] [blame] | 126 | ``` |
| 127 | to build and run only the tests that are not excluded/known-failing on the bot. |