안드로이드 소스 빌드...(ver 0.1)
리눅스 2010. 6. 28. 14:27
http://android.git.kernel.org/
참조..
우분투 상에선 다음을 참조하자.
이걸 다 깔아도 가끔식 안될 때가 있는데 git 코어가 안 깔려있을 경우이다.
참조..
우분투 상에선 다음을 참조하자.
Ubuntu Linux (32-bit x86)
To set up your Linux development environment, make sure you have the following:
- Required Packages:
- Git 1.5.4 or newer and the GNU Privacy Guard.
- JDK 5.0, update 12 or higher.Java 6 is not supported, because of incompatibilities with @Override.
- flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl.
$ sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
- You might also want Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc.
$ sudo apt-get install valgrind
- Intrepid ( 8.10) users may need a newer version of libreadline:
$ sudo apt-get install lib32readline5-dev -->>> 이건 없는 파일인듯. 생략하자.
이걸 다 깔아도 가끔식 안될 때가 있는데 git 코어가 안 깔려있을 경우이다.
다음과 같은 에러 메시지가 나온다.
apt-get install git-core
Installing Repo
Initializing a Repo client
repo initialized in /mydroid
를 참조한다.
apt-get install git-core
를 해준다.
Installing Repo
Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see Using Repo and Git .
- Make sure you have a~/bindirectory in your home directory, and check to be sure that this bin directory is in your path:
$ cd ~
$ mkdir bin
$ echo $PATH
- Download thereposcript and make sure it is executable:
$ curl http://android.git.kernel.org/repo >~/bin/repo$ chmod a+x ~/bin/repo
Initializing a Repo client
- Create an empty directory to hold your working files:
$ mkdir mydroid
$ cd mydroid
- Run "repo init" to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest:
$ repo init -u git://android.git.kernel.org/platform/manifest.git - If you would like to check out a branch other than "master", specify it with -b, like:
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
- When prompted, configure Repo with your real name and email address. If you plan to submit code, use an email address that is associated with a Google account .
repo initialized in /mydroid
를 참조한다.
그런데 간단하게는 2,3번 절차에서
mkdir mydroid
cd mydroid
repo init -u git://android.git.kernel.org/platform/manifest.git
repo sync
cd mydroid
repo init -u git://android.git.kernel.org/platform/manifest.git
repo sync
로 끝낼 수도 있다.
다만 소스 크기가 매우 크므로 시간이 오래 걸린다.
도중에 멈춘 경우엔 다시
repo sync
를 입력하여 소스를 다운 받자.
다만 소스 크기가 매우 크므로 시간이 오래 걸린다.
도중에 멈춘 경우엔 다시
repo sync
를 입력하여 소스를 다운 받자.
Android Build System
안드로이드는 GNU 의 최신 버전의 make 를 사용한다.
# make -v
버전이 3.80 보다 작으면 업그레이드 해야한다.
Understanding the makefile
Makefile 엔 다음과 같은 정보를 담아야 한다.
Name: Give your build a name (LOCAL_MODULE := <build_name>).
Local Variables: Clear local variables with CLEAR_VARS (include
Files: Determine which files your application depends upon
(LOCAL_SRC_FILES := main.c).
Tags: Define tags, as necessary (LOCAL_MODULE_TAGS := eng development).
Libraries: Define whether your application links with other libraries
(LOCAL_SHARED_LIBRARIES := cutils).
Template file: Include a template file to define underlining make tools
for a particular target (include
정형적인 메이크 파일은 다음과 같다.
LOCAL_PATH :=
include
LOCAL_MODULE := <buil_name>
LOCAL_SRC_FILES := main.c
LOCAL_MODULE_TAGS := eng development
LOCAL_SHARED_LIBRARIES := cutils
include
(HOST_)EXECUTABLE, (HOST_)JAVA_LIBRARY, (HOST_)PREBUILT,
(HOST_)SHARED_LIBRARY,
(HOST_)STATIC_LIBRARY, PACKAGE, JAVADOC, RAW_EXECUTABLE,
RAW_STATIC_LIBRARY,
COPY_HEADERS, KEY_CHAR_MAP
Layers
빌드는 아래 테이블에 기술된 추상화된 계층을 포함하는 구조로 이루어진다.
@@Layer (Example) -------
Description
@@Product (myProduct,
myProduct_eu, myProduct_eu_fr, j2, sdk )
-------- The product layer defines a complete specification of a
shipping product, defining which modules to build and how to configure
them. You might offer a device in several different versions based on
locale, for example, or on features such as a camera.
@@Device (myDevice,
myDevice_eu, myDevice_eu_lite) --------- The device layer represents the
physical layer of plastic on the device. For example, North American
devices probably include QWERTY keyboards whereas devices sold in France
probably include AZERTY keyboards. Peripherals typically connect to the
device layer.
@@Board (sardine,
trout, goldfish)
----------- The board layer represents the bare schematics of a product. You may still connect peripherals to the board layer.
----------- The board layer represents the bare schematics of a product. You may still connect peripherals to the board layer.
@@Arch (arm
(arm5te) (arm6), x86, 68k ) ----------The arch layer describes
the processor running on your board.
Building the Android Platform
이번 섹션은 안드로이드의 기본 빌드 방법에 대해 기술한다. 한번 이러한 빌드를 익힌 후면, 타겟 디바이스로의 수정도 가능하게
될거다.
Device Code
일반적인 빌드를 하기 위해서 build/envsetup.sh 의 소스엔 필요한 변수들을 담고 있다.
% cd
% . build/envsetup.sh
# pick a configuration using choosecombo
% choosecombo
% make -j4 PRODUCT-generic-user
eng 로 바꿔 쓸 수도 있다.
% make -j4 PRODUCT-generic-eng
이렇게 빌드 변수를 바꿔가면서 여러가지 디버깅 옵션을 줄 수 있다.
Cleaning Up
Execute % m clean to clean up the binaries you just created. You
can also execute % m clobber to get rid of the binaries of all combos. %
m clobber is equivalent to removing the //out/ directory where all
generated files are stored.
Speeding Up Rebuilds
각각의 combo 바이너리들은 분리된 sub-directories of //out/ 에 저장되어 있다. 이 바이너리들은 재
컴파일시에 빌드 타임을 단축시켜준다.
그러나, 환경 변수 등을 수정한 경우에는 완전 재빌드가 필요하다. 이러한 경우 USE-CCACHE 환경 변수를 다음과 같이
설정한다
% export USE_CCACHE=1
CCASH 는 //prebuilt/. 에 설치되어 있으므로 따로 설치할 필요가 없다.
Troubleshooting
The following error is likely caused by running an outdated version of
Java.
device Dex: core UNEXPECTED TOP-LEVEL ERROR:
java.lang.NoSuchMethodError: method java.util.Arrays.hashCode with
signature ([Ljava.lang.Object;)I was not found.
at com.google.util.FixedSizeList.hashCode(FixedSizeList.java:66)
at com.google.rop.code.Rop.hashCode(Rop.java:245)
at java.util.HashMap.hash(libgcj.so.7)
[...]
dx is a Java program that uses facilities first made available in Java
version 1.5. Check your version of Java by executing % java -version in
the shell you use to build. You should see something like:
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.5.0_07-164)
Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode, sharing)
Java 1.5 이상 버전에서는 이러한 error가 발생한다. 이 때에는 환경 변수에 PATH가 제대로 등록되어있는지 확인한다.
Building the Android Kernel
이번 섹션은 안드로이드의 기본 커널이 어떻게 빌드되는지 기술한다. 한번 이러한 빌드에 익숙해지면, 타겟 디바이스로의
수정도 가능하게 될것이다.
커널 베이스를 빌드하기 위해서 디바이스 디렉토리(/home/joe/android/device)를 바꿔준다.
% . build/envsetup.sh
% partner_setup generic
이 떄, 커널 디렉토리를 /home/joe/android/kernel 로 바꿔준다
Checking Out a Branch
기본 브랜치는 항상 안드로이드가 된다. 다른 브랜치를 체크하고 싶으면, 다음과 같이 실행하라.
% git checkout --track -b android-mydevice origin/android-mydevice
//Branch android-mydevice set up to track remote branch
% refs/remotes/origin/android-mydevice.
//Switched to a new branch "android-mydevice"
To simplify code management, give your local branch the same name
as the remote branch it is tracking (as illustrated in the snippet
above). Switch between branches by executing % git checkout
<branchname>.
Verifying Location
Find out which branches exist (both locally and remotely) and which one
is active (marked with an asterisk) by executing the following:
% git branch -a
android
* android-mydevice
origin/HEAD
origin/android
origin/android-mydevice
origin/android-mychipset
To only see local branches, omit the -a flag.
Building the Kernel
커널을 빌드하고 싶으면 다음과 같이 실행한다.
% make -j4
Build Variants
When building for a particular product, it's often useful to have
minor variations on what is ultimately the final release build. These
are the currently-defined build variants:
eng This
is the default flavor. A plain make is the same as make eng.
Installs modules tagged with: eng, debug, user, and/or development.
Installs non-APK modules that have no tags specified.
Installs APKs according to the product definition files, in
addition to tagged APKs.
ro.secure=0
ro.debuggable=1
ro.kernel.android.checkjni=1
adb is enabled by default.
user make
user
This is the flavor intended to be the final release bits.
Installs modules tagged with user.
Installs non-APK modules that have no tags specified.
Installs APKs according to the product definition files; tags are
ignored for APK modules.
ro.secure=1
ro.debuggable=0
adb is disabled by default.
userdebug make
userdebug
The same as user, except:
Also installs modules tagged with debug.
ro.debuggable=1
adb is enabled by default.
If you build one flavor and then want to build another, you should
run make installclean between the two makes to guarantee that you don't
pick up files installed by the previous flavor. make clean will also
suffice, but it takes a lot longer.