2022-08-08 03:53:37 -04:00
# Cross-Compiling Thorium for Windows on Linux <img src="https://github.com/Alex313031/Thorium/blob/main/logos/NEW/build_light.svg#gh-dark-mode-only" width="48"> <img src="https://github.com/Alex313031/Thorium/blob/main/logos/NEW/build_dark.svg#gh-light-mode-only" width="48">
2022-08-08 03:48:42 -04:00
As many Chromium developers are on Linux/Mac, cross-compiling Chromium for
Windows targets facilitates development for Windows targets on non-Windows
machines.
It's possible to build most parts of the codebase on a Linux or Mac host while
targeting Windows. It's also possible to run the locally-built binaries on
swarming. This document describes how to set that up, and current restrictions.
## Limitations
What does *not* work:
* `js2gtest` tests are omitted from the build ([bug](https://crbug.com/1010561))
* on Mac hosts, 32-bit builds don't work ([bug](https://crbug.com/794838) has
more information, and this is unlikely to ever change)
All other targets build fine (including `chrome` , `thorium_shell` , etc...).
Uses of `.asm` files have been stubbed out. As a result, Crashpad cannot
report crashes, and NaCl defaults to disabled and cannot be enabled in cross
builds ([.asm bug](https://crbug.com/762167)).
## Setup
2022-08-08 03:52:53 -04:00
First make sure you've followed the instructions for getting the Chromium and Thorium code from [HERE ](https://github.com/Alex313031/Thorium/blob/main/docs/BUILDING.md#get-the-code ). \
2022-08-08 03:48:42 -04:00
Also make sure you have run `setup.sh` to copy the Thorium code over the Chromium tree.
## .gclient setup
1. Tell gclient that you need Windows build dependencies by adding
`target_os = ['win']` to the end of your `.gclient` file present in *~/chromium/* . (If you already
have a `target_os` line in there, just add `'win'` to the list.) e.g.
solutions = [
{
...
}
]
target_os = ['linux', 'win']
2022-08-08 03:52:53 -04:00
2. Run a `trunk.sh` , and follow instructions on screen.
2022-08-08 03:48:42 -04:00
### Installing the MSVS Artifacts Archive
2022-08-08 03:52:53 -04:00
Download the latest MSVS Artifacts Archive from [HERE ](https://github.com/Alex313031/Snippets/releases/latest ). \
2022-08-08 03:48:42 -04:00
Then, make a subdir in *chromium* called win, i.e. `mkdir ~/chromium/win` , and then place the .zip file in there.
Then add these lines to your `.bashrc` or `.zshrc` .
2022-08-08 03:52:53 -04:00
export DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL=< base url >
2022-08-08 03:48:42 -04:00
export GYP_MSVS_HASH_< toolchain hash > =< hash value >
2022-08-08 03:52:53 -04:00
`<base url>` is the full path of the directory containing the .zip file, i.e. */home/alex/chromium/win/80909eccbb.zip*
2022-08-08 03:48:42 -04:00
`<toolchain hash>` is hardcoded in `src/build/vs_toolchain.py` and can be found by
setting `DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL` and running `gclient runhooks` :
gclient runhooks
...
Running hooks: 17% (11/64) win_toolchain
________ running '/usr/bin/python src/build/vs_toolchain.py update --force' in < chromium dir >
Windows toolchain out of date or doesn't exist, updating (Pro)...
current_hashes:
desired_hash: < toolchain hash >
`<hash value>` is the name of the .zip, without .zip at the end, i.e. `80909eccbb`
## Building
2022-08-08 03:52:53 -04:00
Follow [Setting up the build ](https://github.com/Alex313031/Thorium/blob/main/docs/BUILDING.md#setting-up-the-build ), except instead of using the `args.gn` from the
root of the Thorium repo, use the [`win_args.gn` ](https://github.com/Alex313031/Thorium/blob/main/infra/win_args.gn ), from *~/Thorium/infra/*
2022-08-08 03:48:42 -04:00
Then, to build, run `build_win.sh` , instead of `build.sh` . See > [Here ](https://github.com/Alex313031/Thorium/blob/main/docs/BUILDING.md#build-thorium- ).
2022-08-08 03:53:37 -04:00
*Happy Thorium Building!*
< img src = "https://github.com/Alex313031/Thorium/blob/main/logos/STAGING/Thorium90_504.jpg" width = "200" >