The second generation of Windows Subsystem for Linux, commonly referred to as WSL 2, was announced during Microsoft’s Build 2019 developer conference. Compared to the legacy WSL implementation, WSL 2 performs substantially better on filesystem-heavy operations due to the major architectural rewrite. Windows 10’s latest stable channel build, i.e. Windows 10 May 2020 update, makes WSL 2 available to all users. With WSL 2, it’s rather easy for Windows users to compile AOSP or custom ROMs like LineageOS from scratch without installing a full-fledged GNU/Linux distribution.
This is not the first time we highlighted the possibility of building LineageOS on Windows using WSL, but the situation is a bit different now. The first stable build of Windows Terminal is here, and CLI lovers can now natively get features like GPU-accelerated text rendering, custom key bindings, tabbed shells with customized color schemes, and a whole lot of other useful goodies. Given that you can directly invoke WSL just like another tab in your terminal, users of Windows 10 can apply different configurations and shortcuts (just like a pre-configured Linux environment) while compiling LineageOS.
XDA Senior Member/LineageOS team member Uldiniad has updated his forum post with a guide on how to compile the latest version of LineageOS, LineageOS 17.1 based on Android 10, on a Windows 10 PC using WSL 2. Before attempting to perform a local build, make sure that you have A LOT of free storage space and an unlimited Internet plan. For example, it took about 340GB of storage space for Uldiniad to compile a clean LineageOS 17.1 build for the OnePlus 6 (code-name “enchilada”), taking account of the synced source code as well as the build output.
If your PC meets the hardware requirements for building Android from source, then follow these steps to set up a WSL 2 build environment in Windows 10 and compile LineageOS 17.1:
- Open Microsoft Store
- Search for and install the Ubuntu app
- Open the app and follow the first-time setup steps
- Update packages and install the following
sudo apt update && sudo apt full-upgrade -y && sudo apt install -y build-essential ccache libncurses5 libssl-dev m4 unzip zip
- Make a directory for the source code (and go to it):
mkdir -p ~/android/lineage && cd android/lineage
- Initialize the LineageOS source repository:
repo init -u https://github.com/LineageOS/android.git -b lineage-17.1
- Sync the sources:
- Turn on caching to speed up build. This step is optional but recommended for subsequent builds.
- Prepare the device-specific code:
- Add the following to
<project name="TheMuppets/proprietary_vendor_your device brand" path="vendor/your device brand" remote="github" />
- Sync the sources again:
- Start the build:
According to Uldiniad, his AMD Ryzen 9 3950X-powered PC (full specifications can be found here) took 22 minutes to compile the aforementioned LineageOS 17.1 build with ccache populated.
Do you think your PC is powerful enough to handle the compilation job? Let us know your experience with LineageOS building on WSL in the comments below!
Rojenx is a leading concept artist who work appears in games and publications
Check out his personal gallery here