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 | |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame^] | 6 | There are instructions for other platforms linked from the |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 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 | |
Fabrice de Gans-Riberi | bbc67a1b | 2018-08-30 13:19:21 | [diff] [blame] | 16 | Most development is done on Ubuntu. Mac build is supported on a best-effort |
| 17 | basis. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 18 | |
| 19 | ## Install `depot_tools` |
| 20 | |
| 21 | Clone the `depot_tools` repository: |
| 22 | |
| 23 | ```shell |
| 24 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 25 | ``` |
| 26 | |
| 27 | Add `depot_tools` to the end of your PATH (you will probably want to put this |
| 28 | in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to |
| 29 | `/path/to/depot_tools`: |
| 30 | |
| 31 | ```shell |
| 32 | $ export PATH="$PATH:/path/to/depot_tools" |
| 33 | ``` |
| 34 | |
| 35 | ## Get the code |
| 36 | |
| 37 | Create a `chromium` directory for the checkout and change to it (you can call |
| 38 | this whatever you like and put it wherever you like, as long as the full path |
| 39 | has no spaces): |
| 40 | |
| 41 | ```shell |
| 42 | $ mkdir ~/chromium && cd ~/chromium |
| 43 | ``` |
| 44 | |
| 45 | Run the `fetch` tool from depot_tools to check out the code and its |
| 46 | dependencies. |
| 47 | |
| 48 | ```shell |
| 49 | $ fetch --nohooks chromium |
| 50 | ``` |
| 51 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 52 | Expect the command to take 30 minutes on even a fast connection, and many |
| 53 | hours on slower ones. |
| 54 | |
| 55 | If you've already installed the build dependencies on the machine (from another |
| 56 | checkout, for example), you can omit the `--nohooks` flag and `fetch` |
| 57 | will automatically execute `gclient runhooks` at the end. |
| 58 | |
| 59 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
Adam MacBeth | c6fc88b5 | 2017-06-30 17:26:31 | [diff] [blame] | 60 | directory called `src` in the working directory. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 61 | |
| 62 | ### Configure for building on Fuchsia |
| 63 | |
| 64 | Edit `.gclient` to include (this is a list, so it could also include `android`, |
| 65 | etc. if necessary.) |
| 66 | |
| 67 | ``` |
| 68 | target_os = ['fuchsia'] |
| 69 | ``` |
| 70 | |
Scott Graham | 9ffcea6 | 2017-06-30 21:31:37 | [diff] [blame] | 71 | Note that this should be added as a top-level statement in the `.gclient` file, |
| 72 | not an entry inside the `solutions` dict. |
| 73 | |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame^] | 74 | You will then need to run: |
| 75 | |
| 76 | ```shell |
| 77 | $ gclient runhooks |
| 78 | ``` |
| 79 | |
| 80 | This makes sure the Fuchsia SDK is available in third\_party and keeps it up to |
| 81 | date. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 82 | |
Adam MacBeth | c6fc88b5 | 2017-06-30 17:26:31 | [diff] [blame] | 83 | The remaining instructions assume you have switched to the `src` directory: |
| 84 | |
| 85 | ```shell |
| 86 | $ cd src |
| 87 | ``` |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 88 | |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame^] | 89 | ### Update your checkout |
| 90 | |
| 91 | To update an existing checkout, you can run |
| 92 | |
| 93 | ```shell |
| 94 | $ git rebase-update |
| 95 | $ gclient sync |
| 96 | ``` |
| 97 | |
| 98 | The first command updates the primary Chromium source repository and rebases |
| 99 | any of your local branches on top of tip-of-tree (aka the Git branch |
| 100 | `origin/master`). If you don't want to use this script, you can also just use |
| 101 | `git pull` or other common Git commands to update the repo. |
| 102 | |
| 103 | The second command syncs dependencies to the appropriate versions and re-runs |
| 104 | hooks as needed. `gclient sync` updates dependencies to the versions specified |
| 105 | in `DEPS`, so any time that file is modified (pulling, changing branches, etc.) |
| 106 | `gclient sync` should be run. |
| 107 | |
Fabrice de Gans-Riberi | bbc67a1b | 2018-08-30 13:19:21 | [diff] [blame] | 108 | ## (Mac-only) Download additional required Clang binaries |
| 109 | |
| 110 | Go to [this page](https://chrome-infra-packages.appspot.com/p/fuchsia/clang/mac-amd64/+/) |
| 111 | and download the most recent build. Extract `bin/llvm-ar` to the clang folder |
| 112 | in Chromium: |
| 113 | |
| 114 | ```shell |
| 115 | $ unzip /path/to/clang.zip bin/llvm-ar -d ${CHROMIUM_SRC}/third_party/llvm-build/Release+Asserts |
| 116 | ``` |
| 117 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 118 | ## Setting up the build |
| 119 | |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 120 | Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with |
| 121 | a tool called [GN](https://gn.googlesource.com/gn/+/master/docs/quick_start.md) |
| 122 | to generate `.ninja` files. You can create any number of *build directories* |
| 123 | with different configurations. To create a build directory, run: |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 124 | |
| 125 | ```shell |
Adam MacBeth | ddd50f3 | 2017-07-10 01:42:26 | [diff] [blame] | 126 | $ 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] | 127 | ``` |
| 128 | |
Wez | 2102c3be | 2017-07-12 01:09:26 | [diff] [blame] | 129 | You can also build for Debug, with `is_debug=true`, but since we don't currently |
| 130 | have any Debug build-bots, it may be more broken than Release. |
| 131 | |
Scott Graham | b69a2f6 | 2017-06-26 19:32:20 | [diff] [blame] | 132 | `use_goma=true` is fine to use also if you're a Googler. |
| 133 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 134 | ## Build |
| 135 | |
| 136 | Currently, not all targets build on Fuchsia. You can build base\_unittests, for |
| 137 | example: |
| 138 | |
| 139 | ```shell |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 140 | $ autoninja -C out/fuchsia base_unittests |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 141 | ``` |
| 142 | |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 143 | `autoninja` is a wrapper that automatically provides optimal values for the |
| 144 | arguments passed to `ninja`. |
| 145 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 146 | ## Run |
| 147 | |
| 148 | Once it is built, you can run by: |
| 149 | |
| 150 | ```shell |
Wez | 2102c3be | 2017-07-12 01:09:26 | [diff] [blame] | 151 | $ out/fuchsia/bin/run_base_unittests |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 152 | ``` |
| 153 | |
| 154 | This packages the built binary and test data into a disk image, and runs a QEMU |
| 155 | instance from the Fuchsia SDK, outputting to the console. |
| 156 | |
| 157 | Common gtest arguments such as `--gtest_filter=...` are supported by the run |
| 158 | script. |
| 159 | |
| 160 | The run script also symbolizes backtraces. |