Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 311 lines (271 sloc) 10.18 kb
#!/bin/sh
#
# Copyright 2007-2013 Mentor Graphics Corporation
#
# This file is licensed under the terms of the GNU General Public License
# version 2. This program is licensed "as is" without any warranty of any
# kind, whether express or implied.
OPTIONALLAYERS="${OPTIONALLAYERS:-mentor-private}"
EXTRAMELLAYERS="${EXTRAMELLAYERS:-openembedded-layer filesystems-layer networking-layer sourcery}"
usage () {
cat >&2 <<END
Usage: $0 [OPTIONS...] [MACHINE]
When operating from a MEL install, this script will use the template config
files from the installed BSP. If multiple BSPs are installed, you must specify
MACHINE, and the script will use the templates from that BSP.
When no installed BSP is available, MACHINE is required, and this script will
set up the build directory with a base set of layers + all layers which
include the machine .conf file for this machine, sorted by layer recipe
priority.
If the build directory already exists and is configured, you can leave MACHINE
unspecified, and the script will set you up for that build directory without
changing its configuration.
All layers whose directory name is update-*, at toplevel or a subdir, of the
parent of meta-mentor, will be automatically included, as a mechanism for
delivering sets of updates for releases.
Options:
-b BUILDDIR Specify the build directory to create (default: 'build')
-o MELDIR Specify the root of the MEL install, where you can find bitbake
and the layers
-l LAYERS Space-separated list of layer names for additional layers you
want to be included in the configuration
-f Force overwrite of existing configuration files in the build
directory. This includes local.conf and bblayers.conf, but not
site.conf
-h Show this usage information
END
}
prompt_choice () {
prompt_message="$1"
prompt_default="$2"
prompt_options="$(mktemp prompt-choice.XXXXXX)"
cat >>"$prompt_options"
prompt_count="$(wc -l <"$prompt_options")"
case $prompt_count in
0)
# No choices provided
rm -f "$prompt_options"
return 1
;;
1)
# Only one choice
cat "$prompt_options"
rm -f "$prompt_options"
return 0
;;
esac
if [ ! -t 0 ] || [ ! -t 2 ]; then
# We only prompt when running on a tty
return 2
fi
while [ -z "$prompt_value" ]; do
prompt_num=0
while read choice; do
prompt_num=$(expr $prompt_num + 1)
eval prompt_value_${prompt_num}="$choice"
printf >&2 "%s) %s\n" "$prompt_num" "$choice"
done <"$prompt_options"
printf >&2 "%s: " "$prompt_message"
read selection </dev/tty
prompt_value="$(eval echo \${prompt_value_$selection})"
done
printf "%s\n" "$prompt_value"
rm -f "$prompt_options"
}
abspath () {
readlink -f "$1"
}
configure_for_machine () {
if [ -n "$EXCLUDEDLAYERS" ]; then
set -- -x "$EXCLUDEDLAYERS"
else
set --
fi
sed -i -e"s/^#*MACHINE *?*=.*/MACHINE ??= \"$MACHINE\"/" $BUILDDIR/conf/local.conf
sed -n -i -e "s|##COREBASE##|$OEROOT|g" -e '/^BBLAYERS /{ :start; /\\$/{n; b start}; d; }; p' $BUILDDIR/conf/bblayers.conf
echo 'BBLAYERS = "\' >> $BUILDDIR/conf/bblayers.conf
layersfile=$(mktemp setup-mel-builddir.XXXXXX)
layerpaths="*:*/*:$MELDIR/*:$MELDIR/*/*"
# Convert layer paths to layer names for bb-determine-layers
extralayernames=
for layer in $extralayers; do
if [ -d "$layer" ]; then
layerpaths="$layerpaths:$layer"
layer="$(PATH="$OEROOT/scripts:$OEROOT/bitbake/bin:$PATH" $(dirname "$0")/bb-print-layer-data 2>/dev/null "$layer" | cut -d: -f1)"
fi
extralayernames="$extralayernames $layer"
done
updatelayernames=
for layer in $updatelayers; do
if [ -d "$layer" ]; then
layer="$(PATH="$OEROOT/scripts:$OEROOT/bitbake/bin:$PATH" $(dirname "$0")/bb-print-layer-data 2>/dev/null "$layer" | cut -d: -f1)"
layerpaths="$layerpaths:$layer"
fi
updatelayernames="$updatelayernames $layer"
done
$layerdir/scripts/bb-determine-layers -g "$layerpaths" -l "core mel mel-support mentor-staging $extralayernames" -o "$EXTRAMELLAYERS $OPTIONALLAYERS" -e "$updatelayernames" "$@" $MACHINE >$layersfile
if [ $? -ne 0 ]; then
rm -f $layersfile
echo >&2 "Error in execution of bb-determine-layers, aborting"
exit 1
fi
sed 's,^, ,; s,$, \\,' <$layersfile >>$BUILDDIR/conf/bblayers.conf
rm -f $layersfile
echo '"' >> $BUILDDIR/conf/bblayers.conf
unset layersfile
}
process_arguments () {
BUILDDIR=
MELDIR=
OEROOT=
extralayers=
force_overwrite=
while getopts b:o:l:fh opt; do
case "$opt" in
b)
BUILDDIR="$(abspath $OPTARG)"
;;
o)
MELDIR="$(abspath $OPTARG)"
;;
l)
extralayers="$OPTARG"
;;
f)
force_overwrite="-f"
;;
\?|h)
usage
return 1
;;
esac
done
if [ -z $BUILDDIR ]; then
if [ -f conf/local.conf -o -f conf/bblayers.conf ]; then
# Assuming we're already in the build dir
BUILDDIR=$PWD
else
BUILDDIR=$PWD/build
fi
fi
if [ -z "$MELDIR" ]; then
MELDIR=$(dirname $layerdir)
fi
updatelayers=
for lconf in $MELDIR/update-*/conf/layer.conf $MELDIR/*/update-*/conf/layer.conf; do
updatelayer="${lconf%/conf/layer.conf}"
if [ -e "$updatelayer" ]; then
updatelayers="$updatelayers $updatelayer"
fi
done
}
setup_builddir () {
process_arguments "$@" || return $?
shift $(expr $OPTIND - 1)
if [ -e "$MELDIR/poky" ]; then
OEROOT="$MELDIR/poky"
elif [ -e "$MELDIR/oe-core" ]; then
OEROOT="$MELDIR/oe-core"
else
echo >&2 "Unable to locate poky or oe-core in $MELDIR, aborting"
return 3
fi
if [ "$force_overwrite" = "-f" ]; then
rm -f $BUILDDIR/conf/local.conf $BUILDDIR/conf/bblayers.conf
fi
TEMPLATECONF=
MACHINE=$1
if [ -n "$MACHINE" ]; then
if [ -e $MELDIR/$MACHINE/binary ]; then
# User specified machine and we have the binary content for this BSP
TEMPLATECONF=$MELDIR/$MACHINE/conf
fi
else
if [ ! -e $BUILDDIR/conf/local.conf -o ! -e $BUILDDIR/conf/bblayers.conf ]; then
tmpfile="$(mktemp -t "${0##*/}.XXXXX")"
ls -1d $MELDIR/*/binary 2>/dev/null | sed "s,^$MELDIR/,,; s,/binary$,," | \
while read machine; do
if [ ! -e "$MELDIR/$machine/conf/local.conf.sample" ]; then
continue
fi
echo "$machine"
done | prompt_choice "Select BSP to use" >$tmpfile
MACHINE="$(cat "$tmpfile")"
rm -f "$tmpfile"
if [ -z "$MACHINE" ]; then
echo >&2 "Error: no installed MEL BSP, please specify MACHINE"
return 1
else
TEMPLATECONF=$MELDIR/$MACHINE/conf
fi
fi
fi
: ${TEMPLATECONF:=$layerdir/conf}
mkdir -p $BUILDDIR/conf
if [ ! -e $BUILDDIR/conf/local.conf ]; then
cp $TEMPLATECONF/local.conf.sample $BUILDDIR/conf/local.conf
echo "You had no local.conf file. This configuration file has therefore been"
echo "created for you with some default values."
(
JOBS_FACTOR="2"
THREADS_FACTOR="3 / 2"
NCPU=`grep -c processor /proc/cpuinfo`
JOBS=`expr $NCPU \* $JOBS_FACTOR`
THREADS=`expr $NCPU \* $THREADS_FACTOR`
sed -i -e"s/^#*PARALLEL_MAKE *?*=.*/PARALLEL_MAKE ?= \"-j$JOBS\"/" $BUILDDIR/conf/local.conf
sed -i -e"s/^#*BB_NUMBER_THREADS *?*=.*/BB_NUMBER_THREADS ?= \"$THREADS\"/" $BUILDDIR/conf/local.conf
)
else
if [ -n "$MACHINE" ]; then
echo "Configuring existing local.conf for $MACHINE"
fi
fi
if [ ! -e $BUILDDIR/conf/bblayers.conf ]; then
echo "MELDIR = \"$MELDIR\"" >$BUILDDIR/conf/bblayers.conf
echo >>$BUILDDIR/conf/bblayers.conf
cat $TEMPLATECONF/bblayers.conf.sample >>$BUILDDIR/conf/bblayers.conf
echo "You had no bblayers.conf file. This configuration file has therefore been"
echo "created for you with some default values."
else
if [ -n "$MACHINE" ]; then
echo "Configuring existing bblayers.conf for $MACHINE"
fi
fi
if [ -z "$MACHINE" ]; then
MACHINE=$(sed -n 's/^MACHINE ?*= "\([^"]*\)"/\1/p' $BUILDDIR/conf/local.conf)
fi
if [ -n "$MACHINE" ]; then
if [ -e "$layerdir/pre-setup.$MACHINE" ]; then
. "$layerdir/pre-setup.$MACHINE"
fi
PATH="$OEROOT/scripts:$OEROOT/bitbake/bin:$PATH" configure_for_machine "$BUILDDIR/conf"
fi
cat >$BUILDDIR/setup-environment <<END
if [ -n "\$BASH_SOURCE" ]; then
BUILDDIR="\$(dirname "\$BASH_SOURCE")"
elif [ -n "\$ZSH_NAME" ]; then
BUILDDIR="\$(dirname "\$0")"
else
BUILDDIR="\$(pwd)"
fi
export TEMPLATECONF="$TEMPLATECONF"
. $OEROOT/oe-init-build-env \$BUILDDIR
export BB_ENV_EXTRAWHITE="\$BB_ENV_EXTRAWHITE GIT_SSL_CAINFO MGLS_LICENSE_FILE LM_LICENSE_FILE"
unset TEMPLATECONF
END
}
scriptsdir="$(cd $(dirname $0) && pwd)"
scriptsdir="$(abspath $scriptsdir)"
layerdir="${scriptsdir%/*}"
setup_builddir "$@" || exit $?
if [ -e $layerdir/../.mel-lite ]; then
MEL_DISTRO="mel-lite"
fi
MEL_DISTRO="${MEL_DISTRO:-mel}"
if [ -e $BUILDDIR/conf/local.conf ]; then
sed -i -e "s/^DISTRO.*/DISTRO = \'$MEL_DISTRO\'/" $BUILDDIR/conf/local.conf
if [ "$MEL_DISTRO" = "mel-lite" ]; then
sed -i -e 's@\(CORE_IMAGE_EXTRA_INSTALL.*\)oprofile\(.*\)@\1\2@' \
$BUILDDIR/conf/local.conf
fi
fi
Jump to Line
Something went wrong with that request. Please try again.