标签 aosp 下的文章

pre

sudo apt-get install -y openjdk-8-jdk
sudo apt-get install -y git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip

download

git

sudo apt install git
git config --global user.name "xyz"
git config --global user.email "xyz@gmail.com"

ethstatus

sudo apt install -y ethstatus net-tools

use ifconfig to get your net name, may be it looks like wlp4s0, then use ethstatus -i wlp4s0 to get net status.

repo

mkdir ~/bin
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo
chmod +x ~/bin/repo
mkdir -p ~/source/android-10
vim ~/repo_sync.sh

#!/bin/bash

export PATH=$PATH:~/bin 
export REPO_URL="https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/"

cd ~/source/android-10
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-10.0.0_r8
repo sync

compile

vim build_aosp.sh
#!/bin/bash

cd source/android-10/
source build/envsetup.sh
lunch aosp_x86_64-eng

#make system-api-stubs-docs-update-current-api

if error with 1 or 137, the ram may be less than needed, you should increase swap size or ram size.

emulator

vim emulator.sh

#!/bin/bash

cd source/android-10/

source build/envsetup.sh
lunch aosp_x86_64-eng

#sudo emulator
emulator

if error is "Please ensure KVM is properly installed and usable." you need:

  1. sudo apt install -y qemu-kvm cpu-checker
  2. use kvm-ok to check the kvm has already?
  3. use usermod -a -G kvm xyz to add user: xyz in kvm group.
  4. user echo 'KERNEL=="kvm",GROUP="kvm",MODE="0660"' >> /etc/udev/rules.d/androidUseKVM.rules to add kvm rules.
  5. reboot or relogin

if still has the error like "grant current user access to /dev/kvm", "/dev/kvm devices: permission denies", then sudo chown xyz -R /dev/kvm

reference:

Ubuntu 18.04 emulator运行Android源码编译的 X86 虚拟机image
https://blog.csdn.net/csusunxgg/article/details/81060890
Ubentu编译Android源码(AOSP)
https://www.cnblogs.com/caoxinyu/p/10568480.html

转自: https://blog.csdn.net/u011913612/article/details/52503318

Android编译系统分析系列文章: android编译系统分析(一)-source build/envsetup.sh与lunch Android编译系统(二)-mm编译单个模块 android编译系统分析(三)-make android编译系统(四)-实战:新增一个产品 Android编译系统分析(五)-system.img的生成过程

我们在完整编译android系统的时候,最终会生成几个重要的镜像文件,其中有system.img,userdata.img,ramdisk.img等。这篇文章的目的是分析system.img的生成过程。 回想下我们完整编译android系统时的动作,我们会在android源码顶级目录执行make命令,这样就会完整的编译android系统,我们没有传入任何参数(-jx等加快编译的除外),因为我们没有明确指定make的目标,所以android编译系统会执行默认的编译目标,也就是droid。因此,我们还是从droid着手,看看system.img怎么生成。

- 阅读剩余部分 -

转自: https://blog.csdn.net/u011913612/article/details/52434445

Android编译系统分析系列文章:

android编译系统分析一<source build/envsetup.sh与lunch> Android编译系统<二>-mm编译单个模块 android编译系统分析(三)-make android编译系统(四)-实战:新增一个产品 Android编译系统分析(五)-system.img的生成过程

通过上一节“android编译系统(三)-make”的分析,初步理清楚了编译初期加载产品相关信息的流程,整个过程主要涉及三个文件:1.AndroidProducts.mk,2.具体产品的配置文件,3.BoardConfig.mk,加上lunch需要的vendorsetup.sh文件,总共只需要四个文件就可以了,所以我们不妨成热打铁,赶紧尝试下如何新增一个产品。因此,android编译系统镜像文件的创建过程方到下一节。

- 阅读剩余部分 -

转自: https://blog.csdn.net/u011913612/article/details/52434411

Android编译系统分析系列文章:

android编译系统分析一<source build/envsetup.sh与lunch> Android编译系统<二>-mm编译单个模块 android编译系统分析(三)-make android编译系统(四)-实战:新增一个产品 Android编译系统分析(五)-system.img的生成过程

这篇博客的目标是摸清楚默认编译整个android系统时代码的流程。

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

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

因此,正真执行的是build/core/main.mk

- 阅读剩余部分 -

转自: https://blog.csdn.net/u011913612/article/details/52415948

Android编译系统分析系列文章:

android编译系统分析一<source build/envsetup.sh与lunch> Android编译系统<二>-mm编译单个模块 android编译系统分析(三)-make android编译系统(四)-实战:新增一个产品 Android编译系统分析(五)-system.img的生成过程

因为Android的编译系统不同于Linux Kernel的递归式的编译系统,它的编译系统是一种称之为independent的模式,每个模块基本独立(它有可能依赖其他模块),每个模块都可以单独编译,这是Android independent编译系统模式的好处。但这并不意味着它是完美的,普通电脑编译android系统需要8个小时甚至更多(以本人的电脑为例),而编译linux kernel只需要半个小时,代码量是一回事,由independent模式造成的编译时间长应该是可以肯定的。正因为每个模块可以单独编译,所以android系统的编译就是依次编译每个模块,然后把所有编译好的模块和其他一些文件一起打包成镜像文件。因此,只要理解了每个模块的编译,理解android系统的编译就轻松多了。(以上均是个人观点,欢迎拍砖)

