[meta-freescale] [fsl-community-bsp-platform][PATCH] setup-environment: add options for the script
Mahesh Mahadevan
Mahesh.Mahadevan at freescale.com
Fri May 17 18:02:54 PDT 2013
From: Mahesh Mahadevan <mahesh.mahadevan at freescale.com>
Add options to help specify the machine, below are the options added:
Usage: source ./setup-environment <-m machine>
Optional parameters: [-j jobs] [-t tasks] [-h]
Supported machines: imx23evk imx28evk imx31pdk imx35pdk imx51evk imx53ard imx53qsb imx6dlsabresd imx6qsabreauto imx6qsabresd imx6slevk
* [-j jobs]: number of jobs for make to spawn during compile; default=4
* [-t tasks]: number of bitbake tasks that can be issued in parallel; default=4
* [-b path]: non-default build dir location; default location is /home/r9aadq/yocto/build
* [-h]: help
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan at freescale.com>
---
setup-environment | 91 +++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 81 insertions(+), 10 deletions(-)
diff --git a/setup-environment b/setup-environment
index 6aadbb4..96b1e26 100644
--- a/setup-environment
+++ b/setup-environment
@@ -17,13 +17,88 @@
# 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]} <-m machine>
+ Optional parameters: [-j jobs] [-t tasks] [-h]"
+ echo -e -n "\n Supported machines: `ls $CWD/sources/meta-fsl-arm/conf/machine \
+ | grep -v "^include" | sed s/\.conf//g | xargs echo`"
+echo "
+ * [-j jobs]: number of jobs for make to spawn during compile; default=$NCPU
+ * [-t tasks]: number of bitbake tasks that can be issued in parallel; default=$NCPU
+ * [-b path]: non-default build dir location; default location is $CWD/build
+ * [-h]: help
+"
+}
+
+clean_up()
+{
+ unset EULA MACHINE JOBS THREADS LIST_MACHINES VALID_MACHINE BUILD_DIR
+ unset NCPU CWD TEMPLATES
+ unset imx_poky_setup_j imx_poky_setup_t imx_poky_setup_help imx_poky_setup_error
+}
+
+# get command line options
+OLD_OPTIND=$OPTIND
+while getopts "m:r:t:b:h" imx_poky_setup_flag
+do
+ case $imx_poky_setup_flag in
+ m) MACHINE="$OPTARG";
+ ;;
+ j) imx_poky_setup_j="$OPTARG";
+ ;;
+ t) imx_poky_setup_t="$OPTARG";
+ ;;
+ b) BUILD_DIR="$CWD/$OPTARG";
+ ;;
+ h) imx_poky_setup_help='true';
+ ;;
+ ?) imx_poky_setup_error='true';
+ ;;
+ esac
+done
+OPTIND=$OLD_OPTIND
if [ "$(whoami)" = "root" ]; then
echo "ERROR: do not use the BSP as root. Exiting..."
fi
-if [ -z "$MACHINE" ]; then
- MACHINE='imx6qsabresd'
+# check the "-h" and other not supported options
+if test $imx_poky_setup_error || test $imx_poky_setup_help; then
+ usage && clean_up && return 1
+fi
+
+# Check the machine type specified
+LIST_MACHINES=`ls $CWD/sources/meta-fsl-arm/conf/machine`
+VALID_MACHINE=`echo -e "$LIST_MACHINES" | grep ${MACHINE}.conf$ | wc -l`
+if [ "x$MACHINE" = "x" ] || [ "$VALID_MACHINE" = "0" ]; then
+ echo "Invalid machine type!"
+ usage && clean_up
+ return 1
+else
+ echo "Configuring for ${MACHINE}"
+fi
+
+if [ -n "$imx_poky_setup_j" ] && [[ "$imx_poky_setup_j" =~ ^[0-9]+$ ]]; then
+ JOBS=$imx_poky_setup_j
+else
+ JOBS=$NCPU
+fi
+
+if [ -n "$fsl_poky_setup_t" ] && [[ "$fsl_poky_setup_t" =~ ^[0-9]+$ ]]; then
+ THREADS=$imx_poky_setup_t
+else
+ THREADS=$NCPU
+fi
+
+if [ -z "$BUILD_DIR" ]; then
+ BUILD_DIR=$CWD/build
fi
if [ -z "$SDKMACHINE" ]; then
@@ -39,8 +114,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 +135,7 @@ fi
cd $OEROOT
-. ./oe-init-build-env $CWD/$1 > /dev/null
+. ./oe-init-build-env $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,12 +147,11 @@ 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
-BB_NUMBER_THREADS = '$NCPU'
-PARALLEL_MAKE = '-j $NCPU'
+BB_NUMBER_THREADS = '$THREADS'
+PARALLEL_MAKE = '-j $JOBS'
EOF
# Change settings according environment
sed -e "s,MACHINE ??=.*,MACHINE ??= '$MACHINE',g" \
@@ -167,5 +239,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.7.10.4
More information about the meta-freescale
mailing list