欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

入职小白随笔之高通项目编译流程

程序员文章站 2022-10-25 18:10:19
声明:本文来自我的导师wangjie. 本文主要包含以下内容 一、查看项目所在分支二、切换到目标分支三、查看当前所在分支四、编译Android源码五、source Android 编译环境六、lunch 所需的编译项目七、单编 模块八、push 模块 验证修改是否生效 一、查看项目所在分支 git ......

声明:本文来自我的导师wangjie.

 

 

本文主要包含以下内容

一、查看项目所在分支
二、切换到目标分支
三、查看当前所在分支
四、编译android源码
五、source android 编译环境
六、lunch 所需的编译项目
七、单编 模块
八、push 模块 验证修改是否生效

一、查看项目所在分支

git branch -a
表示:查看并列出当前项目所有分支

高通项目举例如下:

wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ git branch -a
* linux_android_development
  master
  remotes/origin/a/b_update_linux_android_development
  remotes/origin/head -> origin/master
  ... ...
  remotes/origin/secure_linux_android_development
  remotes/origin/streamlined_code_engineering
wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ 

二、切换到目标分支

git checkout 分支名
表示: 切换到某个分支。

高通项目举例如下:
git checkout linux_android_development

wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ git branch -a
* linux_android_development
  master
  remotes/origin/a/b_update_linux_android_development
  remotes/origin/head -> origin/master
  remotes/origin/cts_development_branch
  ... ...
wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ git checkout linux_android_development 

三、查看当前所在分支

git branch
表示:查看当前所在分支

高通项目举例如下:

wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ git branch 
* linux_android_development
  master
wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ 

四、编译android源码

android 源码编译,每个项目由于脚本各不相同,编译的命令 有时候也会有说差异。

google 官方编译命令如下

1.source ./build/envsetup.sh
2.lunch 项目
3.make -j8

高通项目编译命令 如下:

./buildall_userdebug.sh e5527m all

五、source android 编译环境

首先进入android 源码根目录,执行source ./build/envsetup.sh,
如不source,后续则无法单编模块。

高通项目举例如下:

wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ source ./build/envsetup.sh 
including 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/google/muskie/vendorsetup.sh
including device/google/taimen/vendorsetup.sh
including device/qcom/common/vendorsetup.sh
including device/qcom/qssi/vendorsetup.sh
including vendor/partner_gms/products/vendorsetup.sh
including vendor/qcom/opensource/core-utils/vendorsetup.sh
including vendor/qcom/proprietary/common/vendorsetup.sh
including vendor/qcom/proprietary/prebuilt_hy11/vendorsetup.sh
created 9 symlinks out of 9 mapped links..
including sdk/bash_completion/adb.bash
wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ 

六、lunch 所需的编译项目

执行 lunch 命令,查看所有 编译项目列表,然后选择 编译项目。
高通项目 举例如下:

1. lunch ,然后选择所需编译分支
wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ lunch
you're building on linux
lunch menu... pick a combo:
     1. aosp_arm-eng
     2. aosp_arm64-eng
     3. aosp_mips-eng
     ... ...
     40. msm8937_64-userdebug
     41. msm8937_64-user
     ... ...
     65. taimenb2-userdebug
// 选择要编译的分支名
which would you like? [aosp_arm-eng] msm8937_64-userdebug
device/qcom/msm8937_64/msm8937_64.mk:42: warning: "build with 4.9 kernel"
 ... ...
out_dir=out
============================================
wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ 
2. 直接lunch 分支

比如我们需要编译msm8937_64-userdebug项目,其实我们可以执行最简单的方法,直接lunch这个项目所排列的位置,比如lunch 40

wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ lunch 40
device/qcom/msm8937_64/msm8937_64.mk:42: warning: "build with 4.9 kernel"
============================================
platform_version_codename=rel
platform_version=9
target_product=msm8937_64
... ...
host_cross_2nd_arch=x86_64
host_build_type=release
build_id=pkq1.190601.001
out_dir=out
============================================
wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ 

七、单编 模块

我们常用 mmm 以及mm 来及对单模块进行编译。
mmm 与mm 主要区别在于你当前所在的目录位置。
如果当前正在所要编译模块的地方(需要有android.mk文件,才可以进行),请使用 mm,否则使用mmm

高通项目举例如下:

1. mmm使用举例(此时不在fm 目录)

比如单编fm,不在fm目录下,需要执行mmm vendor/qcom/opensource/commonsys/fm/fmapp2/

wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ mmm vendor/qcom/opensource/commonsys/fm/fmapp2/
/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android/vendor/qcom/opensource/commonsys/fm/fmapp2/
restriction checker not present, skipping..
device/qcom/msm8937_64/msm8937_64.mk:42: warning: "build with 4.9 kernel"
============================================
... ...
out_dir=out
============================================
qssi: not enabled for msm8937_64 target as vendor/qcom/proprietary/release/qssi/qssi_enforced_targets_list.txt was not found.
... ...
#### build completed successfully (7 seconds) ####
wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ 
2. mm使用举例(在fm 目录下)

比如单编fm,在fm目录下,需要执行mm

wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android$ cd  vendor/qcom/opensource/commonsys/fm/fmapp2/
wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android/vendor/qcom/opensource/commonsys/fm/fmapp2$ mm
restriction checker not present, skipping..
device/qcom/msm8937_64/msm8937_64.mk:42: warning: "build with 4.9 kernel"
============================================
platform_version_codename=rel
platform_version=9
... ...
out_dir=out
============================================
qssi: not enabled for msm8937_64 target as vendor/qcom/proprietary/release/qssi/qssi_enforced_targets_list.txt was not found.
ninja: no work to do.
... ...
build/make/core/base_rules.mk:412: warning: ignoring old commands for target `out/target/product/msm8937_64/vendor/lib64/hw/fingerprint.default.so'
ninja: no work to do.
#### build completed successfully (41 seconds) ####
wangjie@wangjie:/wangjie/qualcomm_p/e5527m_msm8917_qm215_r26/la.um.7.6.2/linux/android/vendor/qcom/opensource/commonsys/fm/fmapp2$ 

八、 push 模块 验证修改是否生效

1. 使用debug版本,挂载手机

adb shell getprop ro.build.type 主要用来查看当前使用的版本,调试只能使用debug 版本,user版本无法调试。

高通项目举例如下:

c:\users\administrator>adb shell getprop ro.build.type
userdebug
c:\users\administrator>adb root
c:\users\administrator>adb remount
remount succeeded
c:\users\administrator>
2.将生成的单模块编译的apk 拷贝到桌面并push到手机中

adb push 本地文件 手机目录
adb push主要用来 替换手机中的apk,调试验证单编是否生效。

高通 fm 举例如下:

c:\users\administrator>adb push c:\users\administrator\desktop\fm2.apk /system/app/fm2
c:\users\administrator\desktop\fm2.apk: 1 file pushed. 9.7 mb/s (861880 bytes in 0.085s)
c:\users\administrator>
3. 清除 push apk 的存储数据

adb shell pm clear 包名
用来清除当前包名的数据。
比如:adb shell pm clear com.caf.fmradio

高通 fm apk举例如下:

c:\users\administrator>adb shell dumpsys activity | findstr run
    running activities (most recent first):
        run #0: activityrecord{3bc8d7d u0 com.caf.fmradio/.fmradio t52}
    running activities (most recent first):
        run #0: activityrecord{89df584 u0 com.android.launcher3/com.android.searchlauncher.searchlauncher t51}
c:\users\administrator>adb shell pm clear com.caf.fmradio
success
c:\users\administrator>