Fedroa 16 编译Android 源码

1 安装jdk 6U43
转载请注明出处 [By SELinux+]

[root@android Android_build]# wget ftp://10.2.20.58/pub/jdk-6u43-linux-x64-rpm.bin
[root@android Android_build]# chmod +x jdk-6u43-linux-x64-rpm.bin
[root@android Android_build]# ./jdk-6u43-linux-x64-rpm.bin

2 对java的版本进行管理
[root@android Android_build]# alternatives –install /usr/bin/java java /usr/java/jdk1.6.0_43/bin/java 100

[root@android Android_build]# alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_43/bin/jar 100
[root@android Android_build]# alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_43/bin/javac 100
[root@android Android_build]# alternatives --config java
There are 2 programs which provide 'java'.

Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
2 /usr/java/jdk1.6.0_43/bin/java

Enter to keep the current selection[+], or type selection number: 2

3 确定版本

[root@android Android_build]# java -version
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode

4 设置路径

[root@android Android_build]# cat java.sh
export JAVA_HOME=/usr/java/jdk1.6.0_43
export CLASSPATH=.:${JAVA_HOME}/lib;
export PATH=${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin:${PATH}

5 安装依赖软件包

[root@android Android_build]# cat yum.sh
yum install git gnupg valgrind flex bison gperf zip curl ncurses-devel readline-devel zlib-devel libX11-devel xorg-x11-proto-devel libuuid-devel uuid uuid-devel libsx-devel

=================
6 下载源码 //参照官方文档[root@android Android_Directory]# repo sync
7 编译

[root@android Android_Directory]# source build/envsetup.sh
including device/asus/grouper/vendorsetup.sh
including device/asus/tilapia/vendorsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/armv7-a/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/toroplus/vendorsetup.sh
including device/samsung/toro/vendorsetup.sh
including device/ti/panda/vendorsetup.sh
including sdk/bash_completion/adb.bash
2
[root@android Android_Directory]# lunch full-eng

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.2.2
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.1.0-7.fc16.x86_64-x86_64-with-fedora-16-Verne
HOST_BUILD_TYPE=release
BUILD_ID=JDQ39
OUT_DIR=out
============================================

[root@android Android_Directory]# make -j4
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.2.2
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.1.0-7.fc16.x86_64-x86_64-with-fedora-16-Verne
HOST_BUILD_TYPE=release
BUILD_ID=JDQ39
OUT_DIR=out
============================================

遇到问题(1)

make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/html/DocTypeStrings.cpp] Error 2

解决方法:
vim webkit.patch
——————————————————

diff --git a/Source/WebCore/make-hash-tools.pl b/Source/WebCore/make-hash-tools.pl
index 37639eb..2968beb 100644
--- a/Source/WebCore/make-hash-tools.pl
+++ b/Source/WebCore/make-hash-tools.pl
@@ -20,7 +20,8 @@
# Boston, MA 02110-1301, USA.

use strict;
-use Switch;
+# use Switch;
+use feature qw(switch);
use File::Basename;

my $outdir = $ARGV[0];
@@ -28,9 +29,9 @@ shift;
my $option = basename($ARGV[0],".gperf");

