Bliss OS/Compiling Bliss OS

From BlissWiki
Jump to navigation Jump to search

This is the official guide to build Bliss OS for PCs. In this guide, we will only cover building for x86 & x86_64 devices. We will also go over the details of using the patch system for testing and recompiling a build with a different kernel branch.

The golden rule to building is patience. If something breaks, pay attention to the console output or take logs of the issue and ask for guidance in our build support chat.

Let’s get started.

Requirements[edit]

A moderately powerful x86_64 platform machine is required to compile Bliss OS.

The minimum specifications are:

  • Any x86_64 CPU with at least two cores
  • 8 GB of RAM
  • 150 GB of storage

The recommended specifications are:

  • A CPU from the last 2-3 years with at least four or more cores
  • 16 GB of RAM
  • 200 GB of storage (preferably on solid state drives)

This page assumes your machine is already running a fresh copy of Ubuntu 18.04 (LTS), or a derivative, or similar. Builds on other distributions are not officially supported and may not work.

Dependencies[edit]

Install OpenJDK 8:

sudo apt install openjdk-8-jdk

Install required build tools:

sudo apt install git gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev lib32z1-dev ccache libgl1-mesa-dev libxml2 libxml2-utils xsltproc unzip squashfs-tools python python-mako libssl-dev ninja-build lunzip syslinux syslinux-utils gettext genisoimage bc xorriso liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-dev lzop maven pngcrush schedtool lib32readline-dev

Install repo:

mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

Add repo to the PATH by editing .bashrc. Scroll to the end of the file and add those lines:

# Export ~/bin
export PATH=~/bin:$PATH

To apply your changes to .bashrc, type:

source .bashrc

You can replace source with . for the same effect.

What is source?[edit]

source is a bash command to read aliases, functions, and commands from the specified file. Typically, you'll supply bash with a configuration file such as .bashrc or .bash_profile, or an initialization file such as envsetup.sh. The difference is that while the configuration file lists configuration and user-defined aliases and functions, initialization files typically hold build commands such as breakfast, brunch, and lunch. Without those commands building would be significantly harder as you would have to memorize the long command to invoke a build manually!

But why do you need to run it after modifying a file? Well, bash cannot automatically detect changes in our files. To solve this, we either source it or log out and log back in, forcing bash to reload configuration files. Keep this in mind, because unlike configuration files, if you forget to source initialization files, build commands will not function!

Downloading the source[edit]

You are now ready to download the source code for Bliss OS.

Create a directory for the source:

mkdir -p ~/bliss/q
cd ~/bliss/q

Before we download, we need to tell repo and git who we are. Run the following commands, substituting your information:

git config --global user.email "[email protected]"
git config --global user.name "John Appleseed"

Now, we’re ready to initialize. We need to tell repo which manifest to use:

repo init -u https://github.com/BlissRoms-x86/platform_manifest.git -b p9.0-x86

-b is for the branch, and we’re on q, Android 10. It’ll take a couple of seconds. You may need to type y for the color prompt.

Then sync the source:

repo sync -j$(nproc --all) -c

Note: For more information about the repo tool, visit the BlissRoms/Build Tips guide to learn more about the repo flags.

repo will start downloading all of the code. This will take a couple of hours, even on a fiber network. Go grab a coffee while you wait!

Build[edit]

Set up the build environment:

. build/envsetup.sh

This is the initialization file we talked about earlier up top. This "initializes" the environment, and imports a bunch of useful build commands required to build your device. Again, you need to remember to source this file every time you log out and log back in, or launch a new bash/Terminal instance.

Define what device you’re going to build. For example, the Nexus 5X, has a codename of bullhead. You can check your specific device's codename on GitHub or on Google. Execute:

breakfast bullhead

What does this do? breakfast searches repositories for your device "tree", which contains all the details needed to make the build suitable for your device. CPU, kernel info, device screen size, whether the board has Bluetooth, NFC, what frequencies the build needs for Wi-Fi, and a bunch of other things. breakfast will automatically search in the BlissRoms-Devices GitHub repository, and grab your device tree for you.

Once the device trees have been downloaded, feel free to browse around the source code to see what changed. You should see folders added to device/, kernel/ and vendor/. If you want to return to the root of the source code, execute:

croot

This command, however, requires you to have sourced build/envsetup.sh earlier.

We're ready to build, but before we use the easy command to execute a build, we will first try the manual method. To set up the current terminal environment for building your particular device, execute:

lunch bliss_bullhead-userdebug

Let's break down the command. lunch initializes the proper environmental variables required for the build tools to build your specific device. Things like BLISS_DEVICE and other variables are set in this stage, and the changed variables will be shown as output. bliss is the ROM that we are building. As convention, all devices will have this prefix. bullhead is the specific device we are building - in this case, the Nexus 5X. Finally, userdebug means that we will build a "user-debuggable" variant. This is usually what most ROMs use for publishing their builds. Manufacturers typically use user, which disables a lot of logging functions and other debugging features.

