android底层开发进阶(2)--makefile笔记与android的平台编译

makefile笔记

相关语法

  • / 换行符
  • $(object) 表示一个变量
  • ·PHONY 表示隐晦规则
  • #表示注释
  • include可以将别的makefile包含进来
  • -include将文件读取进来,如文件无法读取则继续执行
  • ifep表示条件语句的开始,并制定一个表达式
  • else表示为假的情况
  • endif表示一个条件语句的结束
  • $@表示目标文件
  • $^ 所有依赖的文件
  • $< 第一个依赖的文件

android 编译过程

在终端中输入source ./build/envsetup.sh

including device/asus/grouper/vendorsetup.sh
including device/asus/fugu/vendorsetup.sh
including device/asus/deb/vendorsetup.sh
including device/asus/tilapia/vendorsetup.sh
including device/asus/flo/vendorsetup.sh
including device/samsung/manta/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-mips/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
including device/htc/flounder/vendorsetup.sh
including device/qcom/common/vendorsetup.sh
including device/lge/mako/vendorsetup.sh
including vendor/qcom/proprietary/common/vendorsetup.sh
including sdk/bash_completion/adb.bash

从命令的输出可以知道,文件build/envsetup.sh在加载的过程中,又会在device目录中寻找那些名称为vendorsetup.sh的文件,并且也将它们加载到当前终端来。另外,在sdk/bash_completion目录下的adb.bash文件也会加载到当前终端来,它是用来实现adb命令的bash completion功能的。也就是说,加载了该文件之后,我们在运行adb相关的命令的时候,通过按tab键就可以帮助我们自动完成命令的输入。

PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.1.1
TARGET_PRODUCT=msm8952_64
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv7-a-neon
TARGET_2ND_CPU_VARIANT=cortex-a53
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.16.0-52-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=LMY47V
OUT_DIR=out

设置好了很多环境变量。通过设置这些环境变量,就配置好了Android编译环境。
总体来说,Android编译环境初始化完成之后,获得了以下三样东西:

  1. 将vendor和device目录下的vendorsetup.sh文件加载到了当前终端;
  2. 新增了lunch、m、mm和mmm等命令;
  3. 通过执行lunch命令设置好了TARGET_PRODUCT、TARGET_BUILD_VARIANT、TARGET_BUILD_TYPE和TARGET_BUILD_APPS等环境变量。

你可能感兴趣的:(android)