- 阅读剩余部分 -

出现这个报错,是因为子文件夹下面也有 .git,有两种方法解决:

  • 直接删除子文件夹的 .git,如果使用 find . -name ".git" 发现要删除的比较少,就手动删除,如果要删除的比较多,就使用 find . -name ".git" | xargs rm -Rf 批量删除。
  • 把子文件夹作为模块来进行管理,这个比较麻烦,如果是大型多人合作工程,可以考虑使用 repo 这样专门的管理模式。如果是小团队,就不如第一种加上复制粘贴来的快捷。

参考

fatal: 'git status --porcelain'
https://blog.csdn.net/qq_40028324/article/details/82770466
删除文件夹下所有的.git文件
https://blog.csdn.net/wuyanyanstrong/article/details/52766293
git submodule 的使用
https://www.jianshu.com/p/e27a978ddb88
https://blog.justwe.site/post/git-submodule/

本文是参考 http://www.ramlife.org/2021/09/08/407.html 在 android 10 源码上面对 envsetup.sh 进行初步分析。

envsetup.sh

envsetup.sh 链接位置在 build/envsetup.sh,真实位置是 build/make/envsetup.sh。 在脚本中,能够看到有很多函数,最下面直接调用的只有三个函数:

validate_current_shell
source_vendorsetup
addcompletions

validate_current_shell

validate_current_shell 中功能很简单,函数名称也能够看出来,检测当前的 shell 是哪种,通过 local current_sh="$(ps -o command -p $$)" 获取当前的 bash 程序,我使用的是 bash,所以这个变量获取到的是 COMMAND -bash , 所以执行 function check_type() { type -t "$1"; }.

type 命令属于 bash 内建命令,-t选项显示参数指定类型信息。会打印字符串:alias, keyword, function, builtin, or file

# type -t gcc
file
#type -t cd
builtin
 #type -t ll
alias

# type -t if
keyword
#type -t print

参考: bash内建命令type简介
https://blog.csdn.net/hanzhen1135/article/details/48340097

source_vendorsetup

看函数名称,应该是执行厂商的配置。

    allowed=
    for f in $(find -L device vendor product -maxdepth 4 -name 'allowed-vendorsetup_sh-files' 2>/dev/null | sort); do
        if [ -n "$allowed" ]; then
            echo "More than one 'allowed_vendorsetup_sh-files' file found, not including any vendorsetup.sh files:"
            echo "  $allowed"
            echo "  $f"
            return
        fi
        allowed="$f"
    done

上面在 device, vendor, product 三个文件夹中,向下找 4层路径,找名字是 'allowed-vendorsetup_sh-files' 的文件, -L 表示是链接的时候,去源文件那边去找,而不是链接本身。我们实际运行的时候,allowed 为空。

参考: Linux基础:文件查找find命令详细讲解
http://www.manongjc.com/article/19084.html

    allowed_files=
    [ -n "$allowed" ] && allowed_files=$(cat "$allowed")
    for dir in device vendor product; do
        for f in $(test -d $dir && \
            find -L $dir -maxdepth 4 -name 'vendorsetup.sh' 2>/dev/null | sort); do

            if [[ -z "$allowed" || "$allowed_files" =~ $f ]]; then
                echo "including $f"; . "$f"
            else
                echo "ignoring $f, not in $allowed"
            fi
        done
    done

上面这段代码是在 device, vendor, product 三个文件夹下面,找四层,找 'vendorsetup.sh',找到之后,先判断 allowed 是零,或者 allowed_files 符合 $f 这个正则的模型,然后就会 include进去,在运行 . $f 意思是再 source $f。 最终输出就是:

including vendor/qcom/opensource/core-utils/vendorsetup.sh
including vendor/qcom/proprietary/common/vendorsetup.sh
including vendor/qcom/proprietary/prebuilt_HY11/vendorsetup.sh
*****Could not create symlink*******
sdk/current/androidx-README.md::frameworks/support/README.md
vendor/qcom/opensource/core-utils/build.sh::build.sh
****************END******************
Created 85 symlinks out of 87 mapped links..
vendor/qcom/opensource/core-utils/vendorsetup.sh

这个脚本里面只有一句: export QTI_BUILDTOOLS_DIR=$(dirname ${BASH_SOURCE[0]}) BASH_SOURCE[0] 等价于 BASH_SOURCE ,取得当前执行的 shell 文件所在的路径及文件名。dirname 去除文件名中的非目录部分,仅显示与目录有关的部分。 所以这句的意思是 QTI_BUILDTOOLS_DIR 这个值就是 vendorsetup.sh 当前目录的值了。

参考: Shell中的BASH_SOURCE
https://blog.csdn.net/lizhiqiang1217/article/details/94737535

vendor/qcom/proprietary/common/vendorsetup.sh

这个脚本里面是:

export QCPATH="$(pwd)/vendor/qcom/proprietary"
export QCPATH_COMMONSYS="${QCPATH}/commonsys"
export SDCLANG_AE_CONFIG="${QCPATH}/common-noship/etc/sdclang.json"
export SDCLANG_CONFIG="${QCPATH}/common/config/sdclang.json"
export SDCLANG_CONFIG_AOSP="${QCPATH}/common/config/sdclang-pureAOSP.json"
if [ -f "${QCPATH}/qrsp/mpgen/mpgen.py" ]; then
export RTIC_MPGEN="python ${QCPATH}/qrsp/mpgen/mpgen.py"
fi

