Skip to main content

Syncing and Building ElementOS.

Build Status Version

Syncing the source

Use the following commands to init the ElementOS source to your machine. Make sure you have enough storage, Android source is about ~100GB, you will need extra ~100GB in order to make builds. See requirements in Android Source | Requirements.

First, create a folder:

mkdir elementos
cd elementos

Init and sync the source, this will take some time depending on your bandwidth.

repo init -u https://github.com/elementosrom/manifest -b eleven
repo sync -c -j$(nproc --all) --force-sync --no-clone-bundle --no-tags
warning

Don't change any folder name (elementos) unless you know what you are doing.

warning

Please, make sure the source is ok by checking the badge in this wiki, if the build is passing, you're good to sync and build.

Cloning trees

Once the source is synced, you will need the source of your device, such as kernel, device tree and vendor tree. You can search for device trees or making one from scratch. If you're building unofficially for supported devices, you'll find the necessary trees in ElementOS Devices.

Clone the trees in the correct path, by following:

tip

Device tree path: device/$BRAND/$CODENAME

tip

Kernel tree path: kernel/$BRAND/$CODENAME

NOTE: You can use prebuilt kernel if it's the only solution to make the device functional.

Finally, vendor tree is also needed for proprietary files/libs. clone a common device device tree if needed.

Required commits on device tree

ElementOS uses AOSP mk files so you won't have to make many changes for bringup. See a bringup example in elementos-devices/device_google_crosshatch.

Starting building

To start building first we need to set up environment on the main rom directory.

. build/envsetup.sh

Using ccache

To export ccache, run this after setting up environment:

export USE_CCACHE=1 && export CCACHE_COMPRESS=1 && export CCACHE_MAXSIZE=50G # 50 GB && export CCACHE_EXEC=$(which ccache)

You can now lunch by typing:

lunch aosp_$DEVICE-user
warning

Replace $DEVICE with your device codename. For example: lunch aosp_coral-user

tip

You can also lunch as eng for debugging builds by just changing user with eng. userdebug is also allowed for releases.

Once lunched you will see a output like this:

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=11
CUSTOM_VERSION:ElementOS_7_coral-11-20210108-1532
TARGET_PRODUCT=aosp_coral
TARGET_BUILD_VARIANT=user
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=kryo
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=kryo
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.19.0-8-cloud-amd64-x86_64-Debian-GNU/Linux-10-(buster)
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=RQ1A.210105.003
OUT_DIR=/home/bbjprojek/ElementOS11/out
PRODUCT_SOONG_NAMESPACES=device/qcom/coral vendor/qcom/coral vendor/google/customization/apex/apex_images hardware/qcom/coral frameworks/av/camera/cameraserver frameworks/av/services/camera/libcameraservice hardware/qcom/common/fwk-detect
============================================

If you haven't seen this, most likely the system encountered an error, followed by #### failed to build some targets ####. Check the device tree if you did the bringup correctly. If you don't see this, just wait, it takes time depending on your computer perfomance.

If you didn't have issues on lunch, now it's time to build by running:

mka bacon -j$(nproc --all)

This will take more time depending on your system. It may take 30 minutes on a high-end system with ccache. But it can take up 6 hours on a low-end system if it's the first build, recommended to export ccache.

info

Once built, you can get the zip on: out/target/product/$DEVICE. For example: out/target/product/coral. Typing ls will help you find the .zip. Called ElementOS_7_coral-11-20210108-1532.zip or similar. The .zip.md5 is the md5 file. .zip.json is the build info, useful for OTA system.

Submitting errors and fixing them

Join the ElementOS builders chat to get build support, and also search for the most common problems as duplicated, missing libs...

After Building

It's recommended to clean the out directory for future builds if you're planning to modify / syncing source that needs to clean the directory such as removed / added new packages. To do it simply run on the root build dir:

make clean
tip

To sync the source again just run again repo sync, seen in Syncing the Source.

tip

To build the ROM again just follow steps from Starting Building.