Build PixelOS

Author: Hridaya
Published on 2024-11-30

PixelOS

Understanding

What is

Git?

Git is a free and open source distributed version control system. Android uses Git for local operations such as branching, commits, diffs, and edits. For help learning Git, refer to the Git documentation.

Repo?

Repo is a Python wrapper around Git that simplifies performing complex operations across multiple Git repositories. Repo doesn't replace Git for all version control operations, it only makes complex Git operations easier to accomplish. Repo uses manifest files to aggregate Git projects into the Android superproject.

manifest file?

A manifest file is an XML file specifying where the various Git projects in the Android source are placed within an AOSP source tree.

Requirements

Hardware Requirements

  • A 64-bit x86 system.

  • At least 400 GB of free disk space to check out and build the code
    (250 GB to check out + 150 GB to build).

  • A minimum of 64 GB of RAM.
    Google uses 72-core machines with 64 GB of RAM to build Android. With this hardware configuration, it takes approximately 40 minutes for a full build of Android and only a few minutes for an incremental build. By contrast, it takes approximately 6 hours for a full build with a 6-core machine with 64 GB of RAM.

Operating System Requirements

  • Any 64-bit Linux distribution with GNU C Library (glibc) 2.17 or later

Install required dependencies

sudo apt update && sudo apt install -y bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5 libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-gtk3-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev python ssh python2 patchelf binutils

OR

wget https://raw.githubusercontent.com/akhilnarang/scripts/refs/heads/master/setup/android_build_env.sh | bash android_build_env.sh

Sync ROM source

  1. Navigate into your home directory

    cd ~

  2. Create a local working subdirectory within it:

    mkdir pixelos

  3. Navigate into the directory:

    cd pixelos

  4. Initialize the PixelOS repository source code latest branch (the default):

    repo init https://github.com/PixelOS-AOSP/manifest --git-lfs

  5. Enter or accept your Git credentials (name, email address). (If you're building for the first time)

  6. Sync the source code

    repo sync

Setup device configuration dependencies

In my case, I am going to build for Xiaomi Redmi Note 9 Pro 5G Series, aka gauguin. To set up the device configuration, clone the necessary repositories into the following directories:

  • Device tree: device/xiaomi/gauguin
  • Kernel tree: kernel/xiaomi/gauguin
  • Proprietary vendor tree: vendor/xiaomi/gauguin

These dependencies are all available in PixelOS-Devices organization,
if your device is officially supported.

Make sure to follow the specific directory format:
{device kernel vendor}/{OEM}/{codename}

Let's build it

  1. Setup build environment

    . build/envsetup.sh

  2. Choose the target device and build type with the lunch command.

    lunch aosp_{codename}-{release_tag}-{buildtype}

  3. Fire up the build

    m bacon

Replace {codename} with your device's codename (e.g., gauguin) {release_tag} with the release tag (e.g., ap4a for Android 15 QPR1) and {buildtype} with one of the build types: user, userdebug, or eng.

If everything is fine, you should get somewhat like following:

PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=15
CUSTOM_VERSION=PixelOS_gauguin-15.0-20241128-1232
TARGET_PRODUCT=aosp_gauguin
TARGET_BUILD_VARIANT=userdebug
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-2a-dotprod
TARGET_CPU_VARIANT=cortex-a55
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-2a
TARGET_2ND_CPU_VARIANT=cortex-a55
HOST_OS=linux
HOST_OS_EXTRA=Linux-6.5.0-44-generic-x86_64-Ubuntu-23.10
HOST_CROSS_OS=windows
BUILD_ID=AP3A.241105.008
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=vendor/xiaomi/gauguin device/xiaomi/gauguin bootable/deprecated-ota hardware/google/interfaces
hardware/google/pixel hardware/qcom-caf/common/libqti-perfd-client hardware/xiaomi vendor/qcom/opensource/usb/etc
vendor/qcom/opensource/usb/etc vendor/gms/common hardware/qcom-caf/sm8250 vendor/qcom/opensource/commonsys/display
vendor/qcom/opensource/commonsys-intf/display vendor/qcom/opensource/display vendor/qcom/opensource/data-ipa-cfg-mgr-legacy-um
vendor/qcom/opensource/dataservices hardware/qcom-caf/wlan packages/apps/FMRadio/jni/fmr

and you should get your build in somewhat this format:

$OUT/product/{codename}/PixelOS*{codename}-{version}-{datetime}-{tag}.zip

Example:

${BUILD_DIR}/out/target/product/gauguin/PixelOS_gauguin-15.0-20241128-1234.zip