Before starting out the procedure, I would hihgly recommend building it on a high-spec VPS and not on your personal computer. You could try out the free-trial of Google Cloud Platform. The guide will assume you are on a Linux system. Please don’t try building on any other OS

Installing required tools and libraries

For this I recommend using the scripts from Akhil Narang’s script repo. I personally use a Ubuntu on a build server. So I will execute script.

sh setup/

Syncing the sources

You can find the syncing instructions on the LineageOS android repo.

For this you will need to install repo. Run the following commands in your home directory

mkdir ~/bin
curl > ~/bin/repo
chmod a+x ~/bin/repo

Now that you have repo, run the following commands to start syncing the project. Make sure you have enough free space since the download can be ~50GB

mkdir los
cd los
repo init -u git:// -b lineage-16.0 --depth=1

Now you need to add your local manifest

mkdir .repo/local_manifests
wget -P los/.repo/local_manifests/

Now start syncing the sources

repo sync -cfj8 --current-branch --no-tags --no-clone-bundle --optimized-fetch --prune

Now kindly go to something productive as this might take a while depending on connection speed.

Once it is done, it’s time to start building.

It is always a good idea to setup ccache as this will make the future builds faster

export USE_CCACHE=1
export CCACHE_DIR=~/.cache
prebuilts/misc/linux-x86/ccache/ccache -M 50G

Here I am using 50GB ccache. You can specify the size depending on how much space you have available

. build/
lunch lineage_whyred-userdeug
make bacon -j8

This will start the build. It can take a few hours depending on the specs of your machine.

If all goes well, you will get a success message and your build should be available in los/out/target/product/whyred/

If you get errors along the way, in most cases a direct Google search should help fix yours error.

Signing your build

The LineageOS Wiki has detailed steps to Sign your build. So no point in repeating them here.

Building Lineage Recovery

If you insist on building and using Lineage recovery, here are the steps

. build/
lunch lineage_whyred-userdebug
make recoveryimage -j8