-switch ($option) {
+given ($option) {

-case "DocTypeStrings" {
+when ("DocTypeStrings") {

my $docTypeStringsGenerated = "$outdir/DocTypeStrings.cpp";
my $docTypeStringsGperf = $ARGV[0];
@@ -40,7 +41,7 @@ case "DocTypeStrings" {

} # case "DocTypeStrings"

-case "ColorData" {
+when ("ColorData") {

my $colorDataGenerated = "$outdir/ColorData.cpp";
my $colorDataGperf = $ARGV[0];

—————————————————-

cp webkit.patch ../Android_Directory/external/webkit/webkit.patch

问题(2)

prebuilts/tools/gcc-sdk/g++: prebuilts/tools/gcc-sdk/../../gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/i686-linux-g++: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

./../../i686-linux/bin/as: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

需要分别打上以下补丁
vim oprofile.patch
——————————————————————

diff --git a/libpp/format_output.h b/libpp/format_output.h
index b6c4592..4efdbb1 100644
--- a/libpp/format_output.h
+++ b/libpp/format_output.h
@@ -91,7 +91,8 @@ protected:
symbol_entry const & symbol;
sample_entry const & sample;
size_t pclass;
- mutable counts_t & counts;
+// mutable counts_t & counts;
+ counts_t & counts;
extra_images const & extra;
double diff;
};

————————————————–
vim gtest.patch
————————————————–

t a/include/gtest/internal/gtest-param-util.h b/include/gtest/internal/gtest-param-util.h
index 5559ab4..b964c45 100644
--- a/include/gtest/internal/gtest-param-util.h
+++ b/include/gtest/internal/gtest-param-util.h
@@ -37,6 +37,7 @@
#include <iterator>
#include <utility>
#include <vector>
+#include <cstddef>

#include <gtest/internal/gtest-port.h>

—————————————————
vim slang.patch
—————————————————

diff --git a/Android.mk b/Android.mk
index fce3637..aff5b7d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -19,7 +19,8 @@ ifeq ($(TARGET_BUILD_APPS),)

LOCAL_PATH := $(call my-dir)

-local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror
+#local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror
+local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter
ifneq ($(TARGET_BUILD_VARIANT),eng)
local_cflags_for_slang += -D__DISABLE_ASSERTS
endif

————————————————-
vim development.patch
————————————————-

t a/tools/emulator/opengl/host/renderer/Android.mk b/tools/emulator/opengl/host/renderer/Android.mk
index 55fcb80..5e4d0bb 100644
--- a/tools/emulator/opengl/host/renderer/Android.mk
+++ b/tools/emulator/opengl/host/renderer/Android.mk
@@ -5,6 +5,7 @@ $(call emugl-begin-host-executable,emulator_renderer)
$(call emugl-import,libOpenglRender)
LOCAL_SRC_FILES := main.cpp
LOCAL_CFLAGS += -O0 -g
+LOCAL_LDLIBS += -lX11

#ifeq ($(HOST_OS),windows)
#LOCAL_LDLIBS += -lws2_32

———————————————

[root@android Android_build]# cp oprofile.patch ../Android_Directory/external/oprofile/
[root@android Android_build]# cp gtest.patch ../Android_Directory/external/gtest/
[root@android Android_build]# cp slang.patch ../Android_Directory/frameworks/compile/slang/
[root@android Android_build]# cp development.patch ../Android_Directory/development/

[root@android webkit]# patch -p1 <webkit.patch
patching file Source/WebCore/make-hash-tools.pl
[root@android oprofile]# patch -p1 < oprofile.patch
patching file libpp/format_output.h
Hunk #1 FAILED at 91.
1 out of 1 hunk FAILED -- saving rejects to file libpp/format_output.h.rej

[root@android gtest]# patch -p1 <gtest.patch
patching file include/gtest/internal/gtest-param-util.h
Hunk #1 succeeded at 37 with fuzz 2.
[root@android slang]# patch -p1 < slang.patch
patching file Android.mk

遇到问题

target Generated: lib_renderControl_dec <= out/host/linux-x86/obj/EXECUTABLES/emugen_intermediates/emugen
out/host/linux-x86/obj/EXECUTABLES/emugen_intermediates/emugen: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

Copying: out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes-jarjar.jar
out/host/linux-x86/bin/acp: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
out/host/linux-x86/bin/acp: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
out/host/linux-x86/bin/acp: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
Install: out/host/linux-x86/framework/dx.jar

解决方法

[root@android Android_build]# yum install libgcc
yum install glibc.i686 ncurses-libs.i686 libstdc libstdc++.i686 libzip.i686 libX11.i686 libXrandr.i686 SDL.i686

One Reply to “Fedroa 16 编译Android 源码”

发表评论

您的电子邮箱地址不会被公开。