[Dell Venue] chacona:
HOWTO: Setup a working environment to build CM7, with SVN

0. Overview

In this thread: http://xdaforums.com/showthread.php?t=1565517, HPA has shown a custom ROM based on CM7, and his development files. I think there's a need to create a guideline of how to create such artifacts yourself by setting up your own development environment, download the source code and build ones for yourself. This post address that need. Hope this helps!

1. Install a version tracking system

1.1 Install SVN, please refer to "Setup a Subversion Server in 4 Minutes" (http://www.tonyspencer.com/2007/03/02/setup-a-subversion-server-in-4-minutes/)

1.1 Install RapidSVN by running "sudo apt-get install rapidsvn" (Ubuntu users may need to use sudo, or by installing it from Synaptic, for more details please refer to http://www.rapidsvn.org/index.php/OnlineHelp:Contents)

What's just happened: you installed Subversion (a software versioning and revision control system) and a GUI tool to track changes to the scripts you are going to create/update. Having a revision control system up and running is recommended since you're going to change many things from the original files, or create ones yourself. When your change is irrelevant, Subversion will save the day by allow you to revert back to a last-known-good version in the past - that's all we need, I think.

2. Get CM7 source code

Assume that we're going to use a folder named "gingerbread" in your home folder for this task:

$ cd ~/android/gingerbread
$ repo init -u git://github.com/CyanogenMod/android.git -b gingerbread
$ repo sync

3. Initialize the build script folder structure

Ensure that, the folder containing development files will have the same structure as the CM7 source tree, like this:

$ tree -d ~/android/cm7dev/gingerbread

gingerbread
|-- device
| `-- dell
| `-- venue
| |-- files
| |-- libaudio-qsd8k
| `-- overlay
| |-- frameworks
| | `-- base
| | |-- core
| | | `-- res
| | | `-- res
| | | `-- values
| | `-- packages
| | `-- SettingsProvider
| | `-- res
| | `-- values
| `-- packages
| `-- apps
| |-- CMParts
| | `-- res
| | `-- values
| |-- Mms
| | `-- res
| | `-- values
| |-- Phone
| | `-- res
| | `-- values
| |-- Settings
| | `-- res
| | `-- values
| `-- Torch
| `-- res
| `-- values
|-- frameworks
| `-- base
| |-- include
| | |-- camera
| | `-- media
| |-- libs
| | `-- camera
| |-- media
| | |-- java
| | | `-- android
| | | `-- media
| | |-- jni
| | `-- libstagefright
| | `-- omx
| |-- policy
| | `-- src
| | `-- com
| | `-- android
| | `-- internal
| | `-- policy
| | `-- impl
| |-- services
| | |-- camera
| | | `-- libcameraservice
| | `-- java
| | `-- com
| | `-- android
| | `-- server
| `-- telephony
| `-- java
| |-- android
| | `-- telephony
| `-- com
| `-- android
| `-- internal
| `-- telephony
| `-- gsm
|-- packages
| `-- providers
| `-- MediaProvider
| `-- src
| `-- com
| `-- android
| `-- providers
| `-- media
`-- vendor
`-- cyanogen
`-- products

Here, we have 4 sub-folders called "device", "frameworks", "packages" and "vendor". Later we will merge this folder with the CM7 source tree.

4. Import cm7dev files (the above tree folder structure) to SVN repo

$ svn import ~/android/cm7dev/gingerbread file:///data/svnrepos/gingerbread

5. Create a new empty working directory

This will be the place we checkout our code, and actually do the development task

$ cd ~/android
$ mkdir dv-dev
$ mkdir dv-dev/gingerbread

Now, checkout code from URL file:///data/svnrepos/gingerbread to the above working folder. You can use RapidSVN, or if you're familiar with SVN command line interface, issue this:

$ svn co file:///data/svnrepos/gingerbread ~/android/dv-dev/gingerbread

6. Merge CM7 code folder with our working directory

Now, copy everything from CM7 code folder (~/android/gingerbread) to the your working directory ~/android/dv-dev/gingerbread. Since they have the same name, with the same sub-folders, a confirmation will be shown to ask you whether you want to merge the content. Say Yes, and besure to select to apply to all items found.

This step ensures that, you can now build CM7 right from the working folder, and any changes to build script can be tracked by SVN (checked in). Now you're ready to go with the build progress. You may want to copy files from ~/android/cm7dev/gingerbread to the working folder again to overwrite all conflicts if there are any.

7. Copy proprietary files

Be sure your phone is connected to your PC, and USB access are well-configured so that ADB can do its task to pull the proprietary needed files.

$ cd ~/android/dv-dev/gingerbread/device/dell/venue
$ ./extract-files.sh

In this step, several changes need to be made for this file (extract-files.sh). You will have to adjust one for yourself since I noticed that HPA - the author - wrote some script to pull files that do not exists (he might have based on a Streak instead).

8. Install new versions of gApps and Rom Manager (of course, if you want) :)

$ cd ~/android/dv-dev/gingerbread/vendor/cyanogen/
$ ./get-rommanager

9. Build (the setup-makefiles.sh below will also has to be modified)

$ cd ~/android/dv-dev/gingerbread/device/dell/venue
$ ./setup-makefiles.sh

$ cd ~/android/dv-dev/gingerbread
$ cp ./vendor/cyanogen/products/cyanogen_venue.mk ./buildspec.mk

# choose device
$ . build/envsetup.sh
$ lunch cyanogen_venue-eng

# actual build
$ mka (or make -j`grep 'processor' /proc/cpuinfo | wc -l`, like what shown in Cyanogen official guidelines)

Now, let's just wait adjust the build scripts base on what you get (errors) during the build progress. For example, here's what I met:

target Strip: InputChannel_test (out/target/product/venue/obj/EXECUTABLES/InputChannel_test_intermediates/InputChannel_test)
(unknown): error 4: Added public method android.telephony.PhoneNumberUtils.formatKoreanNumber
(unknown): error 5: Added public field android.media.MediaRecorder.AudioEncoder.EVRC
(unknown): error 5: Added public field android.media.MediaRecorder.AudioEncoder.QCELP
(unknown): error 5: Added public field android.telephony.PhoneNumberUtils.FORMAT_KOREA

******************************
You have tried to change the API from what has been previously approved.

To make these errors go away, you have two choices:
1) You can add "@hide" javadoc comments to the methods, etc. listed in the
errors above.

