# These are instruction for cross building Thorium for Windows, on Linux. Preliminary file for @gz83, to be eventually migrated to a Wiki with building instructions for all paltforms.
## In general, this document follows information from > https://chromium.googlesource.com/chromium/src.git/+/HEAD/docs/win_cross.md and https://chromium.googlesource.com/chromium/src/+/main/docs/linux/build_instructions.md
## Preparatory setup
First, make sure you are running Ubuntu 18.04/20.04, or Debian 10/11, or Arch, and have nano and unrar installed.
First, we need to install depot_tools. depot_tools is a .zip that contains tools for all Google projects like Chromium, ChromiumOS, NaCl, V8, Infra, Android, Google Cloud, and Fuschia.
We are assuming that depot_tools, chromium, and thorium will all be in $HOME.
Then cd ~/Thorium, and we need to make some files executable. So run
sudo chmod +x build.sh
sudo chmod +x build_win.sh
sudo chmod +x setup.sh
sudo chmod +x trunk.sh
sudo chmod +x clean.sh
sudo chmod +x misc/autoninja
## Setting up the build
Then, run (in order)
./trunk.sh // Pay attention to the PGO profile that is downloaded, the script downloads the PGO profile *.profdata files for Linux, Windows, and MacOS.
./setup.sh
Now we need to set up the PGO profile and set the args.gn
Open ~/Thorium/misc/windows_arg.gn and edit the last line that looks like
And edit it to point to the actual location of that PGO file from above.
You can also add API Keys to the top three lines of this file to enable Google Sync, Translate, etc. (Out of the scope of this article, for help, contact me.)
Now, go to ~/chromium/src, and run
gn args out/thorium
A nano editor will come up, and you will copy/paste the contents of the win_args.gn OR win_AVX2_args.gn (for AVX2) Or win_ARM_args.gn (for Windows on ARM) file into this.
Save and exit and the terminal will show "Generating files..." Wait for it to complete, and then to actually build it:
Go back to ~/Thorium, and run ./build_win.sh
NOTE: Run ./build_win.sh --help to see the (only) option, which is the number of jobs. The command it ultimately runs is:
You can substitute the -j# for the number of jobs. I use 8 because I have an 8 core cpu. Do not use a number more than the number of threads your CPU has.
So for example, I run ./build_win.sh 8
In the end, you will have a nice installer called mini_installer.exe in ~/chromium/src/out/thorium/
I rename it to thorium_mini_installer.exe or thorium_avx2_mini_installer.exe for releases. Just double click to install Thorium to C:\Users\$USERNAME\AppData\Local\Thorium
## AVX2 Release
Speaking of which! Thorium by default compiles with AVX and AES. To make the AVX2 version of it, you will follow all the steps above, except before running gn args out\thorium,
we need to download the avx2 sources.
git clone https://github.com/Alex313031/Thorium-AVX2.git or https://github.com/Alex313031/Thorium-AVX2/archive/refs/heads/main.zip
And simply copy the build directory over ~/chromium/src/build
## Make a portable release.
To make a portable release, it is easiest to copy an already made portable release from GitHub, extract it, and then:
1. Delete the contents of the BIN folder.
2. Use 7-Zip to extract the contents of the new mini_installer you just made, and then extract the chrome.7z that was inside it.
3. Copy the contents of Chrome-bin into the BIN folder in the portable folder.
4. Edit CONTENT_SHELL.bat to point to the actual location as the version number will have changed.
5. Likewise, edit the version number in the name of the whole portable folder to reflect the new Thorium.
6. Finally, rezip it up with 7-Zip. To use it, read the README.txt inside.
## Updating your checkout
To update the Chromium checkout, just run (from ~/Thorium)
./trunk
To update Thorium, do a git pull main or redownload the latest .zip