[meta-freescale] [fsl-community-bsp-platform][PATCH] setup-environment: add options for the script

Otavio Salvador otavio at ossystems.com.br
Mon May 20 12:41:35 PDT 2013


On Mon, May 20, 2013 at 4:26 PM, Mahesh Mahadevan <
Mahesh.Mahadevan at freescale.com> wrote:

> Add options to the script machine, below are the options added:
>
> Usage: source ./setup-environment <-b build-path>
>
>     * [-b build-path]: build dir location
>     * [-h or --help]: help
>
> By default the script will setup MACHINE to be imx6qsabresd.
>
> Supported machines: imx23evk imx28evk imx31pdk imx35pdk imx51evk imx53ard
> imx53qsb imx6dlsabresd imx6qsabreauto imx6qsabresd imx6slevk cgtqmx6
> imx233-olinuxino-maxi imx233-olinuxino-micro imx233-olinuxino-mini
> imx6qsabrelite nitrogen6x wandboard-dual wandboard-solo
>
> To build for a machine listed above, run this script as:
> MACHINE=<machine> source ./setup-environment <-b build-path>
>
> Signed-off-by: Mahesh Mahadevan <Mahesh.Mahadevan at freescale.com>
>

This one is much better but I still does not like to need of using '-b' for
build dir when it is the *only* known option. I'd much prefer the way it
was and been in use for quite some time (since denzil) so I don't think we
should change it without a strong reason.


>  setup-environment | 86
> +++++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 80 insertions(+), 6 deletions(-)
>
> diff --git a/setup-environment b/setup-environment
> index 6aadbb4..72e83b6 100644
> --- a/setup-environment
> +++ b/setup-environment
> @@ -17,15 +17,93 @@
>  # with this program; if not, write to the Free Software Foundation, Inc.,
>  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
>  #
> +# Add options for the script
> +# Copyright (C) 2013 Freescale Semiconductor, Inc.
> +
> +NCPU=`grep -c processor /proc/cpuinfo`
> +CWD=`pwd`
> +
> +usage()
> +{
> +    echo -e "\nUsage: source ${BASH_SOURCE[0]} <-b build-path>"
> +    echo "
> +    * [-b build-path]: build dir location
>

I'd drop this option.


> +    * [-h or --help]: help
> +"
> +    echo -e -n "By default the script will setup MACHINE to be
> imx6qsabresd.
>

I think you could give some examples about variables commonly overriden as
MACHINE, PARALLEL_MAKE and so on. This would justify the existence of the
'help' option and does make improve the user experience.



> +Supported machines: `ls sources/*/conf/machine/*.conf \
> +| sed s/\.conf//g | sed -r 's/^.+\///' | xargs echo`
> +
> +To build for a machine listed above, run this script as:
> +MACHINE=<machine> source ${BASH_SOURCE[0]} <-b build-path>
> +"
>

Use $0 as this needs to be portable for other shells (I personally use zsh
for example) and we shouldn't depend on bash specific features.


> +}
> +
> +clean_up()
> +{
> +   unset EULA MACHINE LIST_MACHINES VALID_MACHINE BUILD_DIR
> +   unset NCPU CWD TEMPLATES SHORTOPTS LONGOPTS ARGS
> +}
> +
> +# get command line options
> +SHORTOPTS="b:h"
> +LONGOPTS="help"
> +
> +ARGS=$(getopt --options $SHORTOPTS  \
> +  --longoptions $LONGOPTS --name ${BASH_SOURCE[0]} -- "$@" )
> +eval set -- "$ARGS"
> +while true;
> +do
> +    case $1 in
> +        -b)
> +           shift
> +           BUILD_DIR=$1;
> +           shift
> +           ;;
>

Drop please.


> +        -h|--help)
> +           usage
> +           clean_up
> +           return 0
> +           ;;
> +        --)
> +           usage
> +           clean_up
> +           return 1
> +           ;;
> +        *)
> +           shift
> +           break
> +           ;;
> +    esac
> +    shift
> +done
>
>  if [ "$(whoami)" = "root" ]; then
>      echo "ERROR: do not use the BSP as root. Exiting..."
>  fi
>
> +if [ -z "$BUILD_DIR" ]; then
> +    echo "Please provide a name for the build directory!"
> +    usage && clean_up
> +    return 1
> +fi
> +
>  if [ -z "$MACHINE" ]; then
>      MACHINE='imx6qsabresd'
>  fi
>
> +# Check the machine type specified
> +LIST_MACHINES=`ls $CWD/sources/*/conf/machine`
> +VALID_MACHINE=`echo -e "$LIST_MACHINES" | grep ${MACHINE}.conf$ | wc -l`
> +if [ "x$MACHINE" = "x" ] || [ "$VALID_MACHINE" = "0" ]; then
> +    echo -e "\nSPECIFIED AN INVALID MACHINE TYPE !"
> +    usage && clean_up
> +    return 1
> +else
> +    echo "Configuring for ${MACHINE}"
> +fi
> +
>  if [ -z "$SDKMACHINE" ]; then
>      SDKMACHINE='i686'
>  fi
> @@ -39,8 +117,6 @@ if [ -e sources/oe-core ]; then
>      OEROOT=sources/oe-core
>  fi
>
> -CWD=`pwd`
> -
>  # Ensure all files in sources/base are kept in sync with project root
>  updated=
>  for f in $CWD/sources/base/*; do
> @@ -62,7 +138,7 @@ fi
>
>  cd $OEROOT
>
> -. ./oe-init-build-env $CWD/$1 > /dev/null
> +. ./oe-init-build-env $CWD/$BUILD_DIR > /dev/null
>
>  # Clean up PATH, because if it includes tokens to current directories
> somehow,
>  # wrong binaries can be used instead of the expected ones during task
> execution
> @@ -74,7 +150,6 @@ if [ ! -e conf/local.conf.sample ]; then
>
>      # Generate the local.conf based on the Yocto defaults
>      TEMPLATES=$CWD/sources/base/conf
> -    NCPU=`grep -c processor /proc/cpuinfo`
>      grep -v '^#\|^$' conf/local.conf.sample > conf/local.conf
>      cat >> conf/local.conf <<EOF
>
> @@ -167,5 +242,4 @@ else
>      echo "Your configuration files at $1 has not been touched."
>  fi
>
> -# Force the question if setting a new build directory
> -unset EULA
> +clean_up
>

In general I like the changes except the '-b' option as it is not really
required and change the way people been using since its creation. Let's
avoid user changes without strong need.

Regards,

-- 
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://projetos.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/meta-freescale/attachments/20130520/549d9b83/attachment.html>


More information about the meta-freescale mailing list