[OnePlus 3 Guides, News, & Discussion] matssa:
Hi guys!

I don't have a lot of knowledge in building android for phones, so please bear with me ;) I wanted to make this thread specifically for our 1+3, since there are a lot of different guides for specific devices.

My objectif is to build the unofficial CM13 sources directly from CM, except the proprietary files, which are not included (thanks [MENTION=975907]Planet X[/MENTION]). So since I'm a beginner, I'm gonna update this OP with the different steps.

As suggested by [MENTION=975907]Planet X[/MENTION], here is another guide which is pretty nice, very fast, but doesn't really explain what you are doing (good for people who wants to get something working fast or that has already some building knowledge): https://github.com/Seraph08/RosettaBuild

Steps

Step 1

: Getting Linux up (see http://xdaforums.com/chef-central/android/guide-android-rom-development-t2814763)

Step

: Installing the different apps like gcc, java, etc. (http://xdaforums.com/chef-central/android/guide-android-rom-development-t2814763 + https://wiki.cyanogenmod.org/w/Build_for_bacon)

Step 3

: Getting the repo synced (http://xda-university.com/as-a-developer/getting-started-building-android-from-source) with CM13.

--> Ok so after I went to a little party, when I came back it was finished. Buuuuuut I had some repo sync errors (couldn't fetch files). Still gonna continue, I'll come back later if I have any issues building or so. Furthermore, I used repo sync instead of using specific options like -c (which takes only the current branch) and -j 4 (number of connections). This means that I downloaded EVERYTHING... /facepalm

--> Ok so I tried to source build/envsetup.sh, but couldn't cause it doesn't exist. Soooo I'm gonna download the source again (yyaaayy!) with this time repo sync -c -j 4.

--> Apparently, when doing the repo sync stuff, CM already has a default line, which is the same that I manually did... So can't tell if my issue is going to be solved or not. Let's wait and see!

--> Ok so errors again. I created manually the local_manifest.xml in .repo and resyncing. I used [MENTION=7366950]proag[/MENTION] xml file. Let's see what happens!

--> I finally understood ^^ local_manifests is not a file but a folder in .repo. In this folder, you add roomservice.xml which points to the other gits. Gonna change this and then resync.

--> Ok, finally have the repo synced correctly (no errors anymore). The trick is to make the local manifest and re-sync afterwards.

Step 4

: Created local manifest and repo sync (https://wiki.cyanogenmod.org/w/Doc:_Using_manifests)

Step 5

: Ok so launched source build/envsetup.sh, no issues there. Launched breakfast oneplus3, no issues there as well. Launched brunch oneplus3 --> BANG, error! I knew it was too good to be true... Anyways, the error was concerning Java. I had 1.8 installed instead of 1.7. For CM13, there are two solutions: eother modify the sources in order to use java 1.8 OR instal java 1.7. I wanted to do the second, so I ran the following command: sudo apt-get update && sudo apt-get install openjdk-7-jdk

The good version of java is installed, now let's try to build!

--> Ok still not good, I had to remove the 1.8 version, so I used sudo apt-get remove open-jdk-8* and tada! Just launched brunch and it works. I won't let it run cause I need the PC, but I'll launch it tomorrow.

Step 6

: Launched the build during the night, but got an error after 2h: make failed to build some targets. Just before, I jave the following: make: fork: cannot allocate memory.

Sooo either I don't have enough RAM (8Gb), either I don't have enough disk space (150Gb). Gonna test out the RAM solution (increase the RAM of the VM).

--> Ok so I took a look in the ressources in Ubuntu and apparently, it isn't even using up all the RAM:

[IMG="Ressources"]http://i.imgur.com/jV1L6St.png[/IMG]

I'm using VMWare workstation 12 Pro (12.0.1) with Ubuntu 16.04 LTS. Anyone having this issue? Really thinking of dual-booting... Gonna let the build go on and see.

--> Ok so I think I'm gonna dual boot, it seems that all the resources are not well used by VMWare... At least, the build will go faster!

Step 7

: Ok so dual booting is easier and the build is faster. After 2h30 of building, success! With ccache enabled, I should reduce it by half at least. I'm now going to change the local-manifest in order to use TheMuppets proprietary files.

--> When repo-syncing, impossible since the work tree isn't the same. So had to repo sync --force-sync vendor/oneplus. The bad news is that it deletes everything for vendor/oneplus. The good news is that you don't need to downlaod all the full repo again, so it took about 5-10mins.

--> Now, doing breakfast and brunching again with this new work tree, let's see!

Step 8

: Build completed in 22min! That was fast! There weren't a lot of changes so kinda normal. Going to upload it on androidfilehost so that anyone can access it ;)

--> Uploaded, it took more time to upload than to build...

Next Step

: Generate a changelog (need help on this point) but not a big issue since it can be found on cmxlog.com/13/ for almost everything.

If anyone wants to help out, feel free to contribute! If we complete this thread, it may help out other users that want to start doing custom ROMs, or even start to do their own unofficial builds for specific devices!

Download latest build

I will use my personal builds and I won't be able to upload since I have a crappy upload connection. I suggest you use [MENTION=2154320]papi92[/MENTION] builds here: http://xdaforums.com/oneplus-3/how-to/unofficial-nightly-supported-t3406706

Sources

CyanogenMod/android_device_oppo_common

CyanogenMod/android_device_qcom_common

TheMuppets/proprietary_vendor_oneplus

CyanogenMod/android_device_oneplus_oneplus3

CyanogenMod/android_kernel_oneplus_msm8996

CyanogenMod/android_vendor_nxp-nfc_opensource_Nfc

CyanogenMod/android_vendor_nxp-nfc_opensource_frameworks

CyanogenMod/android_vendor_nxp-nfc_opensource_libnfc-nci

Thanks

Thanks to the following people for their help / sources, etc...

- XDA team

- CM team

- [MENTION=4443334]Grarak[/MENTION] for his sources, etc...

- [MENTION=975907]Planet X[/MENTION] for his help

- [MENTION=5216756]jackeagle[/MENTION] for his full guide on CM11

- [MENTION=5565132]Kishan14[/MENTION] for his guide on the custom repos / manifest

- TheMuppets repo tree for the proprietary files