CarlLee
CarlLee

Reputation: 4182

Building from android source code

I don't quite understand how Android version control tool "repo" works.

I ran it repo init -u https://android.googlesource.com/platform/manifest ; repo sync the first time, it downloads 9GB of code.

Then I wanted to switch to a branch where I can build 4.1.1 for my Nexus 7.

I researched online and found using repo init -b BRANCH_NAME again and repo sync will do the trick. But when I did it, it started to download some new code (more than 1GB), then I stopped it and switched back to the master branch using repo init; it downloaded another 2GB of source code. I was very confused since I downloaded the source code the first time, what's the 3GB of source code that's downloaded the 2nd and the 3rd time?

2 more questions:

  1. How can I properly switch branches?
  2. What's the tool called lunch? The official site keeps mentioning it, but never introduces it nor does it mention where to download it and how to set it up (as you can imagine what will come out if I searched 'lunch' in google), only stating it as a 'build tool'.

P.S: At the time of this question, the master branch of Google Android project is at 4.2 Jelly Bean. In case anyone find this question in the future

Upvotes: 2

Views: 629

Answers (1)

AWT
AWT

Reputation: 3717

I know this an old question but I recently went through the same experience and figured I would share what I learned.

To answer question #1:

I don't switch branches. You sync all of the code for whatever branch you want, and build that branch. For example, I have two: master and 4.3_r1, in a folder. To do this, I created two folders:

mkdir /Volumes/android_source/master mkdir /Volumes/android_source/4.3_r1

To init and sync master, I type:

cd /Volumes/android_source/master
repo init -u https://android.googlesource.com/platform/manifest
repo sync

Then, to init and sync the 4.3_r1 build, I type:

cd /Volumes/android_source/4.3_r1
repo init -u https://android.googlesource.com/platform/manifest -b android-4.3_r1
repo sync

Before you build, change into the base directory and source the envsetup.sh file:

# cd /Volumes/android_source/master
# source build/envsetup.sh
including device/asus/deb/vendorsetup.sh
including device/asus/flo/vendorsetup.sh
including device/asus/grouper/vendorsetup.sh
including device/asus/tilapia/vendorsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/mips/vendorsetup.sh
including device/generic/x86/vendorsetup.sh
including device/lge/mako/vendorsetup.sh
including device/samsung/maguro/vendorsetup.sh
including device/samsung/manta/vendorsetup.sh
including device/samsung/toro/vendorsetup.sh
including device/samsung/toroplus/vendorsetup.sh
including device/samsung_slsi/arndale/vendorsetup.sh
including device/ti/panda/vendorsetup.sh
including sdk/bash_completion/adb.bash

To answer question #2, once you've run envsetup.sh, lunch will be in your PATH. Then, tell it what exactly you want to build. For a debug build, tell lunch you want full-eng. You can launch lunch with no args to get a lunch menu.

mbpr15:Android awt$ lunch full-eng

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.3.2.1.000.000
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
HOST_ARCH=x86
HOST_OS=darwin
HOST_OS_EXTRA=Darwin-13.0.0-x86_64-i386-64bit
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
OUT_DIR=out
============================================

Now you're ready to build:

# make -j16

I have an 8 core processor, so I use -j16 when I run the build and it greatly improves the speed.

Hope that helps.

Upvotes: 2

Related Questions