[HTC One S] klin1344:
How to compile your own Baked ROM (jb-4.2 branch)​

Requirements:

patience (this is the most important)

Ubuntu 12.04 64bit, dual-booted or virtual machine

some space on your Ubuntu partition, I'd say about 50GB to be very safe

an internet connection

Step 1: Setting up your environment

1) You need to install the required packages for compiling AOSP. Open up a terminal, and type this in:

sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-6-jre openjdk-6-jdk pngcrush schedtool g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-4.5-multilib g++-4.5-multilib libxml2-utils libxml2 xsltproc

Lastly:

sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

OPTIONAL STEPS (Good if you want to do more Android development in the future)

Let's configure our USB access.

gksudo gedit /etc/udev/rules.d/51-android.rules

A text editor should pop up with a blank file. Copy and paste this to the file:

#Acer
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666"

#ASUS
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666"

#Dell
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666"

#Foxconn
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666"

#Garmin-Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="091E", MODE="0666"

#Google
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666"

#HTC
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666"

#Huawei
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666"

#K-Touch
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666"

#KT Tech
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666"

#Kyocera
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666"

#Lenevo
SUBSYSTEM=="usb", ATTR{idVendor}=="17EF", MODE="0666"

#LG
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666"

#Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666"

#NEC
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666"

#Nook
SUBSYSTEM=="usb", ATTR{idVendor}=="2080", MODE="0666"

#Nvidia
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666"

#OTGV
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666"

#Pantech
SUBSYSTEM=="usb", ATTR{idVendor}=="10A9", MODE="0666"

#Philips
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", MODE="0666"

#PMC-Sierra
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666"

#Qualcomm
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666"

#SK Telesys
SUBSYSTEM=="usb", ATTR{idVendor}=="1f53", MODE="0666"

#Samsung
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666"

#Sharp
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666"

#Sony Ericsson
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666"

#Toshiba
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666"

#ZTE
SUBSYSTEM=="usb", ATTR{idVendor}=="19D2", MODE="0666"

Save and close the file. Now do this to change its permissions:

sudo chmod a+r /etc/udev/rules.d/51-android.rules

2) Now we will need to download the Android SDK and set it up properly.

Download the SDK here: http://developer.android.com/sdk/index.html

Extract the archive to your home directory and name it android-sdk

In your home folder, press CTRL + H to show hidden files.

Open up your .bashrc and paste this at the end:

# Android tools
export PATH=${PATH}:~/android-sdk/tools
export PATH=${PATH}:~/android-sdk/platform-tools
export PATH=${PATH}:~/bin

Open .profile and put this at the end as well:

PATH="$HOME/android-sdk/tools:$HOME/android-sdk/platform-tools:$PATH"

The SDK has now been setup properly. You can type

android

in terminal to bring up the SDK menu and install tools/packages if you want.

Step 2: Getting the source downloaded

1) Installing repo and syncing the repository.

Open a new terminal window and type this in:

mkdir ~/bin
PATH=~/bin:$PATH
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo

Now let's initialize the Baked repo. I am creating a folder name "baked" which is where I will download the source to.

mkdir baked
cd baked
repo init -u https://github.com/TeamBAKED/platform_manifest.git -b jb-4.2

Let's download the source.

repo sync -j#

The '#' refers to how many simultaneous jobs you want. I usually do -j16 since I have fast fiber-optic internet, so my command would be "repo sync -j16".

Now the source is downloading. You can leave your computer alone until it is done.

Step 3: Adding in configurations for ville.

This step is NOT needed anymore, because the One S has been merged into official BAKED. Skip ahead to step 4! :victory:

Because TeamBaked doesn't officially support the One S, we will have to add in the parts for ville manually and ensure buildability. I have pre-made everything, so there is really nothing you need to do on your part. You just need to download the parts and place them in their correct directories.

1) We need to first add a local_manifest.xml so we can integrate the projects needed for ville during repo sync. Luckily, I have already prepared one. :) In baked/.repo/ create a file named "local_manifest.xml", and paste this in:

Save and close. Then do another

repo sync -j#

so we can now fetch the additional ville-related parts. The manifest tracks the CM10.1 repos for the kernel and msm8960 common stuff, but the device tree that it tracks is from my Github because I have modified it for the Baked ROM. I'll try and keep it as updated as the CM10.1 device tree as development continues.

2) Now we need another config file, which tells the build system what to execute and which device-specific parameters to be set. Go into baked/vendor/baked/products/ and create a file named "ville.mk". Paste this in:

# Inherit AOSP device configuration for ville.
$(call inherit-product, device/htc/ville/device_ville.mk)

# Inherit common product files.
$(call inherit-product, vendor/baked/configs/common.mk)

# Inherit GSM common stuff
$(call inherit-product, vendor/baked/configs/gsm.mk)

# Setup device specific product configuration.
PRODUCT_NAME := baked_ville
PRODUCT_BRAND := HTC
PRODUCT_DEVICE := ville
PRODUCT_MODEL := HTC One S
PRODUCT_MANUFACTURER := HTC

PRODUCT_BUILD_PROP_OVERRIDES += PRODUCT_NAME=htc_ville BUILD_FINGERPRINT=tmous/ville/ville:4.0.4/IMM76D/96068.7:user/release-keys PRIVATE_BUILD_DESC="=2.35.531.7 CL96068 release-keys" BUILD_NUMBER=96068