2) You can update current.xml by executing the following command:
make update-api
^^^^^^^^^^^^^^^^^^
NO. NO. STOP BEING LAZY. SERIOUSLY.
DO NOT DO THIS in CM. THIS IS A LIE. IF YOU DO THIS I WILL HATE YOU.
USE OPTION #1.
-Koush

To submit the revised current.xml to the main Android repository,
you will need approval.
******************************

I typed "make update-api" like the author said above, and things were fine.

10. Remove symbolic links in /system/xbin, /system/bin

All symbolic links in the above folders need to be removed, since they will be created during the flashing progress, via instructions in updater-script

$ cd ~/android/dv-dev/gingerbread/out/target/product/venue/system/bin
$ find . -maxdepth 1 -type l -exec rm -f {} \;

$ cd ~/android/dv-dev/gingerbread/out/target/product/venue/system/xbin
$ find . -maxdepth 1 -type l -exec rm -f {} \;

11. Deploy

Now, copy the following things from ~/android/dv-dev/gingerbread/out/target/product/venue

- ./system

- boot.img

to another directory to create an update.zip file.

12. Other tools you might need/consider

Meld: a visual diff and merge tool

Geany: a text editor using the GTK2 toolkit with basic features of an integrated development environment

RabbitVCS: a graphical front-end for version control systems available on Linux that can be integrated into file managers such as Nautilus, Thunar. You'll find it familiar if you use TortoiseSVN on Windows before.

P.S. My development files: http://www.mediafire.com/?2ozrmxotdsib9nn