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

Mahesh Mahadevan Mahesh.Mahadevan at freescale.com
Mon May 20 12:26:03 PDT 2013


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>
---
 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
+    * [-h or --help]: help
+"
+    echo -e -n "By default the script will setup MACHINE to be imx6qsabresd.
+
+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>
+"
+}
+
+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
+           ;;
+        -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
-- 
1.8.0





More information about the meta-freescale mailing list