1- adroid 演进过程

Android编译演进过程:

Android7.0之前 使用GNU Make

Android7.0 引入ninja、kati、Android.bp和soong构建系统

Android8.0 默认打开Android.bp

Android9.0 强制使用Android.bp

Make 构建系统得到了广泛的支持和使用,但在 Android 层面变得缓慢、容易出错、无法扩展且难以测试。Soong 构建系统正好提供了 Android build 所需的灵活性。

2- android build 流程

build/ 目录下

blueprint:用于处理Android.bp,编译生成*.ninja文件,用于做ninja的处理

kati:用于处理Android.mk,编译生成*.ninja文件,用于做ninja的处理

make:文件夹还是原始的make那一套流程,比如envsetup.sh

soong:构建系统,核心编译为soong_ui.bash

build 流程

3 编译环境初始化

source build/envsetup.sh

输入指令hmm 就可以查看信息

Run "m help" for help with the build system itself.

Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:

- lunch: lunch -

Selects as the product to build, and as the variant to

build, and stores those selections in the environment to be read by subsequent

invocations of 'm' etc.

- tapas: tapas [ ...] [arm|x86|mips|arm64|x86_64|mips64] [eng|userdebug|user]

- croot: Changes directory to the top of the tree, or a subdirectory thereof.

- m: Makes from the top of the tree.

- mm: Builds all of the modules in the current directory, but not their dependencies.

- mmm: Builds all of the modules in the supplied directories, but not their dependencies.

To limit the modules being built use the syntax: mmm dir/:target1,target2.

- mma: Builds all of the modules in the current directory, and their dependencies.

- mmma: Builds all of the modules in the supplied directories, and their dependencies.

- provision: Flash device with all required partitions. Options will be passed on to fastboot.

- cgrep: Greps on all local C/C++ files.

- ggrep: Greps on all local Gradle files.

- jgrep: Greps on all local Java files.

