在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