Building stable/CM-13 for N00Bs

DavidXanatos

Senior Member
Mar 22, 2013
284
155
0
Vienna
Given how hard it is to find build instructions around here and once you find some that work and are easy to follow you realize they are buried at least on page 9 or later..
I thought I'll make a thread that guides the user in a simple step by step manner from setting up a VM to finishing the CM 13 build.
A thread that will provide all the needed information in the very first post and where thinking is only optional while following the instructions.

But don't worry I will also include some explanations as far as I think to understand the whole matter myself.

==================================================

So lets start first we need to have a machine on which we want to compile. The CM guide https://wiki.cyanogenmod.org/w/Build_for_oneplus3 is not wrong as far as I could tell but it omits crucial steps.
For example it does not tell you where to get the required openjdk-7-jdk as well as some other thinks I will elaborate later on.
The easiest way to get a machine ready to build CM is to download a image of http://bbqlinux.org/

So Step 1.) download https://sourceforge.net/projects/bbqlinux/files/x86_64/bbqlinux-2016.06.19-x86_64-mate.iso/download and install it. It comes with all the pre requirements for building cm13 already installed and it even contain vmware tools (and possibly other VM integration) out of the box.
It has all the right java version android studio, all the libraries and even the repo tool installed.

You can almost right away start with step 2 you only need to config git,y taping the following two commands in a terminal window
Code:
git config --global user.email "[email protected]"
git config --global user.name "me"
==================================================

The Step 2.) is getting a copy of CM sources on the machine.
Create a folder where you want the sources to reside for example ~/Android/cm-13.0 but really it can be any folder you have write permissions to. Than you cd into that folder and initialize the source repository.

Code:
repo init -u https://github.com/CyanogenMod/android.git -b stable/cm-13.0-ZNH5Y
This will prepare you for obtaining the sources of a stable build marked as ZNH5Y if you want an other build just go to https://github.com/CyanogenMod/android and browse through the available brunches so for example to build the latest nightly you would use: "-b cm-13.0" instead of "-b stable/cm-13.0-ZNH5Y"

This call creates a hidden sub folder inside your current directory ".repo"

==================================================

Now we are set up to download the generic cm-13 sources but first we need to add customizations for our specific device. This is done by adding a *.xml file to "./.repo/local_manifests" the default name is roomservice.xml but the cm guide says the name does not meter so you could call it whatever.xml and it should work also.

So Step 3.) add roomservice.xml to "./.repo/local_manifests/", a working one is
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <project name="CyanogenMod/android_device_oppo_common" path="device/oppo/common" remote="github" />
  <project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github" />

  <project name="TheMuppets/proprietary_vendor_oneplus" path="vendor/oneplus" remote="github" />

  <project name="CyanogenMod/android_device_oneplus_oneplus3" path="device/oneplus/oneplus3" remote="github" />
  <project name="CyanogenMod/android_kernel_oneplus_msm8996" path="kernel/oneplus/msm8996" remote="github" />

  <project name="CyanogenMod/android_vendor_nxp-nfc_opensource_Nfc" path="vendor/nxp-nfc/opensource/Nfc" remote="github" />
  <project name="CyanogenMod/android_vendor_nxp-nfc_opensource_frameworks" path="vendor/nxp-nfc/opensource/frameworks" remote="github" />
  <project name="CyanogenMod/android_vendor_nxp-nfc_opensource_libnfc-nci" path="vendor/nxp-nfc/opensource/libnfc-nci" remote="github" />

</manifest>
With the file in place we can download the sources, just execute

Code:
repo sync

An alternative to creating a local manifest would be, after you have synced without a own local_manifest file, to run

Code:
source build/envsetup.sh

breakfast oneplus3
This should build a similar roomservice.xml on its own. Ho weever this would be missing some key files namely TheMuppets/proprietary_vendor_oneplus this repo provides OEM blobs which are required for CM to build.

The CM guide advises you how to get those blobs from a phone that already runs CM13 but that is IMHO very not elegant as you have to flush your device with some one else CM build only to get a few files which you can easily download of the internet.

You can run "repo sync" without a roomservice.xml than the "breakfast oneplus3" as described above, don't forget envsetup, and once it finished downloading he additional repositories you can add the following line to the created ./.repo/local_manifests/roomservice.xml
Code:
  <project name="TheMuppets/proprietary_vendor_oneplus" path="vendor/oneplus" remote="github" />
and resync the repo by executing
Code:
repo sync --force-sync
==================================================

Now after the sync we have all we need to build CM on our HDD, and we can start the build process.

if you want to speed up later build processes you can add "export USE_CCACHE=1" to your ~/.bashrc file, for example using "nano ~/.bashrc" and than executing "prebuilts/misc/linux-x86/ccache/ccache -M 50G" after having synced your repo, you don't have to re do it after each sync later.

So Step 4.) type the following commands in your terminal window

Code:
source build/envsetup.sh

brunch oneplus3
If you have a problem with the build (eider it fails or it builds but the binary does not work) possibly after changing some source files or repositories, you should run "make clobber" just before running "brunch oneplus3"

==================================================

And that is it once it finishes you should have a cm-13 zip ready to be flashed.
 
Last edited:

Drakorcarnis0

Senior Member
Jul 11, 2014
224
67
0
26
Paris
Hello ! I'm trying to build cm14.0 with official sources and TheMuppets vendor, but I get an error at the begining of the build. Anyone has an idea (this is my first build, please be patient). Here is da output
after brunching, in the attached log.txt. I use jdk 1.8.
 

Attachments