对这些变量进行赋值,并 export 出来。

vendor/qcom/proprietary/prebuilt_HY11/vendorsetup.sh

脚本内容:

links_dir="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))"
links_path="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))/links"
sys_links_path="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))/system_links"
ven_links_path="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))/vendor_links"
failed_links=""
count=0
if [[ -f "$links_path" || -f "$sys_links_path" || -f "$ven_links_path" ]];then
  total_links=$(cat $links_dir/*links| wc -l)
  for i in $(cat $links_dir/*links);do
    src=$(echo $i | awk -F:: '{print $1}')
    dest=$(echo $i | awk -F:: '{print $2}')
    if [ -e "$dest" ];then
      rm -rf $dest
    fi
    if [[ -e $src && ! -e $dest ]];then
      mkdir -p $(dirname $dest)
      ln -srf $src $dest
      count=$(($count + 1))
    else
      failed_links="$failed_links $i"
    fi
  done
  if [ ! -z "$failed_links" ];then
    echo "*****Could not create symlink*******"
    echo $failed_links | sed 's/[[:space:]]/\n/g'
    echo "****************END******************"
  fi
  echo "Created $count symlinks out of $total_links mapped links.."
fi

readlink 用于得出链接的真实路径,-e 是递归的读取. 就是为了获得真正的 vendorsetup.h 所在的文件夹。 cat $links_dir/*links | wc -l 指的是统计 links_dir文件夹下所有的 *links,看里面有多少个换行符,也就是有多少行。 然后就是简单的把源文件通过软连接链接到目的路径。ln -srf 意思是如果目的地有软连接就强制删除,并且这个软连接是相对位置的软连接,而不是绝对位置的软连接。

把这个文件中链接部分增加了打印信息,结果如下:

total links:  87
build/make/CleanSpec.mk::build/CleanSpec.mk
---> src:  build/make/CleanSpec.mk
<--- dest:  build/CleanSpec.mk
======
build/make/buildspec.mk.default::build/buildspec.mk.default
---> src:  build/make/buildspec.mk.default
<--- dest:  build/buildspec.mk.default
======
build/make/core::build/core
---> src:  build/make/core
<--- dest:  build/core
======
build/make/envsetup.sh::build/envsetup.sh
---> src:  build/make/envsetup.sh
<--- dest:  build/envsetup.sh
======
build/make/target::build/target
---> src:  build/make/target
<--- dest:  build/target
======
build/make/tools::build/tools
---> src:  build/make/tools
<--- dest:  build/tools
======
build/soong/root.bp::Android.bp
---> src:  build/soong/root.bp
<--- dest:  Android.bp
======
build/soong/bootstrap.bash::bootstrap.bash
---> src:  build/soong/bootstrap.bash
<--- dest:  bootstrap.bash
======
sdk/current/androidx-README.md::frameworks/support/README.md
---> src:  sdk/current/androidx-README.md
<--- dest:  frameworks/support/README.md
======
vendor/codeaurora/commonsys/packages/apps/SoundRecorder/app_qtiSoundRecorder_system_product.mk::vendor/qcom/defs/product-defs/system/app_qtiSoundRecorder_product.mk
---> src:  vendor/codeaurora/commonsys/packages/apps/SoundRecorder/app_qtiSoundRecorder_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/app_qtiSoundRecorder_product.mk
======
vendor/qcom/proprietary/qdssagent/qdssagent-ship-vendor-product.mk::vendor/qcom/defs/product-defs/legacy/qdssagent-ship-vendor-product.mk
---> src:  vendor/qcom/proprietary/qdssagent/qdssagent-ship-vendor-product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/qdssagent-ship-vendor-product.mk
======
device/qcom/common/generate_extra_images.mk::vendor/qcom/build/tasks/generate_extra_images.mk
---> src:  device/qcom/common/generate_extra_images.mk
<--- dest:  vendor/qcom/build/tasks/generate_extra_images.mk
======
device/qcom/common/stop_scan.mk::kernel/Android.mk
---> src:  device/qcom/common/stop_scan.mk
<--- dest:  kernel/Android.mk
======
device/qcom/common/stop_scan.mk::disregard/Android.mk
---> src:  device/qcom/common/stop_scan.mk
<--- dest:  disregard/Android.mk
======
vendor/codeaurora/commonsys/packages/apps/Mms/app_mms_system_product.mk::vendor/qcom/defs/product-defs/system/app_mms_product.mk
---> src:  vendor/codeaurora/commonsys/packages/apps/Mms/app_mms_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/app_mms_product.mk
======
vendor/codeaurora/commonsys/packages/apps/SnapdragonMusic/app_snapMusic_system_product.mk::vendor/qcom/defs/product-defs/system/app_snapMusic_product.mk
---> src:  vendor/codeaurora/commonsys/packages/apps/SnapdragonMusic/app_snapMusic_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/app_snapMusic_product.mk
======
vendor/qcom/proprietary/commonsys/qrdplus/sva/app_sva_system_product.mk::vendor/qcom/defs/product-defs/system/app_sva_product.mk
---> src:  vendor/qcom/proprietary/commonsys/qrdplus/sva/app_sva_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/app_sva_product.mk
======
vendor/qcom/proprietary/commonsys/qrdplus/Extension/app_extension_system_product.mk::vendor/qcom/defs/product-defs/system/app_extension_product.mk
---> src:  vendor/qcom/proprietary/commonsys/qrdplus/Extension/app_extension_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/app_extension_product.mk
======
hardware/qcom/gps/gps_vendor_product.mk::vendor/qcom/defs/product-defs/vendor/gps-product-hal.mk
---> src:  hardware/qcom/gps/gps_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/gps-product-hal.mk
======
hardware/qcom/gps/gps_vendor_board.mk::vendor/qcom/defs/board-defs/vendor/gps-board.mk
---> src:  hardware/qcom/gps/gps_vendor_board.mk
<--- dest:  vendor/qcom/defs/board-defs/vendor/gps-board.mk
======
vendor/qcom/opensource/location/gps_vendor_product.mk::vendor/qcom/defs/product-defs/vendor/gps-product-opensource.mk
---> src:  vendor/qcom/opensource/location/gps_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/gps-product-opensource.mk
======
vendor/qcom/opensource/data-ipa-cfg-mgr/ipacm_vendor_product.mk::vendor/qcom/defs/product-defs/vendor/ipacm_vendor_product.mk
---> src:  vendor/qcom/opensource/data-ipa-cfg-mgr/ipacm_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/ipacm_vendor_product.mk
======
vendor/qcom/proprietary/cne/shipcne_vendor_product.mk::vendor/qcom/defs/product-defs/legacy/shipcne_vendor_product.mk
---> src:  vendor/qcom/proprietary/cne/shipcne_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/shipcne_vendor_product.mk
======
vendor/qcom/proprietary/cne/cne_vendor_product_noship.mk::vendor/qcom/defs/product-defs/legacy/cne_vendor_product_noship.mk
---> src:  vendor/qcom/proprietary/cne/cne_vendor_product_noship.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/cne_vendor_product_noship.mk
======
vendor/qcom/proprietary/cne/cne_vendor_board_noship.mk::vendor/qcom/defs/board-defs/legacy/cne_vendor_board_noship.mk
---> src:  vendor/qcom/proprietary/cne/cne_vendor_board_noship.mk
<--- dest:  vendor/qcom/defs/board-defs/legacy/cne_vendor_board_noship.mk
======
vendor/qcom/proprietary/cne/cne_wqe_vendor_product_noship.mk::vendor/qcom/defs/product-defs/legacy/cne_wqe_vendor_product_noship.mk
---> src:  vendor/qcom/proprietary/cne/cne_wqe_vendor_product_noship.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/cne_wqe_vendor_product_noship.mk
======
vendor/qcom/proprietary/cne/cne-test_vendor_product.mk::vendor/qcom/defs/product-defs/legacy/cne-test_vendor_product.mk
---> src:  vendor/qcom/proprietary/cne/cne-test_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/cne-test_vendor_product.mk
======
vendor/qcom/proprietary/data/data_prop_vendor_product.mk::vendor/qcom/defs/product-defs/vendor/data_prop_vendor_product.mk
---> src:  vendor/qcom/proprietary/data/data_prop_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/data_prop_vendor_product.mk
======
vendor/qcom/proprietary/qmi/qmi_data_vendor_product.mk::vendor/qcom/defs/product-defs/vendor/qmi_data_vendor_product.mk
---> src:  vendor/qcom/proprietary/qmi/qmi_data_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/qmi_data_vendor_product.mk
======
vendor/qcom/proprietary/qcril-data-hal/datamodule/module/qcril-data-product.mk::vendor/qcom/defs/product-defs/legacy/qcril-data-product.mk
---> src:  vendor/qcom/proprietary/qcril-data-hal/datamodule/module/qcril-data-product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/qcril-data-product.mk
======
vendor/qcom/proprietary/nqnfc-firmware/nfc_proprietary_product.mk::vendor/qcom/defs/product-defs/legacy/nfc-proprietary-product.mk
---> src:  vendor/qcom/proprietary/nqnfc-firmware/nfc_proprietary_product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/nfc-proprietary-product.mk
======
vendor/nxp/opensource/commonsys/packages/apps/Nfc/nfc_system_product.mk::vendor/qcom/defs/product-defs/legacy/nfc-system-product.mk
---> src:  vendor/nxp/opensource/commonsys/packages/apps/Nfc/nfc_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/nfc-system-product.mk
======
vendor/nxp/opensource/halimpl/nfc_vendor_product.mk::vendor/qcom/defs/product-defs/legacy/nfc-vendor-product.mk
---> src:  vendor/nxp/opensource/halimpl/nfc_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/nfc-vendor-product.mk
======
vendor/qcom/proprietary/ims-ship/ims_vendor_product_noship.mk::vendor/qcom/defs/product-defs/legacy/ims_vendor_product_noship.mk
---> src:  vendor/qcom/proprietary/ims-ship/ims_vendor_product_noship.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/ims_vendor_product_noship.mk
======
vendor/qcom/proprietary/commonsys-intf/adsprpc_ship/adsprpc_system_product.mk::vendor/qcom/defs/product-defs/system/adsprpc_system_product.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/adsprpc_ship/adsprpc_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/adsprpc_system_product.mk
======
vendor/qcom/proprietary/commonsys-intf/adsprpc_ship/adsprpc_vendor_product.mk::vendor/qcom/defs/product-defs/vendor/adsprpc_vendor_product.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/adsprpc_ship/adsprpc_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/adsprpc_vendor_product.mk
======
vendor/qcom/proprietary/dspservices_ship/contexthub_system_product.mk::vendor/qcom/defs/product-defs/system/contexthub_system_product.mk
---> src:  vendor/qcom/proprietary/dspservices_ship/contexthub_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/contexthub_system_product.mk
======
vendor/qcom/proprietary/dspservices_ship/chre_system_product.mk::vendor/qcom/defs/product-defs/vendor/chre_system_product.mk
---> src:  vendor/qcom/proprietary/dspservices_ship/chre_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/chre_system_product.mk
======
vendor/qcom/proprietary/dspservices_ship/remote_debug_agent_vendor_board.mk::vendor/qcom/defs/board-defs/vendor/remote_debug_agent_vendor_board.mk
---> src:  vendor/qcom/proprietary/dspservices_ship/remote_debug_agent_vendor_board.mk
<--- dest:  vendor/qcom/defs/board-defs/vendor/remote_debug_agent_vendor_board.mk
======
vendor/qcom/proprietary/cv/fastcv/cv_vendor_product.mk::vendor/qcom/defs/product-defs/legacy/cv_vendor_product.mk
---> src:  vendor/qcom/proprietary/cv/fastcv/cv_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/cv_vendor_product.mk
======
vendor/qcom/proprietary/cv/fastcv/cv_vendor_board.mk::vendor/qcom/defs/board-defs/legacy/cv_vendor_board.mk
---> src:  vendor/qcom/proprietary/cv/fastcv/cv_vendor_board.mk
<--- dest:  vendor/qcom/defs/board-defs/legacy/cv_vendor_board.mk
======
vendor/qcom/proprietary/cv/fastcv/cv_system_product.mk::vendor/qcom/defs/product-defs/legacy/cv_system_product.mk
---> src:  vendor/qcom/proprietary/cv/fastcv/cv_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/cv_system_product.mk
======
vendor/qcom/proprietary/securemsm/config/smcinvoke_vendor_proprietary_product.mk::vendor/qcom/defs/product-defs/vendor/smcinvoke_vendor_proprietary_product.mk
---> src:  vendor/qcom/proprietary/securemsm/config/smcinvoke_vendor_proprietary_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/smcinvoke_vendor_proprietary_product.mk
======
vendor/qcom/proprietary/securemsm/config/qseecomd_vendor_proprietary_product.mk::vendor/qcom/defs/product-defs/vendor/qseecomd_vendor_proprietary_product.mk
---> src:  vendor/qcom/proprietary/securemsm/config/qseecomd_vendor_proprietary_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/qseecomd_vendor_proprietary_product.mk
======
vendor/qcom/proprietary/securemsm/config/cpz_vendor_proprietary_board.mk::vendor/qcom/defs/board-defs/vendor/cpz_vendor_proprietary_board.mk
---> src:  vendor/qcom/proprietary/securemsm/config/cpz_vendor_proprietary_board.mk
<--- dest:  vendor/qcom/defs/board-defs/vendor/cpz_vendor_proprietary_board.mk
======
vendor/qcom/proprietary/securemsm/config/cpz_vendor_proprietary_product.mk::vendor/qcom/defs/product-defs/vendor/cpz_vendor_proprietary_product.mk
---> src:  vendor/qcom/proprietary/securemsm/config/cpz_vendor_proprietary_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/cpz_vendor_proprietary_product.mk
======
vendor/qcom/proprietary/securemsm/config/keymaster_vendor_proprietary_board.mk::vendor/qcom/defs/board-defs/vendor/keymaster_vendor_proprietary_board.mk
---> src:  vendor/qcom/proprietary/securemsm/config/keymaster_vendor_proprietary_board.mk
<--- dest:  vendor/qcom/defs/board-defs/vendor/keymaster_vendor_proprietary_board.mk
======
vendor/qcom/proprietary/securemsm/config/keymaster_vendor_proprietary_product.mk::vendor/qcom/defs/product-defs/vendor/keymaster_vendor_proprietary_product.mk
---> src:  vendor/qcom/proprietary/securemsm/config/keymaster_vendor_proprietary_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/keymaster_vendor_proprietary_product.mk
======
vendor/qcom/proprietary/securemsm/config/gp_vendor_proprietary_product.mk::vendor/qcom/defs/product-defs/vendor/gp_vendor_proprietary_product.mk
---> src:  vendor/qcom/proprietary/securemsm/config/gp_vendor_proprietary_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/gp_vendor_proprietary_product.mk
======
vendor/qcom/proprietary/securemsm/config/tloc_vendor_proprietary_product.mk::vendor/qcom/defs/product-defs/vendor/tloc_vendor_proprietary_product.mk
---> src:  vendor/qcom/proprietary/securemsm/config/tloc_vendor_proprietary_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/tloc_vendor_proprietary_product.mk
======
vendor/qcom/proprietary/securemsm/config/qseecom_hal_vendor_proprietary_product.mk::vendor/qcom/defs/product-defs/vendor/qseecom_hal_vendor_proprietary_product.mk
---> src:  vendor/qcom/proprietary/securemsm/config/qseecom_hal_vendor_proprietary_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/qseecom_hal_vendor_proprietary_product.mk
======
vendor/qcom/proprietary/commonsys/securemsm/securemsm_system_product.mk::vendor/qcom/defs/product-defs/system/securemsm_product.mk
---> src:  vendor/qcom/proprietary/commonsys/securemsm/securemsm_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/securemsm_product.mk
======
vendor/qcom/proprietary/commonsys/securemsm/config/gp_system_proprietary_product.mk::vendor/qcom/defs/product-defs/system/gp_system_proprietary_product.mk
---> src:  vendor/qcom/proprietary/commonsys/securemsm/config/gp_system_proprietary_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/gp_system_proprietary_product.mk
======
vendor/qcom/proprietary/commonsys/securemsm/config/qseecom_lib_system_product.mk::vendor/qcom/defs/product-defs/system/qseecom_lib_system_product.mk
---> src:  vendor/qcom/proprietary/commonsys/securemsm/config/qseecom_lib_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/qseecom_lib_system_product.mk
======
vendor/qcom/proprietary/gps-release/gps_system_product.mk::vendor/qcom/defs/product-defs/system/gps-product.mk
---> src:  vendor/qcom/proprietary/gps-release/gps_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/gps-product.mk
======
vendor/qcom/proprietary/gps-release/gps_system_board.mk::vendor/qcom/defs/board-defs/system/gps-board.mk
---> src:  vendor/qcom/proprietary/gps-release/gps_system_board.mk
<--- dest:  vendor/qcom/defs/board-defs/system/gps-board.mk
======
vendor/qcom/proprietary/gps-release/gps_vendor_product.mk::vendor/qcom/defs/product-defs/vendor/gps-product.mk
---> src:  vendor/qcom/proprietary/gps-release/gps_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/gps-product.mk
======
vendor/qcom/proprietary/commonsys-intf/bluetooth/bt-vendor-proprietary-board.mk::vendor/qcom/defs/board-defs/legacy/bt-vendor-proprietary-board.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/bluetooth/bt-vendor-proprietary-board.mk
<--- dest:  vendor/qcom/defs/board-defs/legacy/bt-vendor-proprietary-board.mk
======
vendor/qcom/proprietary/commonsys-intf/bluetooth/bt-vendor-proprietary-product.mk::vendor/qcom/defs/product-defs/legacy/bt-vendor-proprietary-product.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/bluetooth/bt-vendor-proprietary-product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/bt-vendor-proprietary-product.mk
======
vendor/qcom/proprietary/commonsys-intf/bluetooth/bt-system-proprietary-product.mk::vendor/qcom/defs/product-defs/legacy/bt-system-proprietary-product.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/bluetooth/bt-system-proprietary-product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/bt-system-proprietary-product.mk
======
vendor/qcom/opensource/commonsys-intf/bluetooth/bt-commonsys-intf-legacy-board.mk::vendor/qcom/defs/board-defs/legacy/bt-commonsys-intf-legacy-board.mk
---> src:  vendor/qcom/opensource/commonsys-intf/bluetooth/bt-commonsys-intf-legacy-board.mk
<--- dest:  vendor/qcom/defs/board-defs/legacy/bt-commonsys-intf-legacy-board.mk
======
vendor/qcom/opensource/commonsys-intf/bluetooth/bt-system-opensource-product.mk::vendor/qcom/defs/product-defs/legacy/bt-system-opensource-product.mk
---> src:  vendor/qcom/opensource/commonsys-intf/bluetooth/bt-system-opensource-product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/bt-system-opensource-product.mk
======
vendor/qcom/proprietary/commonsys/voiceui/app_voiceui_system_product.mk::vendor/qcom/defs/product-defs/system/app_voiceui_product.mk
---> src:  vendor/qcom/proprietary/commonsys/voiceui/app_voiceui_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/app_voiceui_product.mk
======
vendor/qcom/opensource/core-utils/build/QSSI_violators.mk::vendor/qcom/build/tasks/QSSI_violators.mk
---> src:  vendor/qcom/opensource/core-utils/build/QSSI_violators.mk
<--- dest:  vendor/qcom/build/tasks/QSSI_violators.mk
======
vendor/qcom/opensource/core-utils/build.sh::build.sh
---> src:  vendor/qcom/opensource/core-utils/build.sh
<--- dest:  build.sh
======
vendor/qcom/proprietary/qrdplus/PowerOffAlarm/app_poweroffalarm_vendor_product.mk::vendor/qcom/defs/product-defs/vendor/app_poweroffalarm_product.mk
---> src:  vendor/qcom/proprietary/qrdplus/PowerOffAlarm/app_poweroffalarm_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/app_poweroffalarm_product.mk
======
vendor/qcom/proprietary/commonsys-intf/telephony/build/telephony_vendor_product.mk::vendor/qcom/defs/product-defs/vendor/telephony-product.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/telephony/build/telephony_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/telephony-product.mk
======
vendor/qcom/proprietary/commonsys-intf/telephony/build/telephony-noship_system_product.mk::vendor/qcom/defs/product-defs/system/telephony-noship-product.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/telephony/build/telephony-noship_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/telephony-noship-product.mk
======
vendor/qcom/proprietary/commonsys-intf/telephony/build/telephony_system_product.mk::vendor/qcom/defs/product-defs/system/telephony-product.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/telephony/build/telephony_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/telephony-product.mk
======
vendor/qcom/proprietary/commonsys-intf/telephony/build/telephony-intf_system_product.mk::vendor/qcom/defs/product-defs/system/telephony-intf-product.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/telephony/build/telephony-intf_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/system/telephony-intf-product.mk
======
vendor/qcom/proprietary/commonsys-intf/telephony/build/telephony-intf_vendor_product.mk::vendor/qcom/defs/product-defs/vendor/telephony-intf-product.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/telephony/build/telephony-intf_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/telephony-intf-product.mk
======
vendor/qcom/proprietary/commonsys/cne/cne_commonsys_system_product.mk::vendor/qcom/defs/product-defs/legacy/cne_commonsys_system_product.mk
---> src:  vendor/qcom/proprietary/commonsys/cne/cne_commonsys_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/cne_commonsys_system_product.mk
======
vendor/qcom/proprietary/commonsys/cne/cne_system_product_noship.mk::vendor/qcom/defs/product-defs/legacy/cne_system_product_noship.mk
---> src:  vendor/qcom/proprietary/commonsys/cne/cne_system_product_noship.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/cne_system_product_noship.mk
======
vendor/qcom/proprietary/commonsys/ims-ship/ims_commonsys_system_product.mk::vendor/qcom/defs/product-defs/legacy/ims_commonsys_system_product.mk
---> src:  vendor/qcom/proprietary/commonsys/ims-ship/ims_commonsys_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/ims_commonsys_system_product.mk
======
vendor/qcom/proprietary/commonsys/ims-ship/ims-internal_system_product_noship.mk::vendor/qcom/defs/product-defs/legacy/ims-internal_system_product_noship.mk
---> src:  vendor/qcom/proprietary/commonsys/ims-ship/ims-internal_system_product_noship.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/ims-internal_system_product_noship.mk
======
vendor/qcom/proprietary/commonsys/ims-ship/ims_system_product_noship.mk::vendor/qcom/defs/product-defs/legacy/ims_system_product_noship.mk
---> src:  vendor/qcom/proprietary/commonsys/ims-ship/ims_system_product_noship.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/ims_system_product_noship.mk
======
vendor/qcom/proprietary/commonsys-intf/data/data_commonsys-intf_board.mk::vendor/qcom/defs/board-defs/legacy/data_commonsys-intf_board.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/data/data_commonsys-intf_board.mk
<--- dest:  vendor/qcom/defs/board-defs/legacy/data_commonsys-intf_board.mk
======
vendor/qcom/proprietary/commonsys-intf/data/data_commonsys-intf_vendor_product.mk::vendor/qcom/defs/product-defs/legacy/data_commonsys-intf_vendor_product.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/data/data_commonsys-intf_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/data_commonsys-intf_vendor_product.mk
======
vendor/qcom/proprietary/commonsys-intf/data/data_commonsys-intf_system_product.mk::vendor/qcom/defs/product-defs/legacy/data_commonsys-intf_system_product.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/data/data_commonsys-intf_system_product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/data_commonsys-intf_system_product.mk
======
vendor/qcom/proprietary/commonsys-intf/data/data_commonsys-intf_system_product_noship.mk::vendor/qcom/defs/product-defs/legacy/data_commonsys-intf_system_product_noship.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/data/data_commonsys-intf_system_product_noship.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/data_commonsys-intf_system_product_noship.mk
======
vendor/qcom/proprietary/commonsys-intf/data/data_commonsys-intf_vendor_product_noship.mk::vendor/qcom/defs/product-defs/legacy/data_commonsys-intf_vendor_product_noship.mk
---> src:  vendor/qcom/proprietary/commonsys-intf/data/data_commonsys-intf_vendor_product_noship.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/data_commonsys-intf_vendor_product_noship.mk
======
vendor/qcom/proprietary/mm-camera/mm-camera2/configs/camera_vendor_product.mk::vendor/qcom/defs/product-defs/vendor/camera_vendor_product.mk
---> src:  vendor/qcom/proprietary/mm-camera/mm-camera2/configs/camera_vendor_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/camera_vendor_product.mk
======
vendor/qcom/proprietary/vpp/config/vpp-vendor-board.mk::vendor/qcom/defs/board-defs/legacy/vpp-board.mk
---> src:  vendor/qcom/proprietary/vpp/config/vpp-vendor-board.mk
<--- dest:  vendor/qcom/defs/board-defs/legacy/vpp-board.mk
======
vendor/qcom/proprietary/vpp/config/vpp-vendor-product.mk::vendor/qcom/defs/product-defs/legacy/vpp-product.mk
---> src:  vendor/qcom/proprietary/vpp/config/vpp-vendor-product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/vpp-product.mk
======
vendor/qcom/proprietary/configstore/configstore-product.mk::vendor/qcom/defs/product-defs/legacy/configstore-product.mk
---> src:  vendor/qcom/proprietary/configstore/configstore-product.mk
<--- dest:  vendor/qcom/defs/product-defs/legacy/configstore-product.mk
======
vendor/qcom/proprietary/coretech-config-vendor/thermal-engine/thermal-engine_product.mk::vendor/qcom/defs/product-defs/vendor/thermal-engine_product.mk
---> src:  vendor/qcom/proprietary/coretech-config-vendor/thermal-engine/thermal-engine_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/thermal-engine_product.mk
======
vendor/qcom/proprietary/coretech-config-vendor/thermal-hal/thermal-hal_product.mk::vendor/qcom/defs/product-defs/vendor/thermal-hal_product.mk
---> src:  vendor/qcom/proprietary/coretech-config-vendor/thermal-hal/thermal-hal_product.mk
<--- dest:  vendor/qcom/defs/product-defs/vendor/thermal-hal_product.mk
======

参考: linux shell readlink 获取当前脚本文件绝对路径
https://www.it610.com/article/1304474769474752512.htm
linux shell 指令 诸如-d, -f, -e之类的判断表达式简介
https://www.cnblogs.com/zrmw/p/9625727.html
shell 命令之 wc -l
https://www.cnblogs.com/drjava/p/10533649.html
ln 链接文件
https://www.codesocang.com/jquerymobile/linux/2/11.html

addcompletions

    local completion_files=(
      system/core/adb/adb.bash
      system/core/fastboot/fastboot.bash
      tools/asuite/asuite.sh
    )
    # Completion can be disabled selectively to allow users to use non-standard completion.
    # e.g.
    # ENVSETUP_NO_COMPLETION=adb # -> disable adb completion
    # ENVSETUP_NO_COMPLETION=adb:bit # -> disable adb and bit completion
    for f in ${completion_files[*]}; do
        if [ -f "$f" ] && should_add_completion "$f"; then
            . $f
        fi
    done

判断是否有这个文件,或者是否文件属于 ENVSETUP_NO_COMPLETION 中需要进行补全的,然后执行 adb.bash, fastboot.bash, asuite.sh 这些脚本文件。 在tools/asuite/asuite.sh 这个脚本文件中,包含 tradefederation/core/atest/atest_completion.sh,这个文件也会被执行一下。

增加打印,可以看到输出结果:

complete f:  system/core/adb/adb.bash
should add completion:  system/core/adb/adb.bash
0
complete f:  system/core/fastboot/fastboot.bash
should add completion:  system/core/fastboot/fastboot.bash
0
complete f:  tools/asuite/asuite.sh
should add completion:  tools/asuite/asuite.sh
0
should add completion:  /home/ptz/sc200r/SC200R_Android10.0_R04_r023/tools/tradefederation/core/atest/atest_completion.sh
0
should add completion:  bit
0
    complete -F _lunch lunch

    complete -F _complete_android_module_names gomod
    complete -F _complete_android_module_names m

上面是针对 lunch这个命令 使用 _lunch 这个函数进行补全, gomod, m 也是这样。

参考: shell 中 basename 的简单使用
https://blog.51cto.com/sdsca/1903822
使用bash内置命令complete来实现参数补全
https://www.cnblogs.com/lyg-blog/p/14760145.html
使用Bash中Complete自动补全命令
https://blog.csdn.net/chen_fly2011/article/details/56830892

转自: https://blog.csdn.net/u011913612/article/details/51878356

Android编译系统分析系列文章:

android编译系统分析一<source build/envsetup.sh与lunch> Android编译系统<二>-mm编译单个模块 android编译系统分析(三)-make android编译系统(四)-实战:新增一个产品 Android编译系统分析(五)-system.img的生成过程

虽然已经有很多人分析过android的编译系统的代码了,我也看过他们的博客,也学到了不少知识,但单纯的看别人分析,终究还是理解的不深入,所以,我还是要自己再认真的分析一遍。

想想我们编译android系统的过程:

首先:source build/envsetup.sh

其次:lunch ---选择一个特定的类型

最后:make

按着这个顺序,追踪这看似简单的几步,到底有哪些背后的秘密?

- 阅读剩余部分 -

  1. 根据引脚和初始化参数,以及规格书,制作类似于 panel_ili9881c_720p_video.xml 的文件。
  2. 安装必要的软件
    #sudo apt-get install libxml-libxml-perl 
    #sudo apt-get install libxml-perl 
  3. 把 xml 文件放入 device/qcom/common/display/tools 文件夹里面。
  4. perl parser.pl panel_ ili9881c_720p_video.xml panel 生成 dsi-panel-ili9881c-720p-video.dtsipanel_ili9881c_720p_video.h
  5. cp device/qcom/common/display/tools/dsi-panel-ili9881c-720p-video.dtsi kernel/msm-4.9/arch/arm64/boot/dts/qcom cp device/qcom/common/display/tools/panel_ili9881c_720p_video.h bootable/bootloader/lk/dev/gcdb/display/include/
  6. 修改 bootable/bootloader/lk/target/msm8952/oem_panel.c, lk 中的配置用于刚开机后对屏幕的驱动。
  7. 修改 kernel/msm-4.9/arch/arm64/boot/dts/qcom/msm8937-mdss-panels.dtsi kernel/msm-4.9/arch/arm64/boot/dts/qcom/qm215-qrd.dtsi 等文件,用于 kernel 对于 sleep 和 wakeup 时对屏幕的驱动。
  8. 全部修改完后,编译一下,拿到新的 boot.img
    source build/envsetup.sh 
    lunch msm8937_32-userdebug 
    make aboot 
    make kernel 
  9. 根据修改的内容决定具体烧录哪些 img, 正常修改屏幕驱动,只要更新 emmc_appsboot.mbn, boot.img
    adb reboot bootloader
    fastboot flash boot boot.img
    fastboot flash aboot emmc_appsboot.mbn
    fastboot flash dtbo dtbo.img
    fastboot flash dtbobak dtbo.img
    fastboot reboot