Chinaunix首页 | 论坛 | 博客
  • 博客访问: 23621
  • 博文数量: 4
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 70
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-28 08:55
个人简介

大海中的白桦树

文章分类

全部博文(4)

文章存档

2018年(1)

2017年(3)

最近访客

分类: Android平台

2017-02-06 16:59:49


/*****************************************************************************

 * Author : Elvins Fu      yeyecheng_93@163.com

 *

 * Info : Boway Inc,(C) 2016-11-26, All rights revseved. 

 *

 * This document is summed up by the author for that the  R&D install the   

 * Java running environment or Java development kit and build the project

 * on Android 7.0 Platfrom success.

****************************************************************************/

--------------------------------------------------------

可以连接外网的情况下,使用

sudo add-apt-repository ppa:openjdk-r/ppa

sudo apt-get update

  sudo apt-get install openjdk-8-jdk

-------------------------------------

不能连接外网的情况下,

ahmed@ubuntu:~$ sudo add-apt-repository ppa:webupd8team/java

ahmed@ubuntu:~$ sudo apt-get update

ahmed@ubuntu:~$ sudo apt-get install oracle-java8-installer


问题: Unable to locate package oracle-java8-installer

解决办法:

echo "deb precise main" > /etc/apt/sources.list.d/webupd8team-java.list

echo "deb-src precise main" >> /etc/apt/sources.list.d/webupd8team-java.list

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886

再重复上述操作,若还是不行,则下载源码编译。


--------------------------------------------------------

此时源码安装下载

或者


1.下载Mercurial

Mercurial 是强大的分布式版本控制系统. 本文将介绍如何在 Ubuntu 下快速的最新版的安装Mercurial, 其实只要几条命令就可以搞定了

sudo add-apt-repository ppa:tortoisehg-ppa/releases

sudo add-apt-repository ppa:mercurial-ppa/releases

sudo apt-get update

sudo apt-get install mercurial python-nautilus tortoisehg


2.建立文件目录,下载安装预装环境

bule@sky:~$ hg clone jdk8-1773f1fd0fac.tar.gz

bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ ls

ASSEMBLY_EXCEPTION get_source.sh Makefile test

common LICENSE README THIRD_PARTY_README

configure make README-builds.html

有一个 README-builds.html 描述了如何 build 整个系统,一些细节需要自己去寻找。


3.下载编译文件源码 (网站下载较慢,等待几十分钟)

bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ bash ./get_source.sh

# Repositories: corba jaxp jaxws langtools jdk hotspot nashorn

corba: hg clone /corba corba

jaxp: hg clone /jaxp jaxp


bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ ls

ASSEMBLY_EXCEPTION hotspot LICENSE README-builds.html

common jaxp make test

configure jaxws Makefile THIRD_PARTY_README

corba jdk nashorn

get_source.sh langtools README


4.安装/更新依赖,在openJDK7上升级

bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ sudo apt-get install aptitude

我下载aptitude的目的是在于aptitude比apt-get处理依赖性更好一些


bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ sudo aptitude build-dep openjdk-7

bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ sudo aptitude install openjdk-7-jdk


5.环境变量配置

bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ vi ~/.bashrc (放在这里的好处不用说明)

export LANG=C

export PATH="/usr/lib/jvm/java-7-openjdk/bin:${PATH}"

bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ source ~/.bashrc


6.配置编译选项

bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ bash ./configure

想编译出调试版本的,可以给 configure 加参数,编译有 release等几种编译级别,可以在调试时候提供更多的信息。


通常系统缺少ccache,下载该包加快编译速度。

bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ sudo apt-get install ccache


调试一下:-enable-debug 其实相当于 --with-debug-level=fastdebug, 可以通过这样的参数选项指定编译级别。一共可以指定三种级别: release, fastdebug, slowdebug, slowdebug 含有最丰富的调试信息,没有这些信息,很多执行可能被优化掉,我们单步执行时,可能看不到一些变量的值。所以最好指定slowdebug 为编译级别。


bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ bash ./configure --enable-debug

注意以下信息

Configuration summary:

* Debug level: fastdebug (编译级别release此时改变fastdebug)

* JDK variant: normal

* JVM variants: server

* OpenJDK target: OS: linux, CPU architecture: x86, address length: 64


