{All 2011}[GUIDE][DEV] How to build CyanogenMod 11.0

mikeioannina

Recognized Developer
Mar 22, 2011
1,902
26,538
153
Ioannina
This thread is intended for devs & advanced users only.

Here you can learn how to build CyanogenMod 11.0 for any of the 2011 xperia devices.
I will use 'smultron' as an example device, you should replace the codename with the device you want to build.


For the first time you try to build CM11.0
Follow this guide up to "Initialize the CyanogenMod source repository" step (don't execute this step).
http://wiki.cyanogenmod.org/w/Build_for_smultron

Initialize the CyanogenMod source repository
Enter the following to initialize the repository:
Code:
cd ~/android/system/
repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
Get the required local manifest
Code:
mkdir -p ~/android/system/.repo/local_manifests
curl https://raw.githubusercontent.com/LegacyXperia/local_manifests/cm-11.0/semc.xml > ~/android/system/.repo/local_manifests/semc.xml
Download the source code
Code:
repo sync
Setup the build environment
Code:
. build/envsetup.sh
Download some commits from CyanogenMod gerrit which are not accepted yet
Code:
ln -s vendor/extra/updates.sh updates.sh
./updates.sh
Get the prebuilts
Code:
cd ~/android/system/vendor/cm
./get-prebuilts
Setup the build environment & prepare the device-specific code.
Code:
cd ~/android/system
. build/envsetup.sh
breakfast smultron
Build the ROM (takes long time)
Code:
brunch smultron
If the build finishes successfully, you will find the build here (change DATE into the date):
~/android/system/out/target/product/smultron/cm-11.0-DATE-UNOFFICIAL-LegacyXperia-smultron.zip


The next times you want to build, you only need to do the following:
Sync the repositories & make sure you are using the latest local_manifest.
Code:
cd ~/android/system/
curl https://raw.githubusercontent.com/LegacyXperia/local_manifests/cm-11.0/semc.xml > ~/android/system/.repo/local_manifests/semc.xml
repo sync
Setup the build environment
Code:
. build/envsetup.sh
Download some commits from CyanogenMod gerrit which are not accepted yet
Code:
./updates.sh
Build the ROM
Code:
brunch smultron
If the build finishes successfully, you will find the build here (change DATE into the date):
~/android/system/out/target/product/smultron/cm-11.0-DATE-UNOFFICIAL-LegacyXperia-smultron.zip


Steps to build only the kernel:
Sync the repositories.
Code:
cd ~/android/system/
repo sync
Setup the environment
Code:
. build/envsetup.sh
Download some commits from CyanogenMod gerrit which are not accepted yet
Code:
./updates.sh
Build the kernel
Code:
breakfast smultron
make -j4 bootimage
If the build finishes successfully, you will find the boot image here:
~/android/system/out/target/product/smultron/boot.img

Some suggestions for faster builds:
* Enable ccache
* Use the fastest hdd on your pc to store the source, build output & ccache
* You can also buy an ssd, if it's not large enough to hold everything, just store the build output & ccache
* mount /tmp on tmpfs (RAM).

The above have greatly improved my dirty build times with removed /out/target from 1h30m to 30m.
Mounting /tmp on tmpfs made the biggest improvement for me.


Credits: Thanks to hnl_dk for the initial CM9 & CM10 guides.
 
Last edited:

johnny.tifosi

Senior Member
Dec 11, 2012
96
25
0
Sorry for the noob question, first time builder here. You say you prepare the device specific code, but there is no official CM11 for 2011 Xperia. Where does this code come from? Do you upload somehow your ROMs to Cyanogenmod servers? If it is true, that means that if I build CM11 on my own I can get the latest features before you even release them with a nightly?
 

andogeek10

Senior Member
Apr 7, 2012
1,560
786
0
22
Mumbai
Sorry for the noob question, first time builder here. You say you prepare the device specific code, but there is no official CM11 for 2011 Xperia. Where does this code come from? Do you upload somehow your ROMs to Cyanogenmod servers? If it is true, that means that if I build CM11 on my own I can get the latest features before you even release them with a nightly?
Legacy Xperia maintains the device trees on github. All the respective devices have their codes there. No, the builds are not uploaded to CM servers. But, if you build CM11 at whatever respective time you build, the latest feautes merged till that time will be incorporated in the build.

Sent from my Xperia Mini Pro using XDA Premium 4 mobile app
 

johnny.tifosi

Senior Member
Dec 11, 2012
96
25
0
Hi,
For compile KitKat which better 32bit or 64bit Ubuntu ?
The link in the OP states:
"Note:

You want to use a 64-bit version of Linux. According to Google, 32-bit Linux environment will only work if you are building older versions prior to Gingerbread (2.3.x)/CyanogenMod 7. However, as of 10.1 CyanogenMod does not build with 64bit host binaries on some systems. You will have to set something like BUILD_HOST_32bit=1 in your environment when building on such 64bit system. "
 
  • Like
Reactions: r00lz

johnny.tifosi

Senior Member
Dec 11, 2012
96
25
0
Building stops after about 10 minutes with the following error: AttributeError: 'NoneType' object has no attribute 'group'.

Code:
target thumb C++: third_party_WebKit_Source_wtf_wtf_gyp <= external/chromium_org/third_party/WebKit/Source/wtf/ArrayBuffer.cpp
Traceback (most recent call last):
  File "../../base/android/jni_generator/jni_generator.py", line 1070, in <module>
    sys.exit(main(sys.argv))
  File "../../base/android/jni_generator/jni_generator.py", line 1066, in main
    options.optimize_generation)
  File "../../base/android/jni_generator/jni_generator.py", line 1001, in GenerateJNIHeader
    jni_from_javap = JNIFromJavaP.CreateFromClass(input_file, namespace)
  File "../../base/android/jni_generator/jni_generator.py", line 514, in CreateFromClass
    jni_from_javap = JNIFromJavaP(stdout.split('\n'), namespace)
  File "../../base/android/jni_generator/jni_generator.py", line 457, in __init__
    contents[1]).group('class_name')
AttributeError: 'NoneType' object has no attribute 'group'
make: *** [/home/johnny/android/system/out/target/product/urushi/obj/GYP/shared_intermediates/ui/gl/jni/Surface_jni.h] Error 1
make: *** Waiting for unfinished jobs....

Any help?
 

plethorahil

Senior Member
Jun 12, 2013
244
200
0
You will need more than 55 GB free space to build it from scratch ( Linux installation and everything else ).
I have no issues with storage ...cause ofd 1 tb hdd
but how much data i have to download to build it from scratch ?
Does everyone downloads that who build their own build ? !!
(Dont high speed bandwidths costs expensive in your countries ?)
 
  • Like
Reactions: sahil9701