openbmc 开发bitbake 相关complete script

在Openbmc开发经常需要使用bitbake devtool 等命令,  长期使用简化命令很重要.

在 .bashrc

# 加载项目
alias ldo='source setup oberon'
alias ldro='source setup evb-ast2600'
alias nm1='source setup my-dev'

# 加载项目后有环境变量 BBPATH
# 切入自己项目的meta目录
cdr(){
    cd $BBPATH/../../meta-asus/meta-mydev/
}
# 进入
cdb(){
        if [ -n "${BBPATH}" ]; then
                cd $BBPATH
        fi
}
# 进入openbmc顶层目录
cdt(){
        if [ -n "${BBPATH}" ]; then
                cd $BBPATH/../..
        fi
}
# 进入receipes build目录
cdst(){
        if [ -n "${BBPATH}" ]; then
                cd $BBPATH/tmp/work/
                if [ -n "$1" ]; then
                        cd $1
                fi
        fi
}

# 进入devtool 建立的 receipes 源码目录
cds(){
        if [ -n "${BBPATH}" ]; then
                cd $BBPATH/workspace/sources/
                if [ -n "$1" ]; then
                        cd $1
                fi
        fi
}

建立 bitbake_complete 脚本, 在 .bashrc 里添加

function _devtool_completion(){
        if [ "${COMP_CWORD}" == "1" ];then
                COMPREPLY=($(compgen -W "-h --help  update-recipe modify status build reset finish find-recipe edit-recipe search status" -- ${COMP_WORDS[${COMP_CWORD}]}))
        elif [ "${COMP_WORDS[1]}" == "-h" ];then
                return
        elif [ "${COMP_WORDS[1]}" == "reset" -o "${COMP_WORDS[1]}" == "build" ];then
                COMPREPLY=($(compgen -W "$(ls $BBPATH/workspace/sources)" -- ${COMP_WORDS[${COMP_CWORD}]}))
        elif [ "${COMP_WORDS[1]}" == "modify" ];then
                # COMPREPLY=($(compgen -W "u-boot linux-aspeed" -- ${COMP_WORDS[${COMP_CWORD}]}))
                COMPREPLY=($(compgen -W "$(cat ~/.config/recipe)" -- ${COMP_WORDS[${COMP_CWORD}]}))
        elif [ "${COMP_WORDS[1]}" == "finish" -o "${COMP_WORDS[1]}" == "update-recipe" ];then
                if [ "${COMP_CWORD}" == "2" ];then
                        COMPREPLY=($(compgen -W "$(ls $BBPATH/workspace/sources)" -- ${COMP_WORDS[${COMP_CWORD}]}))
                elif [ "${COMP_CWORD}" == "3" ] ;then
                        COMPREPLY=($(compgen -W "$(ls $BBPATH/../../meta-asus/)" -- ${COMP_WORDS[${COMP_CWORD}]}))
                fi
        fi
}

complete -F _devtool_completion devtool

function _bitbake-layers_completion(){
        if [ "${COMP_CWORD}" == "1" ];then        #
                COMPREPLY=($(compgen -W "-d -q -F -color -h add-layer  remove-layer create-layer  show-cross-depends flatten layerindex-show-depends layerindex-fetch  show-layers show-recipes   show-appends   show-cross-depends  show-overlayed   add-layer  remove-layer" -- ${COMP_WORDS[${COMP_CWORD}]}))                  elif [ "${COMP_WORDS[1]}" == "reset" -o "${COMP_WORDS[1]}" == "build" ];then
       # COMPREPLY=($(compgen -d ${COMP_WORDS[${COMP_CWORD}]}))
                COMPREPLY=($(compgen -W "$(ls $BBPATH/workspace/sources)" -- ${COMP_WORDS[${COMP_CWORD}]}))
        elif [ "${COMP_WORDS[1]}" == "finish" ];then
        if [ "${COMP_CWORD}" == "2" ];then
                    COMPREPLY=($(compgen -W "$(ls $BBPATH/workspace/sources)" -- ${COMP_WORDS[${COMP_CWORD}]}))
        elif [ "${COMP_CWORD}" == "3" ] ;then
            COMPREPLY=($(compgen -W "$(ls $BBPATH/../../meta-asus/)" -- ${COMP_WORDS[${COMP_CWORD}]}))
        fi
        fi
}

complete -F _bitbake-layers_completion bitbake-layers

function _bitbake_completion(){
        if [ "${COMP_CWORD}" == "1" ];then        #
                COMPREPLY=($(compgen -W "$(cat ~/.config/recipe)" -- ${COMP_WORDS[${COMP_CWORD}]}))
                # COMPREPLY=($(compgen -W "-d -g -e -c -h  obmc-phosphor-image linux-aspeed " -- ${COMP_WORDS[${COMP_CWORD}]}))
        elif [ "${COMP_WORDS[1]}" == "-c" ];then
       COMPREPLY=($(compgen -W "clean build compile cleanall" -- ${COMP_WORDS[${COMP_CWORD}]}))
        elif [ "${COMP_WORDS[1]}" == "finish" ];then
        if [ "${COMP_CWORD}" == "2" ];then
                    COMPREPLY=($(compgen -W "$(ls $BBPATH/workspace/sources)" -- ${COMP_WORDS[${COMP_CWORD}]}))
        elif [ "${COMP_CWORD}" == "3" ] ;then
            COMPREPLY=($(compgen -W "$(ls $BBPATH/../../meta-asus/)" -- ${COMP_WORDS[${COMP_CWORD}]}))
        fi
        fi
}

complete -F _bitbake_completion bitbake
function _cds_completion(){
        if [ "${COMP_CWORD}" == "1" ];then
                    COMPREPLY=($(compgen -W "$(ls $BBPATH/workspace/sources)" -- ${COMP_WORDS[${COMP_CWORD}]}))
        fi
}
complete -F _cds_completion cds

取得全部recipes列表,  我选择放在 .config/recipe

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值