小白编译android rom小记

前言:
我虽然是做android framework开发,但平时都是编译模块,要让我添加一个机型编译我还真不熟悉,前段时间花了点时间成功编了griffin,这里记录一下。

正文:
一般来说如果一个机型做好了编译适配并添加到了官方编译列表里面(类似CM,MK等),我们下载了源码,source lunch编译就好了。
今天要说的如何编译一个还没有添加到官方编译列表的机型。

下载源码

首先下载源码这个是必须的。

其次要有机型设备对应的device,kernel,vendor源码,能自己写这些代码的我相信你也用不着看这个文章。
像我这种小白就只有去github上找对应的代码去了。

两种方法下载设备树代码,1.手动git clone,甚至你直接Download Zip也行,2.添加到 local_manifests repo sync 同步。推荐第二种。

  1. 下载代码后放到响应的目录,比如我要编译的griffin(Moto z 2016),在github上对应的仓库为MotoZ-2016/android_device_motorola_griffin,那我就把代码放到device/motorola/griffin,其他kernel和vendor的代码也是同理。
    如果是需要做机型移植,devices目录下,编译相关的内容记得都要改了。
    除去上面三个”必选”仓库以外,有些硬件可能还需要特殊的仓库,比如nfc之类的,这类依赖一般被写在device/griffin目录下的mk.dependencies文件里
    {
      "repository": "android_external_v4l2_hal",
      "target_path": "external/v4l2_hal"
    },

android_external_v4l2_hal这写仓库也可以到github上搜搜看。
2. 添加代码库的地址到.repo/local_manifests/roomservice.xml。直接给个例子吧

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
       <remote  name="github_boul" 
                fetch="https://github.com/"             
                revision="refs/heads/cm-14.1" />
       <project name="boulzordev/android_device_motorola_griffin" path="device/motorola/griffin"    remote="github_boul" />
       <project name="boulzordev/proprietary_vendor_motorola_griffin" path="vendor/motorola/griffin"    remote="github_boul" />
       <project name="boulzordev/android_kernel_motorola_msm8996" path="kernel/motorola/msm8996"    remote="github_boul" />
       <project name="LineageOS/android_external_bson" path="external/bson" remote="github" />
       <project name="LineageOS/android_external_stlport" path="external/stlport" remote="github" />
       ...
</manifest>

好了,这样就可以用repo sync 来同步了。
本来那个remote name=”github_boul” 是不必要的,不过当你.repo/manifest.xml中default的remote代表的不是你添加的设备的代码所在的网站的时候,就需要像上面那样新建一个remote,并且fetch = 代码所在的网站(这个网站不一定是github)。
像LineageOS本身代码是在github上,而且我们新增的代码也是github上,所以我们完全可以把新建的这个remote删掉,把下面的remote=”github_boul”改成remote=”github”。
看不懂的话去网上找一下local_manifest的编写规则吧,以前CM的wiki上有,现在LineageOS的wiki上我没找到。

添加机型设备到lunch列表(非必要)

好了现在我们有代码了,但是我们在lunch的时候还没有griffin的机型可以选择啊。
有两种方法把griffin添加到本地lunch列表。因为我编的Mokee,所以以下以mk为例
1.在device/motorola/griffin目录下新建vendorsetup.sh,添加内容:

 add_lunch_combo mk_griffin-userdebug

2.修改vendor/mk/vendorsetup.sh添加和上面同样的内容

for combo in $(curl -s https://raw.githubusercontent.com/MoKee/*后面地址省略*/
do
    add_lunch_combo $combo
    add_lunch_combo mk_griffin-userdebug
done

之后再

$ source build/envsetup.sh
$ lunch 

就可以看到新添加的机型了。
但是我开始为什么说非必要呢?
因为我们完全可以敲lunch mk_griffin-userdebug来lunch。。。你是LineageOS就敲lunch lineage_griffin-userdebug。

初始化编译

对于Mokee来说

$ source build/envsetup.sh
$ lunch mk_griffin-userdebug
$ mka bacon

对于LineageOS

$ source build/envsetup.sh
$ breakfast griffin
$ brunch griffin
  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值