@@ -29,13 +29,16 @@ usage()
echo -e "\nUsage: source $PROGNAME <build-dir>
<build-dir>: required option; specifies build directory location
-By default the script will setup MACHINE to be imx6qsabresd.
+Either specify the MACHINE in the environment, or choose
+one from the list provided when the script is run.
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 $PROGNAME <build-dir>
+ MACHINE=<machine> source $PROGNAME <build-dir>
+or don't specify the MACHINE and the script will prompt
+you for one with a list.
The script sets PARALLEL_MAKE & BB_NUMBER_THREADS to $NCPU
"
@@ -43,7 +46,8 @@ The script sets PARALLEL_MAKE & BB_NUMBER_THREADS to $NCPU
clean_up()
{
- unset EULA LIST_MACHINES VALID_MACHINE
+ unset EULA LIST_MACHINES VALID_MACHINE MACHINELIST MACHINECNT EXISTINGCONFIG
+ unset _i _opt
unset NCPU CWD TEMPLATES SHORTOPTS LONGOPTS ARGS PROGNAME
}
@@ -79,10 +83,41 @@ if [ "$(whoami)" = "root" ]; then
echo "ERROR: do not use the BSP as root. Exiting..."
fi
-if [ -z "$MACHINE" ]; then
- MACHINE='imx6qsabresd'
+EXISTINGCONFIG=
+if [ -f $1/conf/local.conf ] && [ -f $1/conf/bblayers.conf ]; then
+ EXISTINGCONFIG="yes"
fi
+MACHINELIST=`ls -1 */*/conf/machine/*conf 2> /dev/null | cut -d'/' -f5 | cut -d'.' -f1 | sort -n | uniq`
+MACHINECNT=`echo $MACHINELIST | wc -w`
+machine_menu()
+{
+ _i=1
+ while [ $_i -le $MACHINECNT ]; do
+ echo -n "$_i) "
+ echo $MACHINELIST | cut -d' ' -f$_i
+ _i=`expr $_i + 1`
+ done
+}
+_opt=
+if [ -z "$MACHINE" ] && [ -z "$EXISTINGCONFIG" ]; then
+ while [ -z "$_opt" ]; do
+ machine_menu
+ echo -n "Please choose a MACHINE: "
+ read _opt
+ if echo $_opt | grep -qE "^[0-9]+$"; then
+ if [ $_opt -gt 0 ] && [ $_opt -le $MACHINECNT ]; then
+ MACHINE=`echo $MACHINELIST | cut -d' ' -f$_opt`
+ break
+ fi
+ fi
+ echo "invalid input: \"$_opt\""
+ echo ""
+ _opt=
+ done
+fi
+unset _opt _i EXISTINGCONFIG MACHINELIST MACHINECNT
+
# Check the machine type specified
LIST_MACHINES=`ls -1 $CWD/sources/*/conf/machine`
VALID_MACHINE=`echo -e "$LIST_MACHINES" | grep ${MACHINE}.conf$ | wc -l`
If the user hasn't specified a MACHINE in the environment, and the specified build directory doesn't contain conf/local.conf and conf/bblayers.conf, then provide the user with a list of machines and have them choose one by number. Signed-off-by: Trevor Woerner <trevor.woerner@linaro.org> --- setup-environment | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) I would very much have liked to have been able to use "select", but (alas) it is a bash-ism.