[UTILITY][09/01/2014] Build CM, PA, OMNI or AOKP on OS X - OS X Build Version 2 ! - Android Software Development

Based on frostincredible Script
OS X Build Version 2 - By Ptichalouf
I Will add so Many Team !
So you want to build AOKP, PA, OMNI or CM on OS X?
Well worry no longer my friends,
it is about to get a whole lot easier. Why is that?
Because this script I've written will do pretty
much everything for you, from creating the case sensitive DMG to installing the required files,
to setting up all the folders.
The best part? It also will initialize the AOKP or CM repo (depending
on your choice) and you can also build them straight from the script!
How fantastic is that?!
Simply read on to see how! Make sure to follow all the instructions (there aren't many)!​
Follow these steps:
Install required files (MUST install MacPorts first) MacPorts available free at www.macports.org and Xcode : here Run 1 time Xcode !
Go here and download OS X Build (OSX_Setup.zip) - DOWNLOAD
Place the ZIP file on your Desktop.
Extract the ZIP to your Desktop.
Here comes the only tricky part. Open the file located at OSX_Setup/scripts/advanced_scripts/build_cm or build_aokp, whichever you're going to build.
Find this line -
Code:
HTML:
# BELOW IS THE ONLY LINE YOU SHOULD BE EDITING. REPLACE *YOUR DEVICE* WHITH YOUR DEVICE'S CODE NAME. EX - NEXUS 7 = "grouper"
Just below that, edit this line with the instructions in the one I just posted -
Code:
HTML:
cp /Volumes/Android/OUT/target/product/*YOUR DEVICE*/aokp_*YOUR DEVICE*-ota-eng.$ME.zip /Volumes/Android/Builds/AOKP_$ME.$NOW.zip
IT IS IMPORTANT THAT YOU DON'T EDIT ANYTHING ELSE.
Open your favorite Terminal application (the default on is Terminal located at /Applications/Utilities/Terminal).
cd to the OSX_Setup folder on your Desktop.
Code:
HTML:
cd /Users/YOUR NAME/OSX_Setup
HTML:
$ git config --global user.email "[email protected]"
HTML:
$ git config --global user.name "YourName"
Run the following -
Code:
HTML:
./runme
After running this, you will be presented with the following menu -​
Code:​============================================================
OS X Build Set Up 1 - based on Kyle Frost
By [email protected]
============================================================
---Main Menu---
1 - Create DMG
2 - Install required files (MUST install MacPorts first)
MacPorts available free at www.macports.org
3 - Set up folders
WARNING: DO NOT RUN ADVANCED MENU UNTIL
YOU HAVE RUN ALL 3 ABOVE, OR HAVE DONE
THEM ALL MANUALLY. THANK YOU.
0 - Advanced Menu
x - Exit
Enter option:
As you can see, you need to go here and install MacPorts before proceeding - MacPorts
After installing MacPorts you can go ahead and run everything.
Create DMG will give you the options of creating a 25GB, 30GB, 40GB, 50GB, 60GB or 120GB DMG. 25GB is the lowest recommended by the Android Team.
Install required files will simply do just that, it will install the files needed as specified in the AOSP documents. This can take a while, so go take a nap while it runs.
Set up folders will give you the option of setting up the folders for AOKP or CM10.1. Simply choose which you want and the folders will be created.
Choosing Advanced Menu will give you this - ​
Code:
============================================================
OS X Build Set Up 1 - based on Kyle Frost
By @ptichalouf
============================================================
---Advanced Menu---
MUST INSTALL XCODE BEFORE BUILDING!
XCODE IS FREE IN THE MAC APP STORE!
1 - Initialize AOKP Repo
2 - Initialize CM11 Repo
3 - Initialize Paranoid Repo
When building, it will give you a list
of devices. Enter the number for your device
configuration and the build will continue.
It will take a while the first time, as the
source must first completely download.
4 - Build AOKP
5 - Build CM11
6 - Build Paranoid
Note: When the build is complete, you can
find the finished ZIP in the Builds
folder on your Android disk image.
0 - Go to Main Menu
Enter option:
There you can see you need to install Xcode, if you haven't already. It is free in the Mac App Store (this script is for OS X, you know).
All the options are pretty self explanatory. Make sure you have run the folder set up for the ROM which you wish to build first. Run the initialize option for your desired ROM before running the build option.
That is it! After the build has done (takes a while the first time you set all this up, much faster the next few times) you will be able to build your own nightly's, or whatever you so desire! Have fun!
NOTE: If you have an error regarding "Xcode" and the "10.6 SDK" when trying to build, download the MacOSX10.6.sdk.zip, decompress it, and place it in "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/".
Disclaimer: This will only work with devices that are officially supported by AOKP PA or CM Team If your device is not supported by their official repos, either wait to see if it is, try to edit my script to get the repo your device's tree is on, or wait until I get around to writing a tutorial on how to add custom repos.​

Update :
V2 : Now we have :
AOKP :
Repo KitKat
Repo JB MR2
Repo JB MR1
CM :
Repo CM 11
Repo CM 10.2
Repo CM10.1
Paranoid KitKat
OMNI :
Repo KitKat
Repo 4.3

For me ...

Any return ?

V3 :
echo "============================================================"
echo " OS X Build $version - based on Kyle Frost"
echo " By @ptichalouf"
echo "============================================================"
echo
echo " ---Advanced Menu---"
echo
echo " MUST INSTALL XCODE BEFORE BUILDING!"
echo " XCODE IS FREE IN THE MAC APP STORE!"
echo
echo " 1 - Initialize AOKP Repo"
echo " 2 - Initialize CM Repo"
echo " 3 - Initialize PARANOID Repo"
echo " 4 - Initialize OMNI Repo"
echo " 5 - Initialize LIQUID Repo"
echo " 6 - Initialize CODENAME Repo"
echo " 7 - Initialize CARBON Repo"
echo
echo " 0 - Go to Main Menu"
echo
echo -n "Enter option: "
And Linux version

V3 & Linux
--

Related

Ubuntu Setup Notes for Dev (kitchen) work - UPDATED 2/26

Update 2010-02-26 Added examples for linking either dynamically or statically (see page 2)
I decided to try and set up a kitchen using the closest thing to a native kernel dev environment that I could set up.
At this point I have:
- cross-compiled the HTC Desire (kernel) sources using the Android 1.6 NDK
- figured out the repo/git stuff to pull the Android sources corresponding to a given Android release point
- cross-compiled the entire Cupcake release to an ARM target using the NDK tools
- built a dynamically linked "hello, world" executable using the NDK arm-eabi-* tools and verified it works on the phone.
Yah, I know - not much yet, but it's a start for a newb.
I have some notes documenting the Ubuntu setup process in case anyone wants it - but it is full of links (URLs), so I can't post anything with links as a new user.
If a mod can "verify" my account, I'll post it up. I promise, I'll be good.
bftb0
OK, I guess I need to make a couple of posts before I can embed links.
I'll post it without the URL protocol prefix (it's gonna look fugly), and then come back and edit it once the restriction is removed. I hope someone finds it useful.
Android kernel dev is not officially supported on Windows; closest match to Google Dev environment seems to be -> Ubuntu 8.04 LTS + JDK 5 (32 bit, not x64).
I realize that this is nothing close to the "kitchens" that the WinMo folks have been using, but figured that (as a newb) I would just end up confusing myself trying to figure out which of those tools could be useful for Android, in addition to needing the native binary cross-compilation tools anyway.
(Note: I briefly tried to set this up in a Ubuntu VMware Player VM, but ran into limitations of available Ubuntu 8.04 LTS player machine file size limits (as well as problems hosting a VM bigger than about 10 Gb on a USB drive - insufficient space on my primary drive)
If anyone wants to follow in my footsteps, here is a thumbnail sketch of useful links. I'll admit, this is not for the faint of heart - you need Linux/Unix skills to work through the kinks.
1) (ubuntu.com/getubuntu/downloadmirrors#mirrors) Ubuntu Download Mirrors list - Find a server near you
2) Download ubuntu-8.04.4-alternate-i386.iso and burn it to 700 Mb CD-R
3) Install Ubuntu 8.04 LTS Desktop Version (gulp!)
4) Use the Ubuntu graphical package manager (System -> Administration -> Synaptic Package Manager) and install the packages (git, flex, bison, etc) mentioned in the "Ubuntu Linux (32-bit x86)" section in this (source.android.com/download)Android Source setup page
5) Note that JDK6 does not work correctly; rather than going to Sun/Oracle for JDK5, install the sun-java5-{bin,jdk,jre,doc,demo} packages (1.5.0-22-0ubuntu) using the Ubuntu package installer mentioned above. Note if you install the docs package, you will also need to go to Sun/Oracle and get jdk-1_5_0-doc.zip towards the end of the package install, and drop it into /tmp for the package manager to finish.
6) Go to the (developer.android.com/sdk/index.html) Android SDK Download page and get android-sdk_r04-linux_86.tgz
7) Unpack ( gunzip -c and...tgz | tar xf - ) to desired location, add tools dir to PATH
Optional Steps (For Java App Devs)
o-8) (eclipse.org/downloads/ Eclipse IDE Download page - chose 'Eclipse Classic 3.5.1 (162 MB)' for Linux, 32 bit (eclipse-SDK-3.5.1-linux-gtk.tar.gz)
o-9) Install by unpacking ( gunzip -c ecli....tar.gz | tar xf - ) to desired location, add eclipse folder to PATH
o-10) Run eclipse, and follow the (developer.android.com/sdk/eclipse-adt.html) Installing and Updating ADT instructions for adding Android functionality to Eclipse 3.5 (Galileo)
o-11) From within Eclipse, launch Window -> Android SDK and AVD Manager, and install all available & compatible Android SDK Tools (all versions). (You might need to use http instead of https... YMMV) Note that this is the same functionality as simply running the command "android" from the command prompt if the Android SDK (steps 6,7) tools directory is in your PATH
12) Familiarize yourself with the command line tool "adb" tool in the SDK; in particular, since Ubuntu needs root privs to access the USB hardware, the best way to start the adb server on your PC is to
Code:
$ sudo /bin/bash
- set up root's environment so the SDK "tools" directory is in root's PATH
- plug your phone into the USB cable
- On the Eris, set the options:
Settings -> Applications -> Development -> USB Debugging (on)
Settings -> Applications -> Development -> Stay awake (on)
Code:
# adb devices
This last command only lists the available USB-connected (real) devices and any emulators you have running, but as a side effect it starts up the adb server on the Ubuntu machine running as root. Thereafter, you can use adb (or ddms) as an unprivileged user.
13) Have a peek at the SDK "ddms" monitor. A variety of things can be done from here, the least of which is screen shots (Select device, then Device-> Screen capture)... and some more twisty things too.
14) Download the (developer.android.com/sdk/ndk/1.6_r1/index.html) Android 1.6 NDK r1 (Native Development Kit) - android-ndk-1.6_r1-linux-x86.zip, and unzip into your desired location. Add the ARM cross-compiler tools to your path (see example below).
15) At this point you might be using something like this to set up your path wherever you please (.profile or elsewhere, according to how you want to manage your environment)
Code:
_INSLOC='/opt/android/'
_JAVAPATH='/usr/lib/jvm/java-1.5.0-sun/bin'
_BASEPATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
_ANDTOOLS="${_INSLOC}"'/android-sdk-linux_86/tools'
_ECLPSPATH="${_INSLOC}"'/eclipse-3.5.1'
_ARMXCOMPILE="${_INSLOC}"'/android-ndk-1.5_r1/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin'
PATH="${_JAVAPATH}"':'"${_BASEPATH}"':'"${_ANDTOOLS}"':'"${_ECLPSPATH}"':'"${_ARMXCOMPILE}"
export PATH
16) Download the (member.america.htc.com/download/RomCode/Source_and_Binaries/desirec-be918f7b.tgz) HTC Desire Kernel Source Code and unpack to a location of your choice.
17) Test your enviroment by building the HTC Kernel code:
$ cd v2_6_27/kernel_msm7k; make
I can't remember if I needed to stuff anything into the environment here (e.g. 'CC' definitions, etc.) - but I know that I didn't need to modify any Makefiles. I think the make system will find all the "arm-eabi-*" executables if they are in your path. You will know soon enough.
18) Try to compile a "Hello, world!" program for the phone. Before you get too far along in this (e.g. "where is crt0.o?"), (honeypod.blogspot.com/2007/12/dynamically-linked-hello-world-for.html) read this blog post - steps 3 and 4 only.
You might find a Makefile similar to this useful:
Code:
AR = arm-eabi-ar
AS = arm-eabi-as
CC = arm-eabi-gcc
CXX = arm-eabi-c++
LD = arm-eabi-ld
NDK_KIT = /opt/android/android-ndk-1.5_r1
PLATF_KIT = build/platforms/android-1.5
ARM_INC = $(NDK_KIT)/$(PLATF_KIT)/arch-arm/usr/include
ARM_LIB = $(NDK_KIT)/$(PLATF_KIT)/arch-arm/usr/lib
PLATF_INC = $(NDK_KIT)/$(PLATF_KIT)/common/include
OBJS = hello.o start.o
EXES = hello
hello: hello.o start.o
$(LD) \
--entry=_start \
--dynamic-linker /system/bin/linker -nostdlib \
-rpath /system/lib -rpath $(ARM_LIB) \
-L $(ARM_LIB) -lc -o hello hello.o start.o
hello.o: hello.c
$(CC) -I $(ARM_INC) -I $(PLATF_INC) -c hello.c
start.o: start.c
$(CC) -I $(ARM_INC) -I $(PLATF_INC) -c start.c
clean:
rm -f $(OBJS) $(EXES)
and then
Code:
$ make hello 2>&1 | tee make_hello-log.txt
if all goes well, push to the phone
Code:
$ adb push hello /sqlite_stmt_journals/hello
and then use a shell on the phone to watch the lights gerblinken:
Code:
PC-path$ adb shell
$ cd /sqlite_stmt_journals
$ ./hello
Hello, world!
$ exit
PC-path$
19) Now, download the Android stock kernel sources:
- Make sure you have "git" and "repo" installed; see the (source.android.com/download) Android "Get source" page, starting from "Installing Repo".
- Make a clean directory to initialize "repo" in, and download the code:
Code:
$ mkdir ~/mydroid
$ cd ~/mydroid
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
$ repo sync
The sync step above will download the entire source tree corresponding to the Cupcake release (90 minutes on my link).
20) Build the sources
Code:
$ cd ~/mydroid
$ make 2>&1 | tee make_Android-log.txt
On my old PC, this step took about two hours.
Well, that's a little start; everything that comes after this is heavy lifting, I suppose.
bftb0
Thank you for that.
I forgot to add a disk space usage report to this; here it is:
O/S ( /, /boot, /var, /tmp) ~ 4 Gb **
Android SDK, all versions: 1.3 Gb
Android "Cupcake" full sources + full build: 5.5 Gb (2.5 Gb sources, 3.0 Gb build tree)
Android NDK ~0.05 Gb
Eclipse 3.5.1: 0.21 Gb
HTC Desire Kernel Sources + build ~ 0.77 Gb
All up, thats about 12 Gb minimum needed for a full environment. Obviously, you would want some headroom above that.
Note that if you only want to build native binaries, and not the full Android source tree (or develop Java applications), this could be done handily in a virtual machine which is less than 10 Gb in size - for Windows users, there are VMware "Player" versions of Ubuntu 8.0.4 available for that. That eliminates the need for a separate machine, or a dual-boot PC - and the worries of messing up trying to create a dual-boot machine.
All that is really needed for that is the Desktop OS and the NDK. Adding a single version of the SDK so you have 'adb' and 'ddms' available to you would be helpful, but not absolutely necessary if you are using a Windows host machine with those tools already present.
bftb0
** beware that Ubuntu uses a lot of space on /var if you put it in a separate partition - 600+ Mb in my configuration.
bftb0 said:
I forgot to add a disk space usage report to this; here it is:
O/S ( /, /boot, /var, /tmp) ~ 4 Gb **
Android SDK, all versions: 1.3 Gb
Android "Cupcake" full sources + full build: 5.5 Gb (2.5 Gb sources, 3.0 Gb build tree)
Android NDK ~0.05 Gb
Eclipse 3.5.1: 0.21 Gb
HTC Desire Kernel Sources + build ~ 0.77 Gb
All up, thats about 12 Gb minimum needed for a full environment. Obviously, you would want some headroom above that.
Note that if you only want to build native binaries, and not the full Android source tree (or develop Java applications), this could be done handily in a virtual machine which is less than 10 Gb in size - for Windows users, there are VMware "Player" versions of Ubuntu 8.0.4 available for that. That eliminates the need for a separate machine, or a dual-boot PC - and the worries of messing up trying to create a dual-boot machine.
All that is really needed for that is the Desktop OS and the NDK. Adding a single version of the SDK so you have 'adb' and 'ddms' available to you would be helpful, but not absolutely necessary if you are using a Windows host machine with those tools already present.
bftb0
** beware that Ubuntu uses a lot of space on /var if you put it in a separate partition - 600+ Mb in my configuration.
Click to expand...
Click to collapse
great very descriptive thread
Hey bftb0
thanks for posting this guide. I am trying to just play around with someone of the exploit binaries on my eris (from the tattoo/hero rooting threads) , so these guidelines are coming in handy. However for some reason whenever I try and do anything over adb i get this error:
Code:
error: insufficient permissions for device
I cant use adb shell at all, even trying to push to the sdcard gives permissions denied. In the adb devices output the phone is coming up as "?????? no permissions", Did I miss a step ?
My setup so far: Ubuntu 9.10 i386,
Hey bftb0
thanks for posting this guide. I am trying to just play around with someone of the exploit binaries on my eris (from the tattoo/hero rooting threads) , so these guidelines are coming in handy. However for some reason whenever I try and do anything over adb i get this error:
Code:
error: insufficient permissions for device
I cant use adb shell at all, even trying to push to the sdcard gives permissions denied. In the adb devices output the phone is coming up as "?????? no permissions", Did I miss a step ?
My setup so far: Ubuntu 9.10 i386, android-sdk_r04-linux_86, droid eris with most recent OTA
someguy, you have to go to developer.android.com/guide/developing/device.html and install the linux driver (as root) and restart your system.
@someguy
Type "adb kill-server" followed by "sudo adb". You need to run adb as root in unix for it to work.
zifnab06, that was it, I must have not run the first command as root which caused the server to be run without su.
What exactly does this do?
bigcj55 said:
What exactly does this do?
Click to expand...
Click to collapse
Because of the lineage between Linux and Android, the primary platform for compilation of the kernel and other ARM instruction-set binaries ("native" code) has been on Linux. It appears (at the moment...reading between the lines) that Google engineers are using Ubuntu 8.04 LTS as their choice of Linux platform for maintaining Android kernel & utilities code... so, in principle, it is the "best supported" platform for doing "native" development work, if for no other reason than it's what Google has been using. (Not because it is somehow a "better" O/S, but rather because you are likely to run into fewer quirks, and have more resources on the internet who might have experienced the same difficulties that you run into.)
For instance, the folks that have been building kernel exploit programs have been using the Google "NDK". They are not writing/compiling those in Java - they are writing or compiling programs written in "C", and compiling them into native (ARM) object code.
I provided notes from my own installation for anyone considering "dipping their toe" into building Android kernels or native binaries using Linux as a host O/S - most forum readers are not going to be interested in doing that.
Note that Google now releases an NDK for Windows, Linux, and Mac OS/X. The strange thing about doing development on Windows using Cygwin is that if you have sufficient skills to do so - and are capable of resolving problems that inevitably crop up - then you probably already have sufficient skills to be using Unix/Linux in the first place. Sort of depends on your past experience, though. I'd be willing to bet that Devs with a history of doing WinMo development probably would prefer to climb the Android development learning curve by trying their hand with the Windows/Cygwin NDK because of their familiarity with other Windows-based development tools (IDEs, hex editors, assemblers, GUI generators, etc).
That reminds me though - I need to update this thread with something else.
Cheers
bftb0
Static OR Dynamic Linking of Native Binaries
I was a little unsatisfied with the "hack" used in the above examples to circumvent the need to launch programs without linking to C runtime initialization using that strange code shown above, i.e.
Code:
start() { exit( main() ); }
Moreover, for purposes of debugging applications running on the phone (using "gdbserver"), it simply seems easier to link statically - it allows you to step into the syscall library routines and actually see the assembler implementations wrapped around "STI" interrupts.
So, I spent some time experimenting, and came up with a Makefile that allows me to easily toggle between building an ARM executable linked statically or dynamically. Moreover, it lets "argc" and "argv" work they way they are supposed to, and also allows main() to do a return().
Here's an example Makefile, for a program "hello.c". Make sure you read the notes which follow it.
Code:
#
# FIX THESE (to match your installation)
# Top of the Android Source/build tree (retrieved w/ repo)
ANDSRCROOT := /home/user/android/repo-root
# link dynamically against the libraries shipped on the phone!
# e.g.: $cd /opt/android/Eris_libs/ruu1_16_605_1 ; adb pull /system/lib/
PHONELIBS := /opt/android/Eris_libs/ruu1_16_605_1/lib
# Choose one or the other; static is easiest for debugging use
LINKMODE := dynamic
#LINKMODE := static
# tools
CROSS_COMPILE := arm-eabi-
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
AR := $(CROSS_COMPILE)ar
CXX := $(CROSS_COMPILE)c++
OBJDUMP := $(CROSS_COMPILE)objdump
RANLIB := $(CROSS_COMPILE)ranlib
READELF := $(CROSS_COMPILE)readelf
# Note STATLIBROOT is relative to the Android Source root (ANDSRCROOT)
STATLIBROOT := out/target/product/generic/obj/STATIC_LIBRARIES
INCLUDE := -I $(ANDSRCROOT)/bionic/libc/include \
-I $(ANDSRCROOT)/bionic/libc/arch-arm/include \
-I $(ANDSRCROOT)/bionic/libc/kernel/common \
-I $(ANDSRCROOT)/bionic/libc/kernel/arch-arm
ifeq ($(LINKMODE),dynamic)
LIBDIRS := -L $(PHONELIBS)
else
LIBDIRS := -L $(ANDSRCROOT)/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1 \
-L $(ANDSRCROOT)/$(STATLIBROOT)/libc_intermediates \
-L $(ANDSRCROOT)/$(STATLIBROOT)/libc_common_intermediates
endif
ifeq ($(LINKMODE),dynamic)
CRTBEG := $(ANDSRCROOT)/out/target/product/generic/obj/lib/crtbegin_dynamic.o
LDFLAGS := -rpath /system/lib -rpath-link /system/lib --dynamic-linker /system/bin/linker
EXTLIBS := -lc -ldl
else
CRTBEG := $(ANDSRCROOT)/out/target/product/generic/obj/lib/crtbegin_static.o
LDFLAGS := -static
EXTLIBS := -lc -lgcc -lc_common
endif
CRTEND := $(ANDSRCROOT)/out/target/product/generic/obj/lib/crtend_android.o
CFLAGS := -g -Wall
%.o: %.c
$(CC) -c $(INCLUDE) \
$(CFLAGS) $< -o [email protected]
%.s: %.c
$(CC) -S -c $(INCLUDE) \
$(CFLAGS) $< -o [email protected]
all: hello
hello: hello.o
$(LD) $(LDFLAGS) \
-o [email protected] --entry=_start -nostdlib \
$(CRTBEG) \
$^ \
$(CRTEND) \
$(LIBDIRS) $(EXTLIBS)
This makefile has certain assumptions built into it:
(1) Static Linkage
If you are going to link statically, you will need to have already built the entire Android source tree - the Android NDK does not provide any static libraries (In the OP I provided instructions on how to do this download and build the Android "Cupcake" release.)
(2) Dynamic Linking
If you want to compile code which is "as close to the phone as possible" then there is really only one way to do that: compile against the headers that HTC used, and perform linking against the dynamic libraries that you literally pull off the phone ("adb pull /system/lib").
There's only one problem with this strategy: HTC did not release their copy of the bionic (or other library) source code, so you are forced to punt... the second-best choice is to use headers from the Android (Cupcake) source tree. So... you will notice that for both the dynamic-link or static-link cases in the above makefile, the $(INCLUDE) paths used during compilation come from the Android source tree.
bftb0
PS I guess there is a mechanism to configure the top-level "make" of the Android source tree for not only a target type (defaults to "arm"), but also a "machine" dependency. I didn't research that, as I have only built user-space code. I'm doubt there should be any differences at the syscall interface API - excepting perhaps things like ptrace() which have a machine dependency (register structures, etc).
bftb0 said:
Because of the lineage between Linux and Android, the primary platform for compilation of the kernel and other ARM instruction-set binaries ("native" code) has been on Linux. It appears (at the moment...reading between the lines) that Google engineers are using Ubuntu 8.04 LTS as their choice of Linux platform for maintaining Android kernel & utilities code... so, in principle, it is the "best supported" platform for doing "native" development work, if for no other reason than it's what Google has been using. (Not because it is somehow a "better" O/S, but rather because you are likely to run into fewer quirks, and have more resources on the internet who might have experienced the same difficulties that you run into.)
For instance, the folks that have been building kernel exploit programs have been using the Google "NDK". They are not writing/compiling those in Java - they are writing or compiling programs written in "C", and compiling them into native (ARM) object code.
I provided notes from my own installation for anyone considering "dipping their toe" into building Android kernels or native binaries using Linux as a host O/S - most forum readers are not going to be interested in doing that.
Note that Google now releases an NDK for Windows, Linux, and Mac OS/X. The strange thing about doing development on Windows using Cygwin is that if you have sufficient skills to do so - and are capable of resolving problems that inevitably crop up - then you probably already have sufficient skills to be using Unix/Linux in the first place. Sort of depends on your past experience, though. I'd be willing to bet that Devs with a history of doing WinMo development probably would prefer to climb the Android development learning curve by trying their hand with the Windows/Cygwin NDK because of their familiarity with other Windows-based development tools (IDEs, hex editors, assemblers, GUI generators, etc).
That reminds me though - I need to update this thread with something else.
Cheers
bftb0
Click to expand...
Click to collapse
Wow, i was a little off in this case. I was under the assumption y'all were somehow going to compile ubuntu to run on the eris. :O