# bootanimation
PRODUCT_COPY_FILES += \
vendor/baked/prebuilt/bootanimation/bootanimation_540_960.zip:system/media/bootanimation.zip

Now open up AndroidProducts.mk. We need to tell it to call the configuration file that you just created. Add in

$(LOCAL_DIR)/ville.mk \

right after vibrantmtd. So the whole file should look something like this (at the time of writing, YMMV):

PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/captivatemtd.mk \
$(LOCAL_DIR)/crespo.mk \
$(LOCAL_DIR)/crespo4g.mk \
$(LOCAL_DIR)/d2att.mk \
$(LOCAL_DIR)/d2mtr.mk \
$(LOCAL_DIR)/d2spr.mk \
$(LOCAL_DIR)/d2tmo.mk \
$(LOCAL_DIR)/d2usc.mk \
$(LOCAL_DIR)/d2vzw.mk \
$(LOCAL_DIR)/endeavoru.mk \
$(LOCAL_DIR)/fascinatemtd.mk \
$(LOCAL_DIR)/galaxysmtd.mk \
$(LOCAL_DIR)/i9300.mk \
$(LOCAL_DIR)/grouper.mk \
$(LOCAL_DIR)/maguro.mk \
$(LOCAL_DIR)/mako.mk \
$(LOCAL_DIR)/manta.mk \
$(LOCAL_DIR)/mesmerizemtd.mk \
$(LOCAL_DIR)/p3113.mk \
$(LOCAL_DIR)/p5wifi.mk \
$(LOCAL_DIR)/toro.mk \
$(LOCAL_DIR)/tf201.mk \
$(LOCAL_DIR)/tf300t.mk \
$(LOCAL_DIR)/tf700t.mk \
$(LOCAL_DIR)/toroplus.mk \
$(LOCAL_DIR)/showcasemtd.mk \
$(LOCAL_DIR)/stingray.mk \
$(LOCAL_DIR)/vibrantmtd.mk \
[COLOR="Red"][B]$(LOCAL_DIR)/ville.mk \[/B][/COLOR]
$(LOCAL_DIR)/wingray.mk

Step 4: Actually building. FInally!

1) Open a terminal, and navigate to the baked/ directory.

2) Type this:

cp external/kernel-headers/original/sound/asound.h prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/sysroot/usr/include/sound/

You will run into errors if you don't copy over that kernel header. AOSP Jelly Bean glibc sysroot seems to include an asound.h that relies on uint32t which isn't (normally) defined.

3) Type:

. build/envsetup.sh
lunch

4) You will be brought up with a menu that looks something like this:

You're building on Linux

Lunch menu... pick a combo:
1. mini_armv7a_neon-userdebug
2. mini_armv7a-userdebug
[B][COLOR="Red"]3. baked_ville-userdebug[/COLOR][/B]
4. full_panda-userdebug
5. baked_toro-userdebug
6. baked_maguro-userdebug
7. baked_mako-userdebug
8. baked_manta-userdebug
9. baked_toroplus-userdebug
10. baked_crespo-userdebug
11. baked_crespo4g-userdebug
12. baked_grouper-userdebug
13. baked_captivatemtd-userdebug
14. baked_d2att-userdebug
15. baked_d2mtr-userdebug
16. baked_d2spr-userdebug
17. baked_d2tmo-userdebug
18. baked_d2usc-userdebug
19. baked_d2vzw-userdebug
20. baked_endeavoru-userdebug
21. baked_fascinatemtd-userdebug
22. baked_galaxysmtd-userdebug
23. baked_i9300-userdebug
24. baked_mesmerizemtd-userdebug
25. baked_p3113-userdebug
26. baked_p5wifi-userdebug
27. baked_showcasemtd-userdebug
28. baked_stingray-userdebug
29. baked_tf201-userdebug
30. baked_tf300t-userdebug
31. baked_tf700t-userdebug
32. baked_vibrantmtd-userdebug
33. baked_wingray-userdebug

Which would you like? [full-eng]

See that baked_ville-userdebug is at number 3. So type in '3' or whatever the corresponding number is.

4) Now wait a minute or two (depending on how fast your computer is) as it calls the makefiles and sets up your build system.

5) When the 'lunch' has finished, you should see something like this:

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.2.1
TARGET_PRODUCT=baked_ville
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.5.3-gentoo-x86_64-Intel-R-_Core-TM-_i7-3930K_CPU_@_3.20GHz-with-gentoo-2.1
HOST_BUILD_TYPE=release
BUILD_ID=JOP40D
OUT_DIR=/home/klin1344/baked/out
============================================

Now type in

mka bacon -j#

and the build process will begin! Again, here the -j# is an option on how many simultaneous jobs you want. It's common to use a number between 1 and 2 times the number of hardware threads on the computer being used for the build.

5) When the build is done, you should get a package in baked/out/target/product/ville/.

6) Flash and enjoy!!

Updating / Re-building

Always do a full clean when you want to update your build.

1) Clean out the previous build(s).

rm -rf out

2) Sync up the repo to get the latest changes.

repo sync -j#

3) Follow the tutorial again starting from Step 4.