android开发笔记之android编译过程

news/2025/1/15 23:47:24/

第一:执行环境变量的sh脚本:

我们先执行:

. build/envsetup.shincluding device/generic/car/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-x86_64/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
including device/generic/uml/vendorsetup.sh
including device/qcom/common/vendorsetup.sh
including vendor/qcom/proprietary/common/vendorsetup.sh
including sdk/bash_completion/adb.bash

打印出来的信息是执行最后的此代码来实现的.

# Execute the contents of any vendorsetup.sh files we can find.
for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \`test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \`test -d product && find -L product -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort`
doecho "including $f". $f
done
unset f

我们查看一下vi device/qcom/common/vendorsetup.sh文件:

 30 add_lunch_combo msm8974-userdebug31 add_lunch_combo msm8610-userdebug
................................................................57 add_lunch_combo sdm710-userdebug58 add_lunch_combo msmnile-userdebug59 add_lunch_combo qcs605-userdebug60 add_lunch_combo XXX-user61 add_lunch_combo XXX-userdebug62 add_lunch_combo XXX-eng

看到这个眼熟不,这就是我们添加自定义项目时添加的内容.

我们再看看第一个方法hmm,都是我们常用的命令说明:

function hmm() {
cat <<EOF
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- lunch:     lunch <product_name>-<build_variant>
- tapas:     tapas [<App1> <App2> ...] [arm|x86|mips|armv5|arm64|x86_64|mips64] [eng|userdebug|user]
- croot:     Changes directory to the top of the tree.
- 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.Environment options:
- SANITIZE_HOST: Set to 'true' to use ASAN for all host modules. Note thatASAN_OPTIONS=detect_leaks=0 will be set by default until thebuild is leak-check clean.Look at the source to view more functions. The complete list is:
EOFlocal T=$(gettop)local A=""local ifor i in `cat $T/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; doA="$A $i"doneecho $A
}

我们再查看lunch方法:

function lunch()
{local answerif [ "$1" ] ; thenanswer=$1elseprint_lunch_menuecho -n "Which would you like? [aosp_arm-eng] "read answerfilocal selection=if [ -z "$answer" ]thenselection=aosp_arm-engelif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")thenif [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]thenselection=${LUNCH_MENU_CHOICES[$(($answer-1))]}fielseselection=$answerfiexport TARGET_BUILD_APPS=local product variant_and_version variant versionproduct=${selection%%-*} # Trim everything after first dashvariant_and_version=${selection#*-} # Trim everything up to first dashif [ "$variant_and_version" != "$selection" ]; thenvariant=${variant_and_version%%-*}if [ "$variant" != "$variant_and_version" ]; thenversion=${variant_and_version#*-}fifiif [ -z "$product" ]thenechoecho "Invalid lunch combo: $selection"return 1fiTARGET_PRODUCT=$product \TARGET_BUILD_VARIANT=$variant \TARGET_PLATFORM_VERSION=$version \build_build_var_cacheif [ $? -ne 0 ]thenreturn 1fiexport TARGET_PRODUCT=$(get_build_var TARGET_PRODUCT)export TARGET_BUILD_VARIANT=$(get_build_var TARGET_BUILD_VARIANT)if [ -n "$version" ]; thenexport TARGET_PLATFORM_VERSION=$(get_build_var TARGET_PLATFORM_VERSION)elseunset TARGET_PLATFORM_VERSIONfiexport TARGET_BUILD_TYPE=releaseechoset_stuff_for_environmentprintconfigdestroy_build_var_cache
}

第二:执行编译项目

lunch  project_name-userdebug============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=8.1.0
TARGET_PRODUCT=XXX
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_PLATFORM_VERSION=OPM1
TARGET_BUILD_APPS=
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=kryo300
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv7-a-neon
TARGET_2ND_CPU_VARIANT=cortex-a9
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.16.0-30-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=OPM1.171019.026
OUT_DIR=out
AUX_OS_VARIANT_LIST=
============================================

在这,我们可以看到许多定义的环境变量值,如:

PLATFORM_VERSION=8.1.0
TARGET_PRODUCT=XXX
TARGET_BUILD_VARIANT=userdebug

我们要查看这些变量值,直接执行如下命令:

echo $TARGET_BUILD_VARIANT
userdebug

下面是这些常用的变量值:

echo $ANDROID_PRODUCT_OUT
/hde/hexm/XXX_codes_20180626/LINUX/android/out/target/product/XXX
echo $ANDROID_BUILD_TOP
/hde/hexm/XXX_codes_20180626/LINUX/android
echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64
echo $QCPATH
vendor/qcom/proprietary

第三步:make

当我们执行make时,会查找当前的Makefie文件或者makefile文件并且执行,在android顶级源码目录下面,确实有个Makefile,它之后一行内容:

### DO NOT EDIT THIS FILE ###
include build/core/main.mk
### DO NOT EDIT THIS FILE ###

因此,执行的是build/core/main.mk文件.

参考资料:

(1)android编译系统分析一:source build/envsetup.sh与lunch
https://blog.csdn.net/u011913612/article/details/51878356

(2)Android编译系统分析三:make完整编译android系统
https://blog.csdn.net/u011913612/article/details/52434411


http://www.ppmy.cn/news/326114.html

相关文章

微软Windows操作系统全面兼容机器人操作系统ROS1和ROS2

微软Windows操作系统全面兼容机器人操作系统ROS1和ROS2 turtlebot2&#xff1a;https://github.com/bfjelds/turtlebot2-win10 文档&#xff1a;https://libraries.io/github/bfjelds/turtlebot2-win10 安装在/opt/ros/melodic/x64文件夹下&#xff0c;依据如下教程即可安装成…

2018年智能机器人技术综合实训专题一系统基础

2018年智能机器人技术综合实训专题一系统基础 此部分对应教材&#xff1a;《ROS机器人项目开发11例》&#xff0c;采用翻转课堂模式&#xff0c;并未按书中章节顺序授课。 请自学第一章&#xff0c;入门ROS机器人应用程序开发&#xff1b;第四章&#xff0c;使用ROS控制嵌入式…

南京观海微电子GH1001 datasheet及应用介绍

datasheethttps://pan.baidu.com/s/1I3GXWsrgPGuTe46UpMlLsw?pwd1234 GH1001支持HD 768分辨率驱动IC。 GH1001 设计可驱动 α-Si、LTPS&IGZO TFT 点阵 LCD&#xff0c;最高可支持分辨率&#xff1a;768RGBx2046 。 Single chip solution for a WXGA α-Si type LCD disp…

【汇总】OpenHarmony轻量系统开发【0】目录和个人感悟

前言 还记得2020年9月OpenHarmony大会后&#xff0c;我开始在社区写了一些OpenHarmony轻量系统开发的文章&#xff0c;基于Hi3861。 转眼已经过去那么久了。 OpenHarmony从过去的1.0版本&#xff0c;演变到了现在的3.1版本。 于是决定重新开启篇章&#xff0c;针对3.0以上的版…

OpenHarmony一次开发,多端部署

作者:坚果 团队:坚果派 公众号:“大前端之旅” 润开鸿技术专家,华为HDE,InfoQ签约作者,OpenHarmony布道师,擅长HarmonyOS应用开发、熟悉服务卡片开发,在“战码先锋”活动中作为大队长,累计培养三个小队长,带领100+队员完成Pr的提交合入。 欢迎通过主页或者私信联系我…

Hacker Disassembler Engine (HDE) version 0.07

引用: Hacker Disassembler Engine (HDE) version 0.07 - 09.02.2007 - fixed bug with F6 and F7 opcodes - added support of FPU commands - optimized and small code - corrected documentation 引用: http://www.patkov-site.narod.ru/download/hde.zip

KDE桌面环境下电源管理对应的文件及选项

在KDE桌面环境下&#xff0c;“系统设置”—>“电源管理”—>“高级电源设置”的界面如下&#xff1a; 点击界面中的“配置通知”选项&#xff0c;界面如下所示&#xff1a; 其中图形界面下的各项设置对应的文件为~/.config/powerdevil.notifyrc。上图状态下&#xff0c…

最新OpenHarmony系统一二级目录整理

最新OpenHarmony系统一二级目录整理 坚果:润开鸿技术专家&#xff0c;华为HDE&#xff0c;InfoQ签约作者&#xff0c;OpenHarmony布道师&#xff0c;擅长HarmonyOS应用开发、跨平台Flutter开发、熟悉服务卡片开发、小程序开发、GO的相关开发。开源项目gin-vue-admin成员之一&am…