[UTILITY][1/8] Build CM10.1 or AOKP on OS X - OS X Build Set Up 1.2

OS X Build Set Up 1.2 - By Kyle Frost (frostincredible)
So you want to build AOKP or CM10.1 on OS X? Well worry no longer my friends,
it is about to get a whole lot easier. Why is that? Because this script I've written will do pretty
much everything for you, from creating the case sensitive DMG to installing the required files,
to setting up all the folders. The best part? It also will initialize the AOKP or CM repo (depending
on your choice) and you can also build them straight from the script! How fantastic is that?!
Simply read on to see how! Make sure to follow all the instructions (there aren't many)!​
Follow these steps:
Go here and download OS X Build Set Up 1.2 (OSX_Setup-1.2.zip) - DOWNLOAD
Place the ZIP file on your Desktop.
Extract the ZIP to your Desktop.
Here comes the only tricky part. Open the file located at OSX_Setup/scripts/advanced_scripts/build_cm or build_aokp, whichever you're going to build.
Find this line -
Code:
# BELOW IS THE ONLY LINE YOU SHOULD BE EDITING. REPLACE *YOUR DEVICE* WHITH YOUR DEVICE'S CODE NAME. EX - NEXUS 7 = "grouper"
Just below that, edit this line with the instructions in the one I just posted -
Code:
cp /Volumes/Android/OUT/target/product/*YOUR DEVICE*/aokp_*YOUR DEVICE*-ota-eng.$ME.zip /Volumes/Android/Builds/AOKP_$ME.$NOW.zip
IT IS IMPORTANT THAT YOU DON'T EDIT ANYTHING ELSE.
Open your favorite Terminal application (the default on is Terminal located at /Applications/Utilities/Terminal).
cd to the OSX_Setup folder on your Desktop.
Code:
cd /Users/YOUR NAME/OSX_Setup
Run the following -
Code:
./runme
After running this, you will be presented with the following menu -
Code:
============================================================
OS X Build Set Up 1.2 - by Kyle Frost
============================================================
---Main Menu---
1 - Create DMG
2 - Install required files (MUST install MacPorts first)
MacPorts available free at www.macports.org
3 - Set up folders
WARNING: DO NOT RUN ADVANCED MENU UNTIL
YOU HAVE RUN ALL 3 ABOVE, OR HAVE DONE
THEM ALL MANUALLY. THANK YOU.
0 - Advanced Menu
x - Exit
Enter option:
As you can see, you need to go here and install MacPorts before proceeding - MacPorts
After installing MacPorts you can go ahead and run everything.
Create DMG will give you the options of creating a 25GB, 30GB, 40GB, 50GB, or 60GB DMG. 25GB is the lowest recommended by the Android Team.
Install required files will simply do just that, it will install the files needed as specified in the AOSP documents. This can take a while, so go take a nap while it runs.
Set up folders will give you the option of setting up the folders for AOKP or CM10.1. Simply choose which you want and the folders will be created.
Choosing Advanced Menu will give you this -
Code:
============================================================
OS X Build Set Up 1.2 - by Kyle Frost
============================================================
---Advanced Menu---
MUST INSTALL XCODE BEFORE BUILDING!
XCODE IS FREE IN THE MAC APP STORE!
1 - Initialize AOKP Repo
2 - Initialize CM10.1 Repo
When building, it will give you a list
of devices. Enter the number for your device
configuration and the build will continue.
It will take a while the first time, as the
source must first completely download.
3 - Build AOKP
4 - Build CM10.1
Note: When the build is complete, you can
find the finished ZIP in the Builds
folder on your Android disk image.
0 - Go to Main Menu
Enter option:
There you can see you need to install Xcode, if you haven't already. It is free in the Mac App Store (this script is for OS X, you know).
All the options are pretty self explanatory. Make sure you have run the folder set up for the ROM which you wish to build first. Run the initialize option for your desired ROM before running the build option.
That is it! After the build has done (takes a while the first time you set all this up, much faster the next few times) you will be able to build your own nightly's, or whatever you so desire! Have fun!
NOTE: If you have an error regarding "Xcode" and the "10.6 SDK" when trying to build, download the MacOSX10.6.sdk.zip, decompress it, and place it in "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/".
Disclaimer: This will only work with devices that are officially supported by AOKP or CM10.1. If your device is not supported by their official repos, either wait to see if it is, try to edit my script to get the repo your device's tree is on, or wait until I get around to writing a tutorial on how to add custom repos.
Please do not redistribute this without my permission,
and feel free to hit that thanks button if you liked this.​
Version 1.0 - Initial Release
Version 1.1 - Bug Fixes
Version 1.2 - Bug Fixes
Reserved for future tips and tricks.
Thanks mate..
Sent from my A99 using Tapatalk 2
What Mac OS version is this for?
This is sweet and appreciated. I can't wait to try this tonight.Thanks for the script and tutorial.
What Mac OS X is this for? I assume Mountain Lion. I'm run 10.8.2 at work and thinking about updating my home computer to the same. I have a build environment setup for OS X 10.6.8 at home, but Mac Ports was giving me issues and this will help me in getting my build environment back up and going. Thanks again.
I have mountain Lion, will it work on it? I am surely gonna give it a try when i get home! I was thinking on installing ubuntu. but nahh!
Make sure you mount the sparse image before trying to install the folders
I unfortunately do not own a fast enough computer can someone build aokp for xoom?
Which Version of xCode is requirement? (4.4, 4.0 or a older Version)
emd2009 said:
I unfortunately do not own a fast enough computer can someone build aokp for xoom?
Click to expand...
Click to collapse
Wingray stingray, everest ?
---------- Post added at 08:33 PM ---------- Previous post was at 08:33 PM ----------
heubergen said:
Which Version of xCode is requirement? (4.4, 4.0 or a older Version)
Click to expand...
Click to collapse
just follow the instructions at macports to get the latest updated.
grad061980 said:
This is sweet and appreciated. I can't wait to try this tonight.Thanks for the script and tutorial.
What Mac OS X is this for? I assume Mountain Lion. I'm run 10.8.2 at work and thinking about updating my home computer to the same. I have a build environment setup for OS X 10.6.8 at home, but Mac Ports was giving me issues and this will help me in getting my build environment back up and going. Thanks again.
Click to expand...
Click to collapse
I'm running OS X 10.8.2 and that's what I build on.
sonymsam said:
I have mountain Lion, will it work on it? I am surely gonna give it a try when i get home! I was thinking on installing ubuntu. but nahh!
Click to expand...
Click to collapse
Mountain Lion should be fine. I run 10.8.2
wildestpixel said:
Make sure you mount the sparse image before trying to install the folders
Click to expand...
Click to collapse
Did you have to? Mounting should be a part of the script. I will look into that.
heubergen said:
Which Version of xCode is requirement? (4.4, 4.0 or a older Version)
Click to expand...
Click to collapse
I have the developer beta, but the newest in the App Store should work fine.
any way we can build on windows? without emulation?
Thanks for making this easy! Is there a way to leverage this to also cherrypick patches or revert official merges that don't work well for me?
ross231 said:
any way we can build on windows? without emulation?
Click to expand...
Click to collapse
Not at the moment, and not that I know of at all, actually.
ahpatel said:
Thanks for making this easy! Is there a way to leverage this to also cherrypick patches or revert official merges that don't work well for me?
Click to expand...
Click to collapse
Not currently, not a bad idea though.
Fantastic tutorial. Cant wait to figure out how to compile AOKP for my unsupported i777.
i screwed up and mistakenly ejected the Android DMG and it won't let me create a new one,,,,what should i do?
Plays2 said:
i screwed up and mistakenly ejected the Android DMG and it won't let me create a new one,,,,what should i do?
Click to expand...
Click to collapse
Remount it. It is located in your home directory.
---------- Post added at 07:54 PM ---------- Previous post was at 07:38 PM ----------
Trying to compile for the SGS2 i777 and I get the following error:
Code:
---This is where you choose your device config---
You're building on Darwin
(ohai, koush!)
Lunch menu... pick a combo:
1. full-eng
2. full_x86-eng
3. vbox_x86-eng
4. full_mips-eng
5. mini_armv7a_neon-userdebug
6. mini_armv7a-userdebug
7. mini_mips-userdebug
8. mini_x86-userdebug
9. full_panda-userdebug
Which would you like? [full-eng] 6
build/core/combo/HOST_darwin-x86.mk:62: *****************************************************
build/core/combo/HOST_darwin-x86.mk:63: * Cannot find SDK 10.6 at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
build/core/combo/HOST_darwin-x86.mk:65: * If you wish to build using higher version of SDK,
build/core/combo/HOST_darwin-x86.mk:66: * try setting BUILD_MAC_SDK_EXPERIMENTAL=1 before
build/core/combo/HOST_darwin-x86.mk:67: * rerunning this command
build/core/combo/HOST_darwin-x86.mk:69: *****************************************************
build/core/combo/HOST_darwin-x86.mk:70: *** Stop.. Stop.
Device armv7a not found. Attempting to retrieve device repository from CyanogenMod Github (http://github.com/CyanogenMod).
Repository for armv7a not found in the CyanogenMod Github repository list. If this is in error, you may need to manually add it to your local_manifest.xml.
build/core/combo/HOST_darwin-x86.mk:62: *****************************************************
build/core/combo/HOST_darwin-x86.mk:63: * Cannot find SDK 10.6 at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
build/core/combo/HOST_darwin-x86.mk:65: * If you wish to build using higher version of SDK,
build/core/combo/HOST_darwin-x86.mk:66: * try setting BUILD_MAC_SDK_EXPERIMENTAL=1 before
build/core/combo/HOST_darwin-x86.mk:67: * rerunning this command
build/core/combo/HOST_darwin-x86.mk:69: *****************************************************
build/core/combo/HOST_darwin-x86.mk:70: *** Stop.. Stop.
** Don't have a product spec for: 'mini_armv7a'
** Do you have the right repo manifest?
build/core/combo/HOST_darwin-x86.mk:62: *****************************************************
build/core/combo/HOST_darwin-x86.mk:63: * Cannot find SDK 10.6 at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
build/core/combo/HOST_darwin-x86.mk:65: * If you wish to build using higher version of SDK,
build/core/combo/HOST_darwin-x86.mk:66: * try setting BUILD_MAC_SDK_EXPERIMENTAL=1 before
build/core/combo/HOST_darwin-x86.mk:67: * rerunning this command
build/core/combo/HOST_darwin-x86.mk:69: *****************************************************
build/core/combo/HOST_darwin-x86.mk:70: *** Stop.. Stop.
cp: /Volumes/Android/OUT/target/product/i777/cm_i777-ota-eng.xxxxxxx.zip: No such file or directory
Followed the instructions to the letter, but Im not sure whats wrong.
biontc said:
Remount it. It is located in your home directory.
---------- Post added at 07:54 PM ---------- Previous post was at 07:38 PM ----------
Trying to compile for the SGS2 i777 and I get the following error:
Code:
---This is where you choose your device config---
You're building on Darwin
(ohai, koush!)
Lunch menu... pick a combo:
1. full-eng
2. full_x86-eng
3. vbox_x86-eng
4. full_mips-eng
5. mini_armv7a_neon-userdebug
6. mini_armv7a-userdebug
7. mini_mips-userdebug
8. mini_x86-userdebug
9. full_panda-userdebug
Which would you like? [full-eng] 6
build/core/combo/HOST_darwin-x86.mk:62: *****************************************************
build/core/combo/HOST_darwin-x86.mk:63: * Cannot find SDK 10.6 at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
build/core/combo/HOST_darwin-x86.mk:65: * If you wish to build using higher version of SDK,
build/core/combo/HOST_darwin-x86.mk:66: * try setting BUILD_MAC_SDK_EXPERIMENTAL=1 before
build/core/combo/HOST_darwin-x86.mk:67: * rerunning this command
build/core/combo/HOST_darwin-x86.mk:69: *****************************************************
build/core/combo/HOST_darwin-x86.mk:70: *** Stop.. Stop.
Device armv7a not found. Attempting to retrieve device repository from CyanogenMod Github (http://github.com/CyanogenMod).
Repository for armv7a not found in the CyanogenMod Github repository list. If this is in error, you may need to manually add it to your local_manifest.xml.
build/core/combo/HOST_darwin-x86.mk:62: *****************************************************
build/core/combo/HOST_darwin-x86.mk:63: * Cannot find SDK 10.6 at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
build/core/combo/HOST_darwin-x86.mk:65: * If you wish to build using higher version of SDK,
build/core/combo/HOST_darwin-x86.mk:66: * try setting BUILD_MAC_SDK_EXPERIMENTAL=1 before
build/core/combo/HOST_darwin-x86.mk:67: * rerunning this command
build/core/combo/HOST_darwin-x86.mk:69: *****************************************************
build/core/combo/HOST_darwin-x86.mk:70: *** Stop.. Stop.
** Don't have a product spec for: 'mini_armv7a'
** Do you have the right repo manifest?
build/core/combo/HOST_darwin-x86.mk:62: *****************************************************
build/core/combo/HOST_darwin-x86.mk:63: * Cannot find SDK 10.6 at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
build/core/combo/HOST_darwin-x86.mk:65: * If you wish to build using higher version of SDK,
build/core/combo/HOST_darwin-x86.mk:66: * try setting BUILD_MAC_SDK_EXPERIMENTAL=1 before
build/core/combo/HOST_darwin-x86.mk:67: * rerunning this command
build/core/combo/HOST_darwin-x86.mk:69: *****************************************************
build/core/combo/HOST_darwin-x86.mk:70: *** Stop.. Stop.
cp: /Volumes/Android/OUT/target/product/i777/cm_i777-ota-eng.xxxxxxx.zip: No such file or directory
Followed the instructions to the letter, but Im not sure whats wrong.
Click to expand...
Click to collapse
Same here compiling for grouper and tried 5 and 6.
It would appear that I've completely screwed it up. After creating a twenty-five gig partition, I began to try to build, and was met with an error about Xcode. I fix it, and continued. However, I ended up deleting the created partition through Disk Image. Whenever I try using the program to create another, it says one already exists (which it doesn't). I don't know what to do now.
DinoSoup said:
It would appear that I've completely screwed it up. After creating a twenty-five gig partition, I began to try to build, and was met with an error about Xcode. I fix it, and continued. However, I ended up deleting the created partition through Disk Image. Whenever I try using the program to create another, it says one already exists (which it doesn't). I don't know what to do now.
Click to expand...
Click to collapse
You could try:
Code:
rm -f ~/Android.dmg.sparseimage
then try recreating it through the app.
Disclaimer: This is undoable and use it at your own risk.

[UTILITY][09/01/2014] Build CM, PA or AOKP on OS X - OS X Build Initial release

Based on frostincredible Script
OS X Build - By Ptichalouf
Only KK Build For Now !
I Will add so Many Team !
So you want to build AOKP, PA or CM on OS X? Well worry no longer my friends,
it is about to get a whole lot easier. Why is that? Because this script I've written will do pretty
much everything for you, from creating the case sensitive DMG to installing the required files,
to setting up all the folders. The best part? It also will initialize the AOKP or CM repo (depending
on your choice) and you can also build them straight from the script! How fantastic is that?!
Simply read on to see how! Make sure to follow all the instructions (there aren't many)!​
Follow these steps:
Go here and download OS X Build (OSX_Setup.zip) - DOWNLOAD
Place the ZIP file on your Desktop.
Extract the ZIP to your Desktop.
Here comes the only tricky part. Open the file located at OSX_Setup/scripts/advanced_scripts/build_cm or build_aokp, whichever you're going to build.
Find this line -
Code:
# BELOW IS THE ONLY LINE YOU SHOULD BE EDITING. REPLACE *YOUR DEVICE* WHITH YOUR DEVICE'S CODE NAME. EX - NEXUS 7 = "grouper"
Just below that, edit this line with the instructions in the one I just posted -
Code:
cp /Volumes/Android/OUT/target/product/*YOUR DEVICE*/aokp_*YOUR DEVICE*-ota-eng.$ME.zip /Volumes/Android/Builds/AOKP_$ME.$NOW.zip
IT IS IMPORTANT THAT YOU DON'T EDIT ANYTHING ELSE.
Open your favorite Terminal application (the default on is Terminal located at /Applications/Utilities/Terminal).
cd to the OSX_Setup folder on your Desktop.
Code:
cd /Users/YOUR NAME/OSX_Setup
Run the following -
Code:
./runme
After running this, you will be presented with the following menu -​
Code:​============================================================
OS X Build Set Up 1 - based on Kyle Frost
By [email protected]
============================================================
---Main Menu---
1 - Create DMG
2 - Install required files (MUST install MacPorts first)
MacPorts available free at www.macports.org
3 - Set up folders
WARNING: DO NOT RUN ADVANCED MENU UNTIL
YOU HAVE RUN ALL 3 ABOVE, OR HAVE DONE
THEM ALL MANUALLY. THANK YOU.
0 - Advanced Menu
x - Exit
Enter option:
As you can see, you need to go here and install MacPorts before proceeding - MacPorts
After installing MacPorts you can go ahead and run everything.
Create DMG will give you the options of creating a 25GB, 30GB, 40GB, 50GB, 60GB or 120GB DMG. 25GB is the lowest recommended by the Android Team.
Install required files will simply do just that, it will install the files needed as specified in the AOSP documents. This can take a while, so go take a nap while it runs.
Set up folders will give you the option of setting up the folders for AOKP or CM10.1. Simply choose which you want and the folders will be created.
Choosing Advanced Menu will give you this - ​
Code:
============================================================
OS X Build Set Up 1 - based on Kyle Frost
By @ptichalouf
============================================================
---Advanced Menu---
MUST INSTALL XCODE BEFORE BUILDING!
XCODE IS FREE IN THE MAC APP STORE!
1 - Initialize AOKP Repo
2 - Initialize CM11 Repo
3 - Initialize Paranoid Repo
When building, it will give you a list
of devices. Enter the number for your device
configuration and the build will continue.
It will take a while the first time, as the
source must first completely download.
4 - Build AOKP
5 - Build CM11
6 - Build Paranoid
Note: When the build is complete, you can
find the finished ZIP in the Builds
folder on your Android disk image.
0 - Go to Main Menu
Enter option:
There you can see you need to install Xcode, if you haven't already. It is free in the Mac App Store (this script is for OS X, you know).
All the options are pretty self explanatory. Make sure you have run the folder set up for the ROM which you wish to build first. Run the initialize option for your desired ROM before running the build option.
That is it! After the build has done (takes a while the first time you set all this up, much faster the next few times) you will be able to build your own nightly's, or whatever you so desire! Have fun!
Disclaimer: This will only work with devices that are officially supported by AOKP PA or CM Team If your device is not supported by their official repos, either wait to see if it is, try to edit my script to get the repo your device's tree is on, or wait until I get around to writing a tutorial on how to add custom repos.​
delete please

VM For Developing Custom ROMs

Virtualbox Virtual Machine For Custom ROMs​I found the steps necessary to compile a custom ROM a bit daunting.
Also, I have a Windows PC and most of the instructions are around Linux.
Therefore, I created a Vagrant project to automate all the setup. It does the following:
Creates an Ubuntu trusty64 server VM using VirtualBox
Add all the necessary packages
Adds a 'buildbot' user
Creates the local directory structure
Downloads the repo wrapper
Initialises the repo using CM13.0
Syncs the repos (downloads all the source code)
Adds the build commands
Adds Ziyans device tree for Galaxy Nexus
Syncs the device tree
Compiles the code (brunch maguro)
I have attempted to reduce the amount of data downloaded by excluding various groups and only doing a shallow clone i.e no history.
This still downloads 5.5 GB for the main CM source and 0.5 GB for @Ziyans device tree.
As long you have Vagrant and Virtualbox installed, you just clone my repo (or download the zip from GitHub) and type
Code:
vagrant up
and everything will be done for you!
https://github.com/opticyclic/cyanogenmod-vagrant
This was written for a Galaxy Nexus.
If you want to change ROM you need to modify this line:
Code:
exec { 'init repo':
cwd => '/home/buildbot/android/system',
command => '/usr/local/bin/repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0 --depth=1 --groups=all,-notdefault,-device,-darwin,-x86,-mips,-exynos5,-intel,-eclipse,-device',
user => 'buildbot',
group => 'buildbot',
creates => '/home/buildbot/android/system/.repo',
timeout => 0,
require => [ File['chmod repo'], File['create build dirs'], File['create gitconfig'] ],
}
If you want to change device you need to change this line to your device name.
Code:
exec { 'brunch':
cwd => '/home/buildbot/android/system',
environment => ["HOME=/home/buildbot", "USER=buildbot"],
command => "/bin/bash -c 'source build/envsetup.sh;brunch maguro'",
user => 'buildbot',
group => 'buildbot',
timeout => 0,
require => Exec['sync repo'],
}
And make sure the correct device tree is mentioned in the roomservice.xml
NOTE: If you have CPUs or memory to spare then you should increase the VM settings in the Vagrantfile before doing vagrant up.
Code:
config.vm.provider :virtualbox do |vb|
vb.cpus = 2
vb.memory = 4096
UPDATE 2016-05-19: There was previously an issue with the order of the steps and the file owners. It should now run all the way through brunch maguro now.
.....and if I wanted all the source code Ziyan's "AOSP Omap4" , instead CM13 ?
At the moment it isn't complete as I didn't fully understand the last few steps of the CM build process.
However, the key file to change is https://github.com/opticyclic/cyanogenmod-vagrant/blob/master/modules/gnex/manifests/init.pp
I could add an if statement based on a property to use OMAP4 instead.
However, I would need to know the steps/urls that are different to CM.
Its in a much better state now with swap for those without much RAM to spare and a dedicated virtual drive for the code as the base box isn't big enough.
If you have an SSD you are going to see much faster times.
Also if you have the CPUs or RAM to spare you should increase the VM settings in the Vagrantfile before doing vagrant up.
In case you're familiar with Docker, you can also take a look at my docker-cyanogenmod project which does a very similar thing: http://forum.xda-developers.com/showthread.php?t=2650345
Besides this, I think that a project like this should not be limited to a specific device, so you might want to move the thread to the Android Software Development subforum: http://forum.xda-developers.com/android/software

[GUIDE] HOW TO BUILD ANDROID FROM SOURCE [2020 Edition]

[NOOB-FRIENDLY] HOW TO BUILD ANDROID FROM SOURCE CODE [2020 EDITION]
Introduction
Hi, my name is Varun, during the times I was building I faced some trouble building, and I thought it would be helpful if I put together a guide that covers every aspect of building. Many roms fundamentally differ so this is a generic guide, but when it comes to modifying device specific files you are going to have to refer to your rom developer or your device tree maintainer.
I see a lot of lead devs referring to older guides on xda, and felt like there should be a good reference thats more recent.
I have heavily depended upon Nathan Chance's Guide which can be found HERE. I feel like this may be a little intimidating for new builders hence this thread. I will slowly upload screenshots here as I find time. But for now this is what I have. You can find my guide HERE. If there are any changes to be made in this thread then it also needs to be changed on gh, so please do comment or make a pr and fix what is requested.
Table of Contents
1) Getting started
2) Prerequisites
3) Understanding the DOC
4) Preparing Linux environment
5) Getting the source
6) Getting device specific files
7) Building
GETTING STARTED
• This guide will help you understand the basics of rom building.
• You must have exprience with linux and terminal
• You must read everything at least once
• If you get stuck at any step, google is your best friend.
If you still struggle, these are places you can get help
1) This thread
2) GitHub
3) Other XDA threads
4) Telegram (Your SOC groups or Android Builders Help)
• Build only if you have time to spare, never rush through the learning stage
• Never think about skipping a step
• If you are planning to modify a ROM, always ask for permission
• If you are planning on including other peoples work in your rom always ask for permission
Prerequisites
• Your system should have at least 8GB RAM and 4 cores (Use Zram for 8gb ram devices)
• Strong internet connection. You will be downloading 50GB+ worth of files
• Ubuntu - this should be installed alongside a primary OS. NOT VM
• Minimum 250GB of free disk space (you can sync 1 ROMs and build for 3 devices at once)
• Git - Read some documentation
• Command Line - get yourself familiar, learn with CodeAcademy
Understanding This Doc
• Notes with background information will be given in italics
•
Code:
is used to represent a command that is run from terminal
PREPARING LINUX ENVIRONMENT FOR BUILDING
• Now the you have finished setting up, a special environment is required for building.
• Preparing the environment is as easy as double clicking .exe in Windows or .dmg in MacOS
thanks to developer Akhil N.
• We need to clone his scripts (installer) from his GitHub
NOTE:
A script is a file which contains multiple commands that run sequentially when executed
Code:
git clone https://github.com/akhilnarang/scripts
• This should copy the scripts to directory /home/username/scripts
• Cd into the directory called setup
Code:
cd scripts/setup
• List out directory
Code:
ls
• Find the file that corresponds to our Linux build. Since we are using Ubuntu it will be android_build_env.sh
For other Distros refer to the readme that has also been cloned
• Run the script
Code:
. android_build_env.sh
• Setup GitHub using on screen instructions
• Congratulations you set up your computer for building
• Go back the previous dir that you were originally on (/home/username)
Code:
cd
NOTE:
cd will always take you to home/username
GETTING THE SOURCE
• This is probably one of the worst steps, you have to wait a while
• GCloud users will be able to download source in 15 minutes
• Other users may have to wait longer (depends on internet connection speed)
• Make a directory for your ROM
Code:
mkdir “ROMNAME”
NOTE:
this will make folder in directory home/username/romname
• Cd in and initiate repository, this basically tells your computer where to download source files from.
The repository initiation command can be found on the GitHub page under “manifest” then scroll down to
repo initialisation and copy command
• It should look like
Code:
repo init -u git://github.com/crdroidandroid/android.git -b 10.0
HINTS
NOTE:
1) Linux users can paste into terminal using Ctrl + Shift + V
2) Linux users can copy from terminal using Ctrl + Shift + C
3) GCloud users can paste into window using Ctrl + V
4) GCloud users can copy from window simply by highlighting
5) GCloud users using ssh from terminal can just follow terminal commands
• Once repo is initialised, you can begin download using
Code:
repo sync -f --force-sync --no-clone-bundle --no-tags -j$(nproc --all)
• Let everything download
GETTING DEVICE SPECIFIC FILES
• As most of you know the kernel acts as the translator between the OS and your actual hardware
• The files mentioned above are android version specific and will only work with that android
version
• The developer for your device aka dt maintainer will have these files on their GitHub and its
usually linked at the end of the op of other rom threads in the source code section
• You have to make sure that the rom version you downloaded matches up
• If the device tree is for an older version then wait until your dev. releases the latest trees, if no
developer is working on your device then it is possible to modify the tree to work with newer
version of android but it may take some effort.
• In case your tree doesnt match with the rom version that you have downloaded, the easiest and best option is
to scrap everything and download the source version that your tree is designed for
• To scrap everything, use
Code:
rm -rf “folder containing rom"
• To modify the init command to download an older version you need to pick out the branch you
need (the branch is basically the version the newer version is added to a new branch)
• Change the init command after -b to include desired branch. For example
repo init -b ten to repo init -b seven
• To get the device specific files, we need to fork them to your GitHub.
Find the stuff (kernel vendor device tree hardware) and fork them
NOTE:
Forking basically copies them to your GitHub
• At this point we need to know if we need to modify the device tree as some ROMs don’t require
you to modify it (CrDroid)(LOS)
• Some roms require only partial modifications, this is rom specific so I wont be going too much into detail
• If modification is required follow these steps , otherwise skip to the end of this section
• After forking we need to modify the files we will do this from the browser for ease of
understanding
•There are three files that need modification and they are located your device tree
• Some tree developers may split your device tree into two parts if there is more than one phone
running the same SOC, so keep an eye out for that. (devices that have the same soc are like the op3/op3t and the op7/op7p)
• The files that we need to modify are under your "device codename" device tree, not "device SOC-common" device tree.
• For example; we need to go to "device_samsung_crownlte" tree not "device_samsung_universal9810-common"
• In here the three files that need modification are
1) Android Products.mk
2) lineage.dependencies
3) lineage_"device codename".mk (example:lineage_crownlte.mk)
• First open AndriodProducts.mk Here replace wherever you see lineage with name of ROM in lowercase only.
• Second, open lineage dependencies.mk and rename file to "romname".dependencies (ecample: aim.dependencies)
• Third, open lineage_"codename".mk and rename to "romname"_"codename".mk and replace
lineage with "romname in the code. (Remember,use lowercase)
NOTE:
If you are building an older version of android make sure you branch out the right branch for your trees
People who do not need to modify can join us here
• Now that all your files are in your GitHub, we need to download them
• There are two easy ways
1) Fast and easy Room Service
2) Slow and boring manual cloning
• Room Service
1) cd into .repo from romsource
Code:
cd .repo
2) Make directory local_manifests
Code:
mkdir local_manifests
3) Make room service file
Code:
nano roomservice.xml
(follow next bullet point on how to make roomservice.xml)
4) Return to ROM folder
Code:
cd && cd "romfolder"
• Making the roomservice.xml is as easy as copy paste.
Visit
https://github.com/vrnsoma/local_manifests/blob/lineage-17.1/roomservice.xml
and copy and paste it into a text editor and edit it then paste it into the terminal window (step 3 in above point)
Hint for Device Tree
Example: link= userabc/repositories/device_samsung/crownlte (location on github)
path= device/samsung/crownlte (Where it should download to)
remote= github (where files are stored)
revision= branchname (which version you want)
• Resync Repo like I mentioned before
Code:
repo sync -f --force-sync --no-clone-bundle --no-tags -j$(nproc --all)
BUILDING
• Run
Code:
. build/envsetup.sh
• Then
Code:
brunch codename
• Make sure to clean build by running this in between builds
Code:
make clobber && make clean
• If you are using a slow system and want to improve build speeds, use the following command
for making partially clean builds for incremental updates
Code:
make installclean
• Building without cleaning is called dirty building and is never advised and do not do this unless
you know what you are doing
KEEPING SETUP UP TO DATE
• Repo sync will keep your rom and device specific files that have been deined in roomservice up to date
CREDITS
NathanChance
All threads on XDA
All guides on Github
All devs found on Telegram
If you want specific credits plz do notify me!
XDA:DevDB Information
BUILDING ANDROID, ROM for all devices (see above for details)
Contributors
vsoma
ROM OS Version: Android 10
ROM Firmware Required: NOOB
Version Information
Status: Stable
Created 2020-10-03
Last Updated 2020-10-03
I need rom porting guide for android 10....can you make thread on it?
I tried the tutorial, after the step repo sync -f --force-sync --no-clone-bundle --no-tags -j$(nproc --all). I get message error: RPC failed; curl 56 GnuTLS recv error (-24): Decryption has failed.
i can't finish compiling because java.lang.outofmemoryerror : heap size but i have already set the heap size to 8gb

Categories

Resources