___2017

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  328 随笔 :: 18 文章 :: 15 评论 :: 18万 阅读

build/envsetup.sh

复制代码
function lunch()
{
    local answer

    if [ "$1" ] ; then
        answer=$1
    else
        print_lunch_menu
        echo -n "Which would you like?"
        read answer
    fi

    local selection=

    if [ -z "$answer" ]
    then
        selection=astar_parrot-tina
        # "^[0-9][0-9]*$":检查answer变量是否是数字
    elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
    then
        # 当answer的值为数字的时候
        if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
        then
            selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
        fi
        # "^[^\-][^\-]*-[^\-][^\-]*$":检查answer变量格式是否形如"XXXX-XXXXX"
    elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
    then
        # 当answer的值为字符串的时候
        selection=$answer
    fi

    if [ -z "$selection" ]
    then
        echo
        echo "Invalid lunch combo: $answer"
        return 1
    fi

    # 截掉_及其后面的内容,结果赋给platform。astar_parrot-tina--->astar
    local platform=$(echo -n $selection | sed -e "s/_.*$//")
    # 检测platform是否在PLATFORM_CHOICES的支持列表中
    check_platform $platform

    if [ $? -ne 0 ]
    then
        echo
        echo "** Don't have a platform spec for: '$platform'"
        echo "** Must be one of ${PLATFORM_CHOICES[@]}"
        echo "** Do you have the right repo manifest?"
        platform=
    fi

    # 截掉-及其后面的内容,结果赋给product。astar_parrot-tina--->astar_parrot
    local product=$(echo -n $selection | sed -e "s/-.*$//")
    check_product $product
    if [ $? -ne 0 ]
    then
        echo
        echo "** Don't have a product spec for: '$product'"
        echo "** Do you have the right repo manifest?"
        product=
    fi

    # variant: astar_parrot-tina--->tina
    local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
    check_variant $variant
    if [ $? -ne 0 ]
    then
        echo
        echo "** Invalid variant: '$variant'"
        echo "** Must be one of ${VARIANT_CHOICES[@]}"
        variant=
    fi

    # product\variant\platform任意一个为空,说明有错误
    if [ -z "$product" -o -z "$variant" -o -z "$platform" ]
    then
        echo
        return 1
    fi

    export TARGET_PRODUCT=$product
    export TARGET_PLATFORM=$platform
    export TARGET_BOARD=$(get_build_var TARGET_DEVICE)
    export TARGET_BUILD_VARIANT=$variant
    export TARGET_BUILD_TYPE=release

    rm -rf tmp
    echo

    set_stuff_for_environment
    # 显示当前配置信息
    printconfig
}
复制代码

 

在lunch函数执行过程中,很多次通过直接/间接的方式调用到get_build_var()函数:

复制代码
function get_build_var()
{
    # 编译项目的顶层目录
    T=$(gettop)
    if [ ! "$T" ]; then
        echo "Couldn't locate the top of the tree.  Try setting TOP." >&2
        return
    fi
    (\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build \
      command make --no-print-directory -f build/config.mk dumpvar-$1)
}
复制代码

以printconfig为例,最终执行的是:
get_build_var report_config
然后调用build/dumpvar.mk这个Makefile,显示当前配置的环境变量。

posted on   yin'xiang  阅读(717)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示