[Galaxy Tab S Android Development] Deleted member 4405529:
How to build cm12 for chagallwifi

Most important preperation step!

Learn git. Read all the manpages, that come with git. I don't speak of github - thats a nice service I like to use, but working with git means working on the command line. githubs web interface is a lightwight, impotent version of git. Github is great as server to store your projects, but not that what youmwill need the next days... Learn git or go home.

Setting up the environment

Consult the HOWTOs of your distro. You can use any distro to build android on, there is even a HOWTO on setting up an android build environment on cygwin on win. Ubuntu, archLinux and gentoo are known to work and have detailed descriptions on the settup.

I use gentoo with icedtea-7. But as stated: any distro will work, once you have setup your environment.

Getting cm12

Find a place on your harddisc partitions with at least 18 GB free space and appropriate access rights for the user you are building with. Get a shell as this user and get the scm source:

mkdir cm12 #you can call the dir how ever you want - but whenever I refer to cm12
# as directory in this howto, I refer to THIS directory. I may also use the
# term: cm build root.
repo init -u git://github.com/CyanogenMod/android.git -b cm-12.1 # this initiates the repo
repo sync # this fetches the code (quite a couple of GBs - get a laaaarge cup of coffee)

Getting chagallwifi specific gits

Copy the following lines as nvertigo_local_manifest.xml to cm12/.repo/local_manifests/

<?xml version="1.0" encoding="UTF-8"?>
<manifest>

<remote name="tm"
fetch="https://github.com/TheMuppets/" />

<remote name="cm"
fetch="https://github.com/CyanogenMod/" />

<remote name="nvertigo"
fetch="https://github.com/nvertigo/" />

<!-- save us from the step of extract-files -->

<!-- BLOBS for manta -->

<project name="proprietary_vendor_samsung" path="vendor/samsung" remote="tm" revision="cm-12.1" />
<project name="proprietary_vendor_audience" path="vendor/audience" remote="tm" revision="cm-12.1" />
<project name="proprietary_vendor_widevine" path="vendor/widevine" remote="tm" revision="cm-12.1" />
<project name="proprietary_vendor_broadcom" path="vendor/broadcom" remote="tm" revision="cm-12.1" />

<!-- BLOBS for lge -->

<project name="proprietary_vendor_lge" path="vendor/lge" remote="tm" revision="cm-12.1" />

<!-- BLOBS for oneplusone -->

<project name="proprietary_vendor_oneplus" path="vendor/oneplus" remote="tm" revision="cm-12.1" />
<project name="proprietary_vendor_oppo" path="vendor/oppo" remote="tm" revision="cm-12.1" />

<!-- BLOBS, device tree and kernel for chagallwifi -->

<project name="android_vendor_samsung_chagallwifi.git" path="vendor/samsung/chagallwifi" remote="nvertigo" revision="current-12.1" />
<project name="android_device_samsung_chagallwifi.git" path="device/samsung/chagallwifi" remote="nvertigo" revision="current-12.1" />
<project name="android_kernel_samsung_chagallwifi.git" path="kernel/samsung/chagallwifi" remote="nvertigo" revision="current-12.1" />

</manifest>

As you can see, I'm building for more devices then chagallwifi. I've decided to keep this file this way: perhaps it holds a hint on how to save us from extract-files.sh. ;)

After you have put nvertigo_local_manifest.xml in place, make sure all dependencies are there and fetch the additional git repos:

source build/envsetup.sh
breakfast picassowifi #this pushes the relevant git repos to .repo/local_manifests/roomservice.xml and fetches them
repo sync # this one fetches our additions to nvertigo_local_manifest.xml

Build cm12 for chagallwifi

Now you are ready for build. So let's clean the build environment and fire off the magic to homegrow a cm12 rom for chagallwifi (you guessed it: from cm12 dir):

source build/envsetup.sh
make -j9 ARCH=arm clean #cleaning from previous build; you have to replace 9 by number of cores + 1
make -j9 ARCH=arm clobber #paranoid; you have to replace 9 by number of cores + 1
time breakfast chagallwifi >make.log 2>&1
time brunch chagallwifi >>make.log 2>&1
# in a second shell: tail -f make.log

make.log is better seacheble then scrolling on terminal. If something goes wrong, search for "Error 1". In the lines before that you can see what breaks your build. On my slightly overclocked amd-fx8150 with 16GB Ram brunching takes about 100 minutes.

Now you have build a flashable rom. Congrats.

Developing

Learn git.

Put the following four lines in your /etc/gitconfig

[alias]
lg1 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
lg2 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(bold white)— %an%C(reset)' --abbrev-commit
lg = !"git lg1"

Example 1: You have a fix for the device tree.

cd device/samsung/chagallwifi
git lg1 # get an impression of the git in treeview; scroll, read, learn the way the source flows
git checkout -b my-branch #you create your own local branch
#edit the files for your fix
#if you add a new file
git add new_file
#if you editied an existing file
git add edited_file
#if you want to remove a file
git rm removed_file
#now each edit is in gits staging area, but it's not commited; to commit it locally:
git commit -em "Fix foobar: foo the bar from... Try to document what you have done and why."
#now the message is taken as title for the commit and an editor opens: you can write in more detail to document your changes.
#if you want to provide such a commit in a way I can use ist
git lg1 # get the hash of the commit you want to provide
git format-patch -1 --stdout hash >/tmp/my-commit.diff

Send me the file - do NOT copy'n'paste the content. That would break tabs and spacing and render the commit unsuable. I will apply the commit with "git am", so authorship remains as well as git history. The latter is important if later one wishes to merge two different gits with simalar commits.

If you decide to keep your own git at this point, go to the github web interface, login with your name (i.e. XXXX), go to my device repository and clone it. Back to your local shell in cm12:

cd device/samsung/chagallwifi
git remote add yyyy https://github.com/XXXX/android_device_samsung_chagallwifi.git
git fetch yyyy
#remember you have commited your changes locally in your local branch cm-12..0
#the local branch cm-12.0 is setup to follow the branch cm-12.0 of the origin remote git
#but we want the local cm-12.0 to follow the one from yyyy:
git branch --set-upstream-to=yyyy/cm-12.0 cm-12.0
git push

Now you have pushed your local commit to your own remote git. Congrats. Now you write me an email: "Huh, look at my git, it fixes everything and will finally bring peace to earth.... It's in hash." Of course, I want this commit in my repo, and that is

Example 2: Take a commit from an other devs git

cd device/samsung/chagallwifi
git fetch https://github.com/XXXX/android_device_samsung_chagallwifi.git #I don't want to have this as an additional remote
git cherry-pick hash

...to be continued....