Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame^] | 1 | # Cross-compiling Chrome/win |
| 2 | |
| 3 | It's possible to build parts of the codebase on a Linux (and soon, Mac) host |
| 4 | while targeting Windows. This document describes how to set that up, and |
| 5 | current restrictions. |
| 6 | |
| 7 | What does *not* work: |
| 8 | |
| 9 | * goma. Sorry. ([internal bug](b/64390790)) |
| 10 | * targets depending on crashpad ([bug](https://crbug.com/762167)) |
| 11 | * targets using .rc files ([bug](https://crbug.com/774193)) |
| 12 | * linking on Mac ([bug](https://crbug.com/774209)), should change soon |
| 13 | |
| 14 | This disqualifies most interesting targets for now, but a few smaller ones |
| 15 | (`base_unittests`, ...) do work. Over time, more things should work. |
| 16 | |
| 17 | ## .gclient setup |
| 18 | |
| 19 | 1. Tell gclient that you need Windows build dependencies by adding |
| 20 | `target_os = ['win']` to the end of your `.gclient`. (If you already |
| 21 | have a `target_os` line in there, just add `'win'` to the list.) |
| 22 | 1. `gclient sync`, follow instructions on screen. |
| 23 | |
| 24 | If you're at Google, this will automatically download the Windows SDK for you. |
| 25 | If you are not at Google, you'll have to figure out how to get the SDK, and |
| 26 | you'll need to put a JSON file describing the SDK layout in a certain location. |
| 27 | |
| 28 | # GN setup |
| 29 | |
| 30 | Add `target_os = "win"` to your args.gn. Then just build, e.g. |
| 31 | |
| 32 | ninja -C out/gnwin base_unittests.exe |
| 33 | |
| 34 | # Running tests on swarming |
| 35 | |
| 36 | You can run the Windows binaries you built on swarming, like so: |
| 37 | |
| 38 | tools/mb/mb.py isolate //out/gnwin base_unittests |
| 39 | tools/swarming_client/isolate.py archive \ |
| 40 | -I https://isolateserver.appspot.com \ |
| 41 | -i out/gnwin/base_unittests.isolate \ |
| 42 | -s out/gnwin/base_unittests.isolated |
| 43 | tools/swarming_client/swarming.py trigger \ |
| 44 | -S https://chromium-swarm.appspot.com \ |
| 45 | -I https://isolateserver.appspot.com \ |
| 46 | -d os Windows -d pool Chrome -s <hash printed by previous command> |
| 47 | |
| 48 | Most tests that build should pass. However, the cross build uses |
| 49 | the lld linker, and a couple of tests fail when using lld. You can look at |
| 50 | https://build.chromium.org/p/chromium.clang/builders/CrWinClangLLD%20tester |
| 51 | to get an idea of which tests fail with lld. |
| 52 | |
| 53 | TODO(thakis): It'd be nice if there was a script for doing this. Maybe make |
| 54 | tools/fuchsa/run-swarmed.py work for win cross builds too, or create |
| 55 | `run_base_unittests` script targets during the build (like Android). |