Tools summary:

* Boot JDK: java version "1.7.0_121" OpenJDK Runtime Environment (IcedTea 2.6.8) (7u121-2.6.8-1ubuntu0.14.04.1) OpenJDK 64-Bit Server VM (build 24.121-b00, mixed mode) (at /usr/lib/jvm/java-7-openjdk-amd64)


7.编译 (时间有点慢,耐心等待)

bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ make

No CONF given, but more than one configuration found in /home/bule/JDK/jdk8-1773f1fd0fac.tar.gz//build.

Available configurations:

* linux-x86_64-normal-server-fastdebug

* linux-x86_64-normal-server-release

Please retry building with CONF= (or SPEC=)

Makefile:55: *** Cannot continue. Stop. (需要指定哪种编译器配置/我的是上面两种64位的模式)


bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz$ make CONF=linux-x86_64-normal-server-release


编译成功

----- Build times -------

Start 2016-11-26 11:03:49

End 2016-11-26 11:18:12

00:00:21 corba

00:10:23 hotspot

00:00:16 jaxp

00:00:21 jaxws

00:02:35 jdk

00:00:27 langtools

00:14:23 TOTAL

-------------------------

Finished building OpenJDK for target 'default'

bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz


bule@sky:~/JDK/jdk8-1773f1fd0fac.tar.gz/build/linux-x86_64-normal-server-fastdeb

ug/jdk/bin$ ./java -version

openjdk version "1.8.0-internal"

OpenJDK Runtime Environment (build 1.8.0-internal-fastdebug-bule_2016_11_26_10_59-b00)

OpenJDK 64-Bit Server VM (build 25.71-b00-fastdebug, mixed mode)


--------------------------------------

8.加入Ubuntu切换版本


sudo update-alternatives --install /usr/bin/java java /home/bule/JDK/jdk8-1773f1fd0fac.tar.gz/build/linux-x86_64-normal-server-release/jdk/bin/java 300


sudo update-alternatives --install /usr/bin/javac javac /home/bule/JDK/jdk8-1773f1fd0fac.tar.gz/build/linux-x86_64-normal-server-release/jdk/bin/javac 300


sudo update-alternatives --install /usr/bin/javap javap /home/bule/JDK/jdk8-1773f1fd0fac.tar.gz/build/linux-x86_64-normal-server-release/jdk/bin/javap 300


sudo update-alternatives --install /usr/bin/javah javah /home/bule/JDK/jdk8-1773f1fd0fac.tar.gz/build/linux-x86_64-normal-server-release/jdk/bin/javah 300


sudo update-alternatives --install /usr/bin/jar jar /home/bule/JDK/jdk8-1773f1fd0fac.tar.gz/build/linux-x86_64-normal-server-release/jdk/bin/jar 300


-------------------------------------

9.选择切换的版本

sudo update-alternatives --config java

sudo update-alternatives --config javac

sudo update-alternatives --config javah

sudo update-alternatives --config javap

sudo update-alternatives --config jar

sudo update-alternatives --config javadoc


10.查看

bule@sky:~$ java -version

openjdk version "1.8.0-internal"

OpenJDK Runtime Environment (build 1.8.0-internal-bule_2016_11_26_10_58-b00)

OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)


11.编译Android 7.0工程

bule@sky:~/workspace/jianwen.fu/jianwen.fu/V65_7.0$ make

build/core/config.mk:600: *** Error: could not find jdk tools.jar at /home/bule/JDK/jdk8-1773f1fd0fac.tar.gz/build/linux-x86_64-normal-server-release/jdk/bin/../lib/tools.jar, please check if your JDK was installed correctly. Stop.


Android工程的build/core/config.mk 需要在jdk/bin/../lib目录中有tools.jar文件,但是编译的源码是没有的,那么查看ubuntu目录带有的

bule@sky:~$ find /usr/lib/jvm -name tools.jar

/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/lib/tools.jar

拷贝tools.tar到/home/bule/JDK/jdk8-1773f1fd0fac.tar.gz/build/linux-x86_64-normal-server-release/jdk/bin/../lib/目录中



12.此时大功告成,可以放心的编译Android 7.0的工程





阅读(1940) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:Android 7.0工程之预编译jack服务器

给主人留下些什么吧!~~