Compiling the Brave Browser (based on Chromium) on Linux can take a really long time and so most developers use sccache to cache objects files and speed up future re-compilations.
Here's the cronjob I wrote to seed my local cache every work day to pre-compile the latest builds:
30 23 * * 0-4 francois /usr/bin/chronic /home/francois/bin/seed-brave-browser-cache
and here are the contents of that script:
#!/bin/bash
set -e
# Set the path and sccache environment variables correctly
source ${HOME}/.bashrc-brave
export LANG=en_CA.UTF-8
cd ${HOME}/devel/brave-browser-cache
echo "Environment:"
echo "- HOME = ${HOME}"
echo "- PATH = ${PATH}"
echo "- PWD = ${PWD}"
echo "- SHELL = ${SHELL}"
echo "- BASH_ENV = ${BASH_ENV}"
echo
echo $(date)
echo "=> Clean up repo and delete old build output"
rm -rf src/out node_modules src/brave/node_modules
git clean -f -d
git checkout HEAD package-lock.json
find -name "*.pyc" -delete
echo $(date)
echo "=> Update repo"
git fetch --prune origin
git pull
npm install
rm -rf src/brave/*
git -C src/third_party/devtools-frontend/src/ reset --hard
gclient sync -D
git -C src/brave pull
git -C src/brave reset --hard
npm run init
echo $(date)
echo "=> Debug build"
killall sccache || true
ionice nice timeout --foreground 4h npm run build || ionice nice timeout 4h npm run build
ionice nice ninja -C src/out/Component brave_unit_tests
ionice nice ninja -C src/out/Component brave_browser_tests
echo
echo $(date)
echo "=> Release build"
killall sccache || true
ionice nice timeout --foreground 5h npm run build Release || ionice nice timeout 5h npm run build Release
ionice nice ninja -C src/out/Release brave_unit_tests
ionice nice ninja -C src/out/Release brave_browser_tests
echo
echo $(date)
echo "=> Delete build output"
rm -rf src/out
It references a ~/.bashrc-brave
file which contains:
#!/bin/sh
export PATH="${PATH}:${HOME}/bin:${HOME}/devel/brave-browser/vendor/depot_tools:${HOME}/.cargo/bin"
export SCCACHE_DIR="${HOME}/.cache/sccache"
export SCCACHE_CACHE_SIZE=200G
export NO_AUTH_BOTO_CONFIG="${HOME}/.boto"
ccache instead of sccache
While I started using sccache for compiling Brave, I recently switched to ccache as sccache turned out to be fairly unreliable at compiling Chromium.
Switching to ccache
is easy, simply install the package:
apt install ccache
and then set the environment
variable
in .npmrc
:
sccache = ccache
Finally, you'll probably want to increase the maximum cache size:
ccache --max-size=200G
in order to fit all of Chromium/Brave in the cache.