[OnePlus 3T Guides, News, & Discussion] namanjr:
System Requirements

Arch Linux x86-64

Oxygen OS(extracted image or installed)

adb installed and drivers setup

non-root user

sudo setup for your user (you can install packages as root as a workaround)

40GB free storage

4GB+ ram

Required Packages

First off you're gonna want to make sure you're completely up to date and fetch the packages required to build, with the command below.

#sudo pacman -Syyu gcc-multilib git gnupg flex bison gperf sdl wxgtk squashfs-tools curl ncurses zlib schedtool perl-switch zip unzip libxslt python2-virtualenv bc lib32-zlib lib32-ncurses lib32-readline jdk7-openjdk rsync maven repo

Then you're going to need to fetch some apps from the AUR. First add their GPG key.

#gpg --keyserver pgp.mit.edu --recv-keys C52048C0C0748FEE227D47A2702353E0F7E48EDB

Now you can fetch them with a tool like yaourt or manually install the two packages.

lib32-ncurses5-compat-libs

ncurses5-compat-libs

#yaourt --aur lib32-ncurses5-compat-libs ncurses5-compat-libs

Setting up build enviroment and syncing

This part will assume you're building in a folder called "android" in your home directory, and requires the above packages to be installed.

Run these commands to install repo in a folder called "bin" in your home directory. Then for a single terminal session set the new "bin" folder as a binary folder in bash.

#mkdir ~/bin
#export PATH=~/bin:$PATH
#curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
#chmod a+x ~/bin/repo

Make a folder to store and build android, then enter it.

#mkdir ~/android
#cd ~/android

Setup a virtual python 2.7 enviroment in your "android" folder as repo doesn't work with 3+.

#virtualenv2 venv
#ln -s /usr/lib/python2.7/* ~/android/venv/lib/python2.7/
#source venv/bin/activate

Now it's time to sync the sourcecode with your python 2.7 and repo setup. The following code will sync CAF android 6.0.1 from oneplus. The "4" can be removed or replaced with any whole number becides zero depending on your connection speed. You may omit the "-c" if you have problems syncing or need more than the defined branches.

#repo init -u https://github.com/OnePlusOSS/android.git -b oneplus3T/6.0.1
#repo sync -j4 -c

You can also use my repo if you prefer. I'm working on improving the mess oneplus gave us.

#repo init -u https://github.com/droidman/android.git -b oneplus3T/6.0.1
#repo sync -j4 -c

Compile Your Build

Assuming your in your virtual python 2.7 and followed the first part of the guide, set openjdk 7 as your active java.

#export JAVA_HOME=/usr/lib/jvm/java-7-openjdk

Fix broken provided glib.

cp /usr/bin/ld.gold prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin/ld

If you're rooted and have adb installed, you may want to fetch your prebuilt files from the latest marshallow Oxygen OS or caf based rom. You may also extract them from a Oxygen OS system image but build will not complete without prebuilts.

#cp ~/android/.repo/manifests/pull_library.sh ~/android/pull.sh
#sh pull.sh

Intialize the enviroment and select a platform. You may build "msm8996-userdebug" or "msm8996-user".

#source build/envsetup.sh
#lunch msm8996-userdebug

Time to build! Find the number of threads on your cpu and set 1-2x that as "x". You may also omit "OTAackage" if you prefer to have fastboot/twrp flashable images instead of a zip, (system.img, boot.img, etc).

#make -jx OTApackage

Your compiled files and flashable zip or images will be located in "~/android/out/target/product/msm8996".

How to rebuild!

Cd into directory, sync repo, and setup enviroment.

#export PATH=~/bin:$PATH
#export JAVA_HOME=/usr/lib/jvm/java-7-openjdk
#cd ~/android
#source venv/bin/activate
#repo sync -j4 -c
#source build/envsetup.sh
#lunch msm8996-userdebug

Clean the out directory.

#make clobber

Build. (setup to make a recovery flashable zip with a 8 thread processor.)

#make -j16 otapackage