My device isn't booting, and userdebug won't print any adb logcats. What gives?[edit]

There is a third build variant called eng, short for "engineering builds". These builds will activate adb logcat during boot, and will show you exactly what is going wrong, where, and why. However, these builds are NOT recommended for normal usage as they are not securely hardened, have log spam that will slow down your device, and other unexpected problems like userspace utilities crashing during runtime. If you want to submit your device for mainline, do NOT submit an eng build!

All set? Let's start the building process. Run:

mka blissify

And the build should start. The build process will take a long time. Prepare to wait a few hours, even on a decent machine.

Why mka and not make?[edit]

make only runs with 1 thread. mka is properly aliased to use all of your threads by checking nproc.

If you want to customize your thread count (maybe you're building with a fan-screaming laptop in a quiet coffee shop), use make blissify -j#, replacing the hash with the number of threads (example: make blissify -j4).

I get an error about no blissify target to build against; what's wrong?[edit]

If you are building other ROMs, it is usually make bacon. For BlissRoms, we chose the build target of blissify. If that doesn't work, sometimes there is a bug, or the ROM developers do not implement a bacon target to build against. In this case, you will need to find what name they use to initialize a full build of the ROM. Conventionally, it is supposed to be bacon, but some ROM developers change this name, or their build system may actually have a bug that causes the build target to not be found. If you cannot locate the build target, ask the developers of the ROM. Alternatively, you can try poking around in build/make/core/Makefile to see what the build target name is. But this is out of the scope of this article as you're not supposed to be building other ROMs (that's not what this tutorial is for, sorry!)

All right, but that's annoying. You had to type three commands to build it all. What about running one command?

blissify bullhead

But what is blissify? It is a compact form of these commands:

breakfast bullhead
lunch bliss_bullhead-userdebug
make blissify

Note that on other ROMs this command will usually be brunch. Once you have run the command, jump over to the next section.

After building[edit]

There are two outcomes to a build - either it fails and you get a red error message from make, or it succeeds and you see the Bliss logo in ASCII. If you encounter the former, you need to go back and fix whatever it's complaining about. Typically, 90% of the time the problem will be in your device tree. For the other 10%, submit a bug report to the ROM developers. Be sure to include the full log of your build to help diagnose the problem, and your device tree.

If you face the latter, congratulations! You've successfully built BlissRoms for your device. Grab the artifacts for your device:

cd out/target/product/bullhead/

In here, you’ll find a .zip that goes along the lines of Bliss-v11.9-Stable-bullhead-UNOFFICIAL-20190531.zip. Install TWRP, flash the build to your device, and enjoy!

Troubleshooting[edit]

If your build failed, there are a couple things you can try.

  • Try a fresh repo sync to make your repository up to date. Sometimes, the Internet connection between you and GitHub can be flaky. In rare cases a commit merge might be ongoing, and you might've grabbed an incomplete merge. This should fix the issue 70% of the time.
  • Make sure your dependencies are installed correctly. Error messages help out a lot here! Often it will say shared/linked library not found or something along those lines.
  • Make sure you sourced build/envsetup.sh. This is especially common and worth suspecting if none of the build commands like breakfast and lunch work. If you have repo synced do this again.
  • Make sure you’re at the root of the build tree. Again, to quickly jump there, use croot.
  • Make sure you ran breakfast correctly and it did not error out. Missing device files will prevent successful builds.
  • Make sure your computer meets minimum requirements to compile AOSP. Chances are, you need more memory/CPU power to complete a build. Some users are often confused, as the builds will appear to start and work on a under-specification machine, but crash or stop midway with no apparent cause. If this happens, you will probably need better hardware, or you will need to tweak your configuration so that the build will progress normally on your under-spec machine (not recommended).
  • Make sure your computer isn't faulty. This is unlikely, but to check, use a stress-test program like Prime95.

If something goes wrong and you've tried everything above, first use Google to look up your error! Most of the errors you encounter is due to misconfiguration and wrong commands entered. More often than not, Google will have the answer you are looking for. If you're still stuck and nothing fixes the problem, then ask us via our Telegram Build Support chat. (Please only ask issues about BlissRoms, not other custom ROMs as we are unable to assist with those!)

Conclusion[edit]

Building a ROM is very hard and tedious and the results are very rewarding! If you managed to follow along, congratulations!

After you finish building, you can try out the Git Started guide. Make changes, commit, and send them off to our Gerrit for review! Or better yet, download experimental commits not ready for the mainline repositories and review them! Again, ROM building is a fun project you can work with. I hope this guide was a lot of fun to run through!

-- Eric Park (ideaman924)