- resgrep: Greps on all local res/*.xml files.

- mangrep: Greps on all local AndroidManifest.xml files.

- mgrep: Greps on all local Makefiles files.

- sepgrep: Greps on all local sepolicy files.

- sgrep: Greps on all local source files.

- godir: Go to the directory containing a file.

- allmod: List all modules.

- gomod: Go to the directory containing a module.

- pathmod: Get the directory containing a module.

- refreshmod: Refresh list of modules for allmod/gomod.

Environment options:

- SANITIZE_HOST: Set to 'true' to use ASAN for all host modules. Note that

ASAN_OPTIONS=detect_leaks=0 will be set by default until the

build is leak-check clean.

- ANDROID_QUIET_BUILD: set to 'true' to display only the essential messages.

lunch 2

PLATFORM_VERSION_CODENAME=REL

PLATFORM_VERSION=10

TARGET_PRODUCT=aosp_arm64

TARGET_BUILD_VARIANT=eng

TARGET_BUILD_TYPE=release

TARGET_ARCH=arm64

TARGET_ARCH_VARIANT=armv8-a

TARGET_CPU_VARIANT=generic

TARGET_2ND_ARCH=arm

TARGET_2ND_ARCH_VARIANT=armv8-a

TARGET_2ND_CPU_VARIANT=generic

HOST_ARCH=x86_64

HOST_2ND_ARCH=x86

HOST_OS=linux

HOST_OS_EXTRA=Linux-4.15.0-137-generic-x86_64-Ubuntu-16.04.7-LTS

HOST_CROSS_OS=windows

HOST_CROSS_ARCH=x86

HOST_CROSS_2ND_ARCH=x86_64

HOST_BUILD_TYPE=release

BUILD_ID=QD4A.200805.003

OUT_DIR=out

4-make 说明

通过soong执行编译构建,这里执行make命令时,main.mk文件把一些环境变量和目标都配置好后,会执行envsetup.sh中的make()进行编译。

function make()

{

_wrap_build $(get_make_command "$@") "$@"

}

function get_make_command()

{

# If we're in the top of an Android tree, use soong_ui.bash instead of make

if [ -f build/soong/soong_ui.bash ]; then

# Always use the real make if -C is passed in

for arg in "$@"; do

if [[ $arg == -C* ]]; then

echo command make

return

fi

done

echo build/soong/soong_ui.bash --make-mode

else

echo command make

fi

}

build/soong/soong_ui.bash --make-mode

------->

[build/soong/soong_ui.bash] -------》 下面说明

# Save the current PWD for use in soong_ui

export ORIGINAL_PWD=${PWD}

export TOP=$(gettop)

source ${TOP}/build/soong/scripts/microfactory.bash

soong_build_go soong_ui android/soong/cmd/soong_ui -->生成soog_ui

cd ${TOP} --->return root

exec "$(getoutdir)/soong_ui" "$@"------>exec out/soong_ui --make-mode build

“echo build/soong/soong_ui.bash --make-mode ”

soong的编译过程:

soong_ui.bash 调用流程:

可以看到include 了main.mk文件,从main.mk开始,将通过include命令将其所有需要的.mk文件包含进来,最终在内存中形成一个包括所有编译脚本的集合,这个相当于一个巨大Makefile文件。Makefile文件看上去很庞大,其实主要由三种内容构成: 变量定义、函数定义和目标依赖规则,此外mk文件之间的包含也很重要。

文件

作用

build/make/core/main.mk

Build的主控文件,主要作用是包含其他mk,以及定义几个最重要的编译目标,同时检查编译工具的版本,例如如gcc、clang、java等

build/make/core/config.mk

Build的配置文件,主要是区分各个产品的配置,并将这些编译器参数引入产品配置 BoardConfig.mk,同时也配置了一些编译器的路径等

build/make/core/definitions.mk

最重要的 Make 文件之一,在其中定义了大量的函数。这些函数都是 Build 系统的其他文件将用到的。例如:my-dir,all-subdir-makefiles,find-subdir-files,sign-package 等,关于这些函数的说明请参见每个函数的代码注释。

build/make/core/dex_preopt.mk

定义了dex优化相关的路径和参数

5.工具链的关系

Android.bp --> Blueprint --> Soong --> Ninja

Makefile or Android.mk --> kati --> Ninja

(Android.mk --> Soong --> Blueprint --> Android.bp)

android make 编译器,Android make 基础相关推荐

  1. Android NDK开发之 NEON基础介绍

    原文:http://blog.csdn.net/app_12062011/article/details/50434259 Android NDK开发之 NEON基础介绍 这是官方介绍: http:/ ...

  2. android.mk 比较字变量,Android.mk的用法和基础

    一个Android.mk file用来向编译系统描述你的源代码.具体来说:该文件是GNU Makefile的一小部分,会被编译系统解析一次或多次.你可以在每一个Android.mk file中定义一个 ...

  3. Android 系统(182)---Android.mk的用法和基础 amp;amp; m、mm、mmm编译命令

    Android.mk的用法和基础 && m.mm.mmm编译命令 一个Android.mk file用来向编译系统描述你的源代码.具体来说:该文件是GNU Makefile的一小部分, ...

  4. Android 系统(47)Android.mk的用法和基础

    Android.mk的用法和基础 && m.mm.mmm编译命令 一个Android.mk file用来向编译系统描述你的源代码.具体来说:该文件是GNU Makefile的一小部分, ...

  5. 【Android 应用开发】 ActionBar 基础

    作者 : 万境绝尘 (octopus_truth@163.com) 转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/3920439 ...

  6. 003 Android之线性布局与基础控件

    文章目录 Android快速入门三步 布局介绍 LinearLayout布局属性 代码示例 基础控件 TextView和EditText 使用TextView与EditText ImageView I ...

  7. java调用android打包_Android Gradle打包基础

    Android gradle打包基础 gradle目录 [代码]java代码:12345MyApp├── build.gradle ( 可以查看Gradle的版本 )├── settings.grad ...

  8. Android线程和线程Handler基础一览

    线程概览 线程是任何多任务系统的基石.可以被认为是一个主进程的多个子进程.这样做的目的就是了增加应用的性能. 应用主线程 当一个Android应用被打开的时候,系统会默认开辟一个线程.这个线程就被叫做 ...

  9. Android 音视频开发之基础篇 使用 SurfaceView绘制一张图片

    Android 音视频开发 上一篇文章:使用 imageview绘制一张图片 任务一 SurfaceView绘制一张图片 文章目录 Android 音视频开发 前言 一.surfaceview是什么? ...

最新文章

  1. IBM强化Watson对商业语言的理解能力—AI辩论一些关键技术首次商业化
  2. 戳破微服务的七大谎言
  3. c语言中如何将select出来的字段值赋给一个变量,sql server 重命名列(字段)
  4. Where does the setting xx-bindingSuntax - complex take effect
  5. Docker最全教程之使用.NET Core推送钉钉消息(二十)
  6. Oracle mysql 语句_Oracle 数据库常用操作语句大全
  7. 【ShaderToy】跳动的心
  8. 微软“杀”不死的数据库软件
  9. Qt程序启动画面QSplashScreen类
  10. [转载] python iter( )函数
  11. c语言回调函数_【云里雾里】回调函数与钩子函数
  12. struts2远程命令执行漏洞S2-045
  13. 论文阅读笔记——Adversarial Attack on Attackers Post-Process to
  14. 如何在不知道密码的情况下卸载趋势防毒墙网络版
  15. 算法图解:像小说一样有趣的算法入门书
  16. 关于javaFx 操作串口 报错的问题~
  17. AIOps对监控报警架构的挑战
  18. (HTML)浏览器将多个空格压缩为一个空格
  19. 服务器上文件不能重命名,服务器文件重命名
  20. Linux中vsftpd服务配置(匿名,用户,虚拟用户)

热门文章

  1. 微课|中学生可以这样学Python(8.4节):递归算法例题讲解2
  2. bool查询原理 es_es6.2.4,使用bool查询查出的结果,SearchResponse的Hits[]总是比t..._慕课猿问...
  3. php-fpm进程的用户组,PHP中的“进程”系列1——PHP-FPM模型
  4. 典范杜希奇与机器人_典范英语7_16 杜希奇与机器人.ppt
  5. 力扣977,有序数组的平方(JavaScript)
  6. 顶级数据团队建设全景报告_如何拥有一支顶级数据智能团队?联想总结了这些由内而外的经验...
  7. python获取eth0_详解 Python 获取网卡 IP 地址的黑魔法
  8. 开源框架_跨平台开源框架对比介绍
  9. Xmodem、Ymodem、Zmodem
  10. 数据库MySQL驱动5.1.22下载_mysql-connector-java-5.1.22下载