聲明:本文來自我的導師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>