0x0001 设置参数
tom@tommain:/media/tom/rom$ source build/envsetup.sh
including device/asus/deb/vendorsetup.sh
including device/asus/flo/vendorsetup.sh
including device/asus/fugu/vendorsetup.sh
including device/generic/mini-emulator-arm64/vendorsetup.sh
including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh
including device/generic/mini-emulator-mips/vendorsetup.sh
including device/generic/mini-emulator-x86_64/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
including device/htc/flounder/vendorsetup.sh
including device/huawei/angler/vendorsetup.sh
including device/lge/bullhead/vendorsetup.sh
including device/lge/hammerhead/vendorsetup.sh
including device/moto/shamu/vendorsetup.sh
including sdk/bash_completion/adb.bash
0x0002设定编译目标
tom@tommain:/media/tom/rom$ lunch full-eng
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=6.0.1
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
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-62-generic-x86_64-with-Ubuntu-16.04-xenial
HOST_BUILD_TYPE=release
BUILD_ID=MMB29S
OUT_DIR=out
============================================
发现这么搞不对阿。
默认是arm的,可是我要在虚拟机里先跑跑,所以重新设定。
tom@tommain:/media/tom/rom$ lunch
You're building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_mips-eng
4. aosp_mips64-eng
5. aosp_x86-eng
6. aosp_x86_64-eng
7. aosp_deb-userdebug
8. aosp_flo-userdebug
9. full_fugu-userdebug
10. aosp_fugu-userdebug
11. mini_emulator_arm64-userdebug
12. m_e_arm-userdebug
13. mini_emulator_mips-userdebug
14. mini_emulator_x86_64-userdebug
15. mini_emulator_x86-userdebug
16. aosp_flounder-userdebug
17. aosp_angler-userdebug
18. aosp_bullhead-userdebug
19. aosp_hammerhead-userdebug
20. aosp_hammerhead_fp-userdebug
21. aosp_shamu-userdebug
Which would you like? [aosp_arm-eng] 14
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=6.0.1
TARGET_PRODUCT=mini_emulator_x86_64
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=x86_64
TARGET_CPU_VARIANT=
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=x86
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-62-generic-x86_64-with-Ubuntu-16.04-xenial
HOST_BUILD_TYPE=release
BUILD_ID=MMB29S
OUT_DIR=out
============================================
0x0003补上之前设置的编译的需求
上原文:
Optimizing a build environment (optional)
Setting up ccache
You can optionally tell the build to use the ccache compilation tool, which is a compiler cache for C and C++ that can help make builds faster. It is especially useful for build servers and other high-volume production environments. Ccache acts as a compiler cache that can be used to speed up rebuilds. This works very well if you use make clean often, or if you frequently switch between different build products.
Note: If you're instead conducting incremental builds (such as an individual developer rather than a build server), ccache may slow your builds down by making you pay for cache misses.
To use ccache, issue these commands in the root of the source tree:
$ export USE_CCACHE=1
$ export CCACHE_DIR=/<path_of_your_choice>/.ccache
$ prebuilts/misc/linux-x86/ccache/ccache -M 50G
The suggested cache size is 50-100G.
Put the following in your .bashrc (or equivalent):
export USE_CCACHE=1
跟着做:
NOTE: prebuilts 这个就在下载的目录里
tom@tommain:/media/tom/rom$ ls
abi bin bootable cts developers device external hardware libnativehelper Makefile packages platform_testing sdk tools
art bionic build dalvik development docs frameworks libcore lost+found ndk pdk prebuilts system
tom@tommain:/media/tom/rom$ prebuilts/misc/linux-x86
linux-x86/ linux-x86_64/
tom@tommain:/media/tom/rom$ prebuilts/misc/linux-x86_64/swig/
ccache-swig swig
tom@tommain:/media/tom/rom$ prebuilts/misc/linux-x86_64/swig/
ccache-swig swig
tom@tommain:/media/tom/rom$ prebuilts/misc/linux-x86/
analyzer/ bison/ ccache/ flex/ futility/ protobuf/ relocation_packer/ yasm/
tom@tommain:/media/tom/rom$ prebuilts/misc/linux-x86/ccache/ccache -M 50G
Set cache size limit to 50.0 Gbytes
配置ccache.
tom@tommain:/media/tom/rom$ sudo apt-get install -y ccache
[sudo] password for tom:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gir1.2-gkbd-3.0 gir1.2-xkl-1.0
Use 'sudo apt autoremove' to remove them.
Suggested packages:
distcc
The following NEW packages will be installed:
ccache
0 upgraded, 1 newly installed, 0 to remove and 184 not upgraded.
Need to get 83.7 kB of archives.
After this operation, 261 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 ccache amd64 3.2.4-1 [83.7 kB]
Fetched 83.7 kB in 2s (31.3 kB/s)
Selecting previously unselected package ccache.
(Reading database ... 330756 files and directories currently installed.)
Preparing to unpack .../ccache_3.2.4-1_amd64.deb ...
Unpacking ccache (3.2.4-1) ...
Processing triggers for doc-base (0.10.7) ...
Processing 1 added doc-base file...
Processing triggers for man-db (2.7.5-1) ...
Setting up ccache (3.2.4-1) ...
Updating symlinks in /usr/lib/ccache ...
注意最后的ccache的配置
tom@tommain:~$ tail .bashrc
export ANDROID_SDK_HOME=/home/tom/Android/Sdk/
export ANDROID_PLATFORM_HOME=$ANDROID_SDK_HOME/platform-tools
export ANDROID_TOOLS=$ANDROID_SDK_HOME/tools
export ANDROID_BUILD_TOOLS=$ANDROID_SDK_HOME/build-tools/25.0.0
export PATH=$PATH:$ANDROID_PLATFORM_HOME/:$ANDROID_TOOLS/:$ANDROID_TOOLS/bin/:$ANDROID_BUILD_TOOLS/:/home/tom/mybin/:
export PATH=$PATH:/media/tom/rom/bin:
export PATH=/usr/lib/ccache:$PATH:
export CCACHE_DIR=/media/tom/rom/.ccache
tom@tommain:~$
中间调整了下/rom的目录结构,把代码放到了src中,新建了.ccache目录。默认的话,.ccache目录在~/下。擦,硬盘不够,只能放出来。最终目录如下:
tom@tommain:/media/tom/rom$ tree -aL 2
.
├── bin
│ └── repo
├── .ccache
├── lost+found [error opening dir]
└── src
├── abi
├── art
├── bionic
├── bootable
├── build
├── cts
├── dalvik
├── developers
├── development
├── device
├── docs
├── external
├── frameworks
├── hardware
├── libcore
├── libnativehelper
├── Makefile
├── ndk
├── packages
├── pdk
├── platform_testing
├── prebuilts
├── .repo
├── sdk
├── system
└── tools
29 directories, 2 files
tom@tommain:/media/tom/rom$
0x0004好激动,终于要开始编译了。。(8核就是吊!!!)
tom@tommain:/media/tom/rom/src$ make -j8
0x0005吊到没朋友!!!
人在兴奋的时候往往会碰到问题。
tom@tommain:/media/tom/rom/src$ make -j8
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=6.0.1
TARGET_PRODUCT=mini_emulator_x86_64
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=x86_64
TARGET_CPU_VARIANT=
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=x86
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-62-generic-x86_64-with-Ubuntu-16.04-xenial
HOST_BUILD_TYPE=release
BUILD_ID=MMB29S
OUT_DIR=out
============================================
Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of java.
Your version is: java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode).
The required version is: "1.7.x"
Please follow the machine setup instructions at
https://source.android.com/source/initializing.html
************************************************************
build/core/main.mk:171: *** stop. Stop.
#### make failed to build some targets (1 seconds) ####
我了个擦!!! 居然要1.7!!!!