Matt Lawrence 2cd8ac3875 BUILD: Housekeeping, add artoo bulild, directory moves/names, new build opts
- Changed build directory to /solo-build since it isn't alt anymore.
- Move 3dr-yocto-bsp-base into solo-builder directory
- Remove unused files and directories from solo-builder
- Added building artoo STM32 FW to build
- Updated command line options for nuke and scripted
- Removed debug outputs
2019-05-05 19:44:09 -04:00

249 lines
6.1 KiB
Bash
Executable File

#!/bin/sh
shopt -s xpg_echo
# -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
#
# Copyright (C) 2012, 2013 O.S. Systems Software LTDA.
# Authored-by: Otavio Salvador <otavio@ossystems.com.br>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# 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`
PROGNAME="setup-environment"
usage()
{
echo "\nUsage: source $PROGNAME <build-dir>
<build-dir>: required option; specifies build directory location
By default the script will setup MACHINE to be imx6solo-3dr-1080p.
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>
The script sets PARALLEL_MAKE & BB_NUMBER_THREADS to $NCPU
"
}
clean_up()
{
unset EULA LIST_MACHINES VALID_MACHINE
unset NCPU CWD TEMPLATES SHORTOPTS LONGOPTS ARGS PROGNAME
}
# get command line options
SHORTOPTS="h"
LONGOPTS="help"
ARGS=$(getopt --options $SHORTOPTS \
--longoptions $LONGOPTS --name $PROGNAME -- "$@" )
# Print the usage menu if invalid options are specified
if [ $? != 0 -o $# -lt 1 ]; then
usage && clean_up
exit 1
fi
eval set -- "$ARGS"
while true;
do
case $1 in
-h|--help)
usage
clean_up
exit 0
;;
--)
shift
break
;;
esac
done
if [ "$(whoami)" = "root" ]; then
echo "\nERROR: do not use the BSP as root. Exiting..."
exit 1
fi
if [ -z "$MACHINE" ]; then
MACHINE='imx6solo-3dr-1080p'
fi
# 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 [ "x$MACHINE" = "x" ] || [ "$VALID_MACHINE" = "0" ]; then
echo"\nERROR: Invalid machine type"
usage && clean_up
exit 1
else
echo "Configuring for ${MACHINE}"
fi
if [ -z "$SDKMACHINE" ]; then
SDKMACHINE='i686'
fi
if [ -z "$DISTRO" ]; then
DISTRO='3dr'
fi
OEROOT=sources/poky
if [ -e sources/oe-core ]; then
OEROOT=sources/oe-core
fi
# Ensure all files in sources/base are kept in sync with project root
updated=
for f in $CWD/sources/base/*; do
file="$(basename $f)"
if [ "$file" = "conf" ] || echo $file | grep -q '~$'; then
continue
fi
if ! cmp -s "$file" "$f"; then
updated="true"
[ -e $file ] && chmod u+w $file
cp $f $file
fi
done
if [ "$updated" = "true" ]; then
echo "\nACTION REQUIRED: The project root content has been updated. Please run $0 again."
return 2
fi
cd $OEROOT
. ./oe-init-build-env $CWD/$1 > /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
export PATH="`echo $PATH | sed 's/\(:.\|:\)*:/:/g;s/^.\?://;s/:.\?$//'`"
generated_config=
if [ ! -e conf/local.conf.sample ]; then
mv conf/local.conf conf/local.conf.sample
# Generate the local.conf based on the Yocto defaults
TEMPLATES=$CWD/sources/base/conf
grep -v '^#\|^$' conf/local.conf.sample > conf/local.conf
cat >> conf/local.conf <<EOF
BB_NUMBER_THREADS = '8'
PARALLEL_MAKE = '-j $NCPU'
DL_DIR ?= "\${BSPDIR}/downloads/"
EOF
# Change settings according environment
sed -e "s,MACHINE ??=.*,MACHINE ??= '$MACHINE',g" \
-e "s,SDKMACHINE ??=.*,SDKMACHINE ??= '$SDKMACHINE',g" \
-e "s,DISTRO ?=.*,DISTRO ?= '$DISTRO',g" \
-i conf/local.conf
cp $TEMPLATES/* conf/
for s in $HOME/.oe $HOME/.yocto; do
if [ -e $s/site.conf ]; then
echo "Linking $s/site.conf to conf/site.conf"
ln -s $s/site.conf conf
fi
done
generated_config=1
fi
# Handle EULA setting
if [ -z "$EULA" ] && ! grep -q '^ACCEPT_FSL_EULA\s*=' conf/local.conf; then
EULA='ask'
fi
if [ "$EULA" = "ask" ]; then
cat <<EOF
Some SoC depends on libraries and packages that are covered by
Freescale EULA. To have the right to use those binaries in your images
you need to read and accept the EULA that will be displayed.
EOF
sleep 4
more -d $CWD/sources/meta-fsl-arm/EULA
echo
while [ "$EULA" = "ask" ]; do
echo -n "Do you accept the EULA you just read? (y/n) "
read REPLY
case "$REPLY" in
y|Y)
echo "EULA has been accepted."
EULA="1"
;;
n|N)
echo "EULA has not been accepted."
EULA="0"
;;
esac
done
fi
if grep -q '^ACCEPT_FSL_EULA\s*=' conf/local.conf; then
sed -i "s/^#*ACCEPT_FSL_EULA\s*=.*/ACCEPT_FSL_EULA = \"$EULA\"/g" conf/local.conf
else
echo "ACCEPT_FSL_EULA = \"$EULA\"" >> conf/local.conf
fi
cat <<EOF
Welcome to Freescale Community BSP
The Yocto Project has extensive documentation about OE including a
reference manual which can be found at:
http://yoctoproject.org/documentation
For more information about OpenEmbedded see their website:
http://www.openembedded.org/
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
meta-toolchain
meta-toolchain-sdk
adt-installer
meta-ide-support
EOF
if [ -n "$generated_config" ]; then
cat <<EOF
Your build environemnt has been configured with:
MACHINE=$MACHINE
SDKMACHINE=$SDKMACHINE
DISTRO=$DISTRO
EULA=$EULA
EOF
else
echo "Your configuration files at $1 have not been touched."
fi
clean_up