这一章我们来学习如何编译user 版本的系统。(这里以Android9.0,手机设备Piexl一代为例 )在编译Android系统源码的时候会有三种编译版本的选项,分别是:user、userdebug、eng ,它们之间的区别如下表。
构建类型 | 使用情况 |
---|
user | 权限受限;适用于生产环境 | userdebug | 与“user”类似,但具有 root 权限和调试功能;是进行调试时的首选编译类型 | eng | 具有额外调试工具的开发配置 |
一、环境准备
(1) Android系统源码编译环境 (2) 开发环境(SubLime Text3)
二、概述
在编译系统源码过程种,我们会使用到lunch 命令,这个命令会列出所有的编译选项,而我们发现提供的编译选项中没有user 版本,那么如何让lunch 命令列出user 版本,就成了我们第一个要解决的问题。
jhan@ubuntu:~/aosp$ lunch
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_car_arm-userdebug
8. aosp_car_arm64-userdebug
9. aosp_car_x86-userdebug
10. aosp_car_x86_64-userdebug
11. mini_emulator_arm64-userdebug
.........
.........
45. aosp_marlin-userdebug
46. aosp_marlin_svelte-userdebug
47. aosp_sailfish-userdebug
48. aosp_walleye-userdebug
49. aosp_walleye_test-userdebug
50. aosp_taimen-userdebug
51. hikey-userdebug
52. hikey64_only-userdebug
53. hikey960-userdebug
我们在使用lunch 命令之前,需要执行source build/envsetup.sh 命令,命令执行之后会输出一些sh文件(这些文件中包含了需要编译的版本),其实这些文件就是我们修改的点,在里面的任意文件中手动添加user 版本就行了。
jhan@ubuntu:~/aosp$ 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-mips64/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/generic/uml/vendorsetup.sh
including device/google/bonito/vendorsetup.sh
including device/google/crosshatch/vendorsetup.sh
including device/google/cuttlefish/vendorsetup.sh
including device/google/marlin/vendorsetup.sh
including device/google/muskie/vendorsetup.sh
including device/google/taimen/vendorsetup.sh
including device/linaro/hikey/vendorsetup.sh
including sdk/bash_completion/adb.bash
三、添加User版本
这里我需要编译的目标版本是aosp_sailfish-user ,那么在编译的选项中是没有这一项的,根据lunch 命令列出的文件,随意找一个文件进行修改,我们以device/google/marlin/vendorsetup.sh 文件为例,进行修改。
jhan@ubuntu:~/aosp$ vim device/google/marlin/vendorsetup.sh
add_lunch_combo aosp_marlin-userdebug
add_lunch_combo aosp_marlin_svelte-userdebug
add_lunch_combo aosp_sailfish-userdebug
add_lunch_combo aosp_sailfish-user
四、编译
最后进行编译,执行lunch 命令后可以发现列出了新的编译选项(48. aosp_sailfish-user )
jhan@ubuntu:~/aosp$ source build/envsetup.sh
jhan@ubuntu:~/aosp$ source lunch
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
.........
.........
45. aosp_marlin-userdebug
46. aosp_marlin_svelte-userdebug
47. aosp_sailfish-userdebug
48. aosp_sailfish-user
49. aosp_walleye-userdebug
50. aosp_walleye_test-userdebug
51. aosp_taimen-userdebug
jhan@ubuntu:~/aosp$ lunch 48
jhan@ubuntu:~/aosp$ make -j32
asjhan for Android reverse
|