#!/bin/bash CWD=$(pwd) function log_error(){ echo -ne "\e[31m $1 \e[0m\n" } function usage(){ echo "Usage:" echo " MACHINE= source igkboard-setup.sh " echo "Options:" echo " machine name" echo " - igkboard-imx8mp" echo " - igkboard-imx6ull" echo " * [-b build-dir]: Build directory, if unspecified script uses 'build' as output directory" echo " * [-h]: help" echo "Examples: " echo "$ MACHINE=igkboard-imx8mp source sources/meta-igkboard/tools/igkboard-setup.sh -b igkboard-imx8mp" echo "$ MACHINE=igkboard-imx6ull source sources/meta-igkboard/tools/igkboard-setup.sh -b igkboard-imx6ull" echo } function cleanup_EULA(){ cd $CWD/sources/meta-freescale if [ -h EULA ]; then echo Cleanup meta-freescale/EULA... git checkout -- EULA fi if [ ! -f classes/fsl-eula-unpack.bbclass ]; then echo Cleanup meta-freescale/classes/fsl-eula-unpack.bbclass... git checkout -- classes/fsl-eula-unpack.bbclass fi cd - } function file_override() { source_path=$1 override_root=$2 if [ -f $source_path ]; then override_path=$override_root/`basename $source_path` if [ -f $override_path ]; then echo "\ WARNING: The file '$CWD/$source_path' is replacing the upstream file '$CWD/$override_path'. \ Overrides by file replacement are error-prone and discouraged. Please find an \ alternative override mechanism that uses meta-data only. " rm $override_path fi fi } function machine_overrides() { layer=$1 upstream_layer=$2 machines="../sources/$layer/conf/machine/*" machine_includes="../sources/$layer/conf/machine/include/*" for machine in $machines; do file_override $machine ../sources/$upstream_layer/conf/machine done for machine_include in $machine_includes; do file_override $machine_include ../sources/$upstream_layer/conf/machine/include done } function bbclass_overrides() { layer=$1 upstream_layer=$2 bbclasses="../sources/$layer/classes/*" for bbclass in $bbclasses; do file_override $bbclass ../sources/$upstream_layer/classes done } function hook_in_layer() { layer=$1 shift if [ "$1" = "" ]; then upstream_layers="meta-freescale" else upstream_layers="$@" fi # echo "BBLAYERS += \"\${BSPDIR}/sources/$layer\"" >> conf/bblayers.conf for upstream_layer in $upstream_layers; do machine_overrides $layer $upstream_layer bbclass_overrides $layer $upstream_layer done } function igkboard_conf_set(){ local build_dir=$1 cp $CWD/sources/meta-igkboard/conf/${MACHINE}_local.conf $CWD/${build_dir}/conf/local.conf cp $CWD/sources/meta-igkboard/conf/bblayers.conf $CWD/${build_dir}/conf/bblayers.conf } function run(){ local build_dir=$1 local oeroot=$CWD/sources/poky if [ -e $CWD/sources/oe-core ]; then oeroot=$CWD/sources/oe-core fi . $oeroot/oe-init-build-env $CWD/$build_dir > /dev/null if [ ! -e conf/local.conf ]; then log_error "oe-init-build-env does not generated." exit -1 fi igkboard_conf_set $build_dir # 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/:.\?$//'`" cat <' Common targets are: yocto-image-full core-image-minimal imx-image-full EOF hook_in_layer meta-imx/meta-bsp hook_in_layer meta-imx/meta-sdk hook_in_layer meta-nxp-demo-experience } function start(){ if [ "$(whoami)" = "root" ]; then echo "ERROR: do not use the BSP as root. Exiting..." exit -1 fi local BUILD_DIR; local OLD_OPTIND=$OPTIND while getopts "b:h" fsl_setup_flag do case $fsl_setup_flag in b) BUILD_DIR="$OPTARG"; echo -e "\n Build directory is " $BUILD_DIR ;; h) usage exit -1 ;; \?) usage exit -1;; esac done shift $((OPTIND-1)) OPTIND=$OLD_OPTIND if [ -z "$BUILD_DIR" ]; then BUILD_DIR='build' fi if [ -z "$MACHINE" ]; then echo setting to default machine MACHINE='igkboard-imx8mp' fi cleanup_EULA; mkdir -p $BUILD_DIR run $BUILD_DIR } start $@