123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- function help() {
- cat <<EOF
- Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- == before all ==
- - config: config <arch_name>
- == build project ==
- - mbase: Build ice_base.
- - mxfce: Build ice_xfce.
- - mgnome: Build ice_gnome.
- - msdk: Build SDK.
- == jump directory ==
- - ctarget: Jump to target directory.
- - cdeb: Jump to target deb directory.
- - cimage: Jump to target image directory.
- == grep file ==
- - cgrep: Greps on all local C/C++ files.
- Look at the source to view more functions. The complete list is:
- EOF
- T=$(gettop)
- local A
- A=""
- for i in `cat $T/openembedded-core/envsetup.sh | sed -n "/^[ \t]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
- A="$A $i"
- done
- echo $A
- }
- function cgrep()
- {
- find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
- }
- function gettop
- {
- local TOPFILE=openembedded-core/envsetup.sh
- if [ -n "$MPSOC_TOP" -a -f "$MPSOC_TOP/$TOPFILE" ] ; then
- # The following circumlocution ensures we remove symlinks from TOP.
- (\cd $MPSOC_TOP; PWD= /bin/pwd)
- else
- if [ -f $TOPFILE ] ; then
- # The following circumlocution (repeated below as well) ensures
- # that we record the true directory name and not one that is
- # faked up with symlink names.
- PWD= /bin/pwd
- else
- local here="${PWD}"
- while [ "${here}" != "/" ]; do
- if [ -f "${here}/${TOPFILE}" ]; then
- (\cd ${here}; PWD= /bin/pwd)
- break
- fi
- here="$(dirname ${here})"
- done
- fi
- fi
- }
- function mbase()
- {
- local T=$(gettop)
- [ -z "$T" ] \
- && echo "Couldn't locate the top of the tree. Try setting TOP." \
- && return
- if [ "$1" ] ; then
- config $1
- fi
- export YOCTO_TARGET_IMAGE_DIR="thead-build/ice-base"
- echo -e
- echo "YOCTO_TARGET_IMAGE_DIR=$YOCTO_TARGET_IMAGE_DIR"
- echo -e
- if [ -e $T/openembedded-core/oe-init-build-env ] ; then
- source $T/openembedded-core/oe-init-build-env $T/$YOCTO_TARGET_IMAGE_DIR
- bitbake core-image-minimal
- fi
- }
- function msdk()
- {
- local T=$(gettop)
- [ -z "$T" ] \
- && echo "Couldn't locate the top of the tree. Try setting TOP." \
- && return
- if [ "$1" ] ; then
- config $1
- fi
- export YOCTO_TARGET_IMAGE_DIR="thead-build/ice-base"
- echo -e
- echo "YOCTO_TARGET_IMAGE_DIR=$YOCTO_TARGET_IMAGE_DIR"
- echo -e
- if [ -e $T/openembedded-core/oe-init-build-env ] ; then
- source $T/openembedded-core/oe-init-build-env $T/$YOCTO_TARGET_IMAGE_DIR
- bitbake core-image-minimal -c populate_ext
- fi
- }
- function mxfce()
- {
- local T=$(gettop)
- [ -z "$T" ] \
- && echo "Couldn't locate the top of the tree. Try setting TOP." \
- && return
- if [ "$1" ] ; then
- config $1
- fi
- export YOCTO_TARGET_IMAGE_DIR="thead-build/ice-xfce"
- echo -e
- echo "YOCTO_TARGET_IMAGE_DIR=$YOCTO_TARGET_IMAGE_DIR"
- echo -e
- if [ -e $T/openembedded-core/oe-init-build-env ] ; then
- source $T/openembedded-core/oe-init-build-env $T/$YOCTO_TARGET_IMAGE_DIR
- bitbake core-image-minimal-xfce
- fi
- }
- function mgnome()
- {
- local T=$(gettop)
- [ -z "$T" ] \
- && echo "Couldn't locate the top of the tree. Try setting TOP." \
- && return
- if [ "$1" ] ; then
- config $1
- fi
- export YOCTO_TARGET_IMAGE_DIR="thead-build/ice-gnome"
- echo -e
- echo "YOCTO_TARGET_IMAGE_DIR=$YOCTO_TARGET_IMAGE_DIR"
- echo -e
- if [ -e $T/openembedded-core/oe-init-build-env ] ; then
- source $T/openembedded-core/oe-init-build-env $T/$YOCTO_TARGET_IMAGE_DIR
- bitbake core-image-gnome
- fi
- }
- function ctarget()
- {
- T=$(gettop)
- local T=$(gettop)
- [ -z "$T" ] \
- && echo "Couldn't locate the top of the tree. Try setting TOP." \
- && return
- \cd $T/$YOCTO_TARGET_IMAGE_DIR
- }
- function cdeb()
- {
- T=$(gettop)
- local T=$(gettop)
- [ -z "$T" ] \
- && echo "Couldn't locate the top of the tree. Try setting TOP." \
- && return
- \cd $T/$YOCTO_TARGET_IMAGE_DIR/tmp-glibc/deploy/deb
- }
- function cimage()
- {
- T=$(gettop)
- local T=$(gettop)
- [ -z "$T" ] \
- && echo "Couldn't locate the top of the tree. Try setting TOP." \
- && return
- \cd $T/$YOCTO_TARGET_IMAGE_DIR/tmp-glibc/deploy/images
- }
- function gen_config_combo()
- {
- export ARCH_MENU_CHOICES=(riscv csky)
- }
- function print_config_menu()
- {
- local uname=$(uname)
- echo
- echo "You're building on" $uname
- echo
- echo "Config menu... pick a combo:"
- local i=1
- local choice
- for choice in ${ARCH_MENU_CHOICES[@]}
- do
- echo " $i. $choice"
- i=$(($i+1))
- done
- echo
- }
-
- function config
- {
- local T=$(gettop)
- [ -z "$T" ] && return -1
-
- local last=riscv
-
- # install config menu
- gen_config_combo
- # select platform
- local select
- if [ "$1" ] ; then
- select=$1
- else
- print_config_menu
- echo -n "Which would you like?"
- [ -n "${last}" ] && echo -n " [Default ${last}]"
- echo -n ": "
- read select
- fi
- if [ -z "${select}" ]; then
- select=${last}
- elif (echo -n $select | grep -q -e "^[0-9][0-9]*$"); then
- [ $select -le ${#ARCH_MENU_CHOICES[@]} ] \
- && select=${ARCH_MENU_CHOICES[$(($select-1))]}
- elif (echo -n $select | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$"); then
- select="$select"
- else
- echo
- echo "Invalid config combo: $select" >&2
- return 1
- fi
- # config info
- export YOCTO_BUILD_TOP=$(gettop)
- export YOCTO_TARGET_ARCH="$select"
- # Get the exact value of a build variable.
- echo -e
- echo "YOCTO_BUILD_TOP=$(gettop)"
- echo "YOCTO_TARGET_ARCH=${YOCTO_TARGET_ARCH}"
- echo -e
-
- rm -rf $T/meta-arch
- ln -s $T/meta-$YOCTO_TARGET_ARCH $T/meta-arch
- }
- function envsetup
- {
- if [ "x$SHELL" != "x/bin/bash" ]; then
- case `ps -o command -p $$` in
- *bash*)
- ;;
- *)
- echo -n "WARNING: Only bash is supported, "
- echo "use of other shell would lead to erroneous results"
- ;;
- esac
- fi
- # check top of SDK
- if [ ! -f "${PWD}/openembedded-core/envsetup.sh" ]; then
- echo "ERROR: Please source envsetup.sh in the root of SDK"
- return -1
- else
- export YOCTO_TOP="$(PWD= /bin/pwd)"
- fi
- # reset these variables.
- export VARIANT_CHOICES=yocto
- # Execute the contents of any vendorsetup.sh files we can find.
- local vendors vendor
- verdors="$(find -L target -maxdepth 4 -name 'vendorsetup.sh' 2>/dev/null | sort)"
- for verdor in ${verdors}
- do
- source ${verdor}
- done
- echo "Setup env done! Please run config next."
- local T=$(gettop)
- [ -z "$T" ] \
- && echo "Couldn't locate the top of the tree. Try setting TOP." \
- && return
- export YOCTO_TARGET_IMAGE_DIR="thead-build/ice-base"
- if [ -e $T/openembedded-core/oe-init-build-env ] ; then
- source $T/openembedded-core/oe-init-build-env $T/$YOCTO_TARGET_IMAGE_DIR >/dev/null
- fi
- }
- #### MAIN ####
- envsetup
|