2017-12-09 21:51:48 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-02-20 21:30:34 +01:00
|
|
|
if [ ! $# -eq 2 ]; then
|
|
|
|
echo "usage: $0 <board> <product>"
|
2017-12-09 21:51:48 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-02-09 18:06:16 +01:00
|
|
|
BOARD="$1"
|
2018-02-20 21:30:34 +01:00
|
|
|
PRODUCT="$2"
|
2017-12-09 21:51:48 +01:00
|
|
|
|
|
|
|
################################ basic setup ################################
|
|
|
|
BUILDROOT=$(pwd)
|
|
|
|
SCRIPTDIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
|
|
|
|
NUMJOBS=$(grep -e "^processor" /proc/cpuinfo | wc -l)
|
2018-03-24 17:07:47 +01:00
|
|
|
HOSTTUPLE=$($SCRIPTDIR/util/config.guess)
|
2017-12-09 21:51:48 +01:00
|
|
|
|
2018-02-20 21:30:34 +01:00
|
|
|
if [ ! -d "$SCRIPTDIR/product/$PRODUCT" ]; then
|
|
|
|
echo "No configuration for this product: $PRODUCT"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$SCRIPTDIR/board/$BOARD" ]; then
|
|
|
|
echo "No configuration for this board: $BOARD"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e "$SCRIPTDIR/product/$PRODUCT/BOARDS" ]; then
|
|
|
|
if ! grep -q "$BOARD" "$SCRIPTDIR/product/$PRODUCT/BOARDS"; then
|
|
|
|
echo "Error, $PRODUCT cannot be built for $BOARD"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
TCDIR="$BUILDROOT/${BOARD}-${PRODUCT}/toolchain"
|
|
|
|
PKGBUILDDIR="$BUILDROOT/${BOARD}-${PRODUCT}/build"
|
2017-12-09 21:51:48 +01:00
|
|
|
PKGSRCDIR="$BUILDROOT/src"
|
2018-02-20 21:30:34 +01:00
|
|
|
PKGDEPLOYDIR="$BUILDROOT/${BOARD}-${PRODUCT}/deploy"
|
|
|
|
PKGLOGDIR="$BUILDROOT/${BOARD}-${PRODUCT}/log"
|
2017-12-09 21:51:48 +01:00
|
|
|
PKGDOWNLOADDIR="$BUILDROOT/download"
|
2018-02-20 21:30:34 +01:00
|
|
|
PACKAGELIST="$BUILDROOT/${BOARD}-${PRODUCT}/pkglist"
|
2017-12-09 21:51:48 +01:00
|
|
|
|
2018-02-16 18:45:25 +01:00
|
|
|
mkdir -p "$PKGDOWNLOADDIR" "$PKGSRCDIR" "$PKGLOGDIR"
|
2018-06-17 13:28:18 +02:00
|
|
|
mkdir -p "$PKGDEPLOYDIR" "$TCDIR/bin"
|
2017-12-09 21:51:48 +01:00
|
|
|
|
|
|
|
export PATH="$TCDIR/bin:$PATH"
|
|
|
|
|
2018-02-14 13:07:23 +01:00
|
|
|
pushd "$SCRIPTDIR" > /dev/null
|
|
|
|
OS_NAME="Pygos"
|
2018-02-15 12:17:22 +01:00
|
|
|
OS_RELEASE=$(git describe --always --tags --dirty)
|
2018-02-14 13:07:23 +01:00
|
|
|
popd > /dev/null
|
|
|
|
|
2017-12-09 21:51:48 +01:00
|
|
|
############################# include utilities ##############################
|
|
|
|
source "$SCRIPTDIR/util/depends.sh"
|
|
|
|
source "$SCRIPTDIR/util/download.sh"
|
|
|
|
source "$SCRIPTDIR/util/pkgcmd.sh"
|
|
|
|
source "$SCRIPTDIR/util/toolchain.sh"
|
2018-02-09 18:49:17 +01:00
|
|
|
source "$SCRIPTDIR/util/misc.sh"
|
2018-05-10 14:42:43 +02:00
|
|
|
source "$SCRIPTDIR/util/override.sh"
|
2018-09-02 14:19:23 +02:00
|
|
|
source "$SCRIPTDIR/util/autotools.sh"
|
2017-12-09 21:51:48 +01:00
|
|
|
|
2018-05-10 14:41:13 +02:00
|
|
|
############################## toolchain config ##############################
|
|
|
|
include_merge "TOOLCHAIN"
|
|
|
|
|
|
|
|
mkdir -p "$TCDIR/$TARGET"
|
|
|
|
|
|
|
|
CMAKETCFILE="$TCDIR/toolchain.cmake"
|
|
|
|
|
2017-12-09 21:51:48 +01:00
|
|
|
############################### build packages ###############################
|
|
|
|
echo "--- resolving package dependencies ---"
|
|
|
|
|
2018-02-15 23:47:54 +01:00
|
|
|
include_pkg "release-${BOARD}"
|
2018-01-24 21:48:10 +01:00
|
|
|
dependencies | tsort | tac > "$PACKAGELIST"
|
2017-12-09 21:51:48 +01:00
|
|
|
cat "$PACKAGELIST"
|
|
|
|
|
|
|
|
echo "--- downloading package files ---"
|
|
|
|
|
|
|
|
while read pkg; do
|
2018-02-15 23:47:54 +01:00
|
|
|
include_pkg "$pkg"
|
2018-01-24 21:48:10 +01:00
|
|
|
fetch_package
|
2017-12-09 21:51:48 +01:00
|
|
|
done < "$PACKAGELIST"
|
|
|
|
|
2018-02-19 12:43:22 +01:00
|
|
|
echo "--- building packages ---"
|
2017-12-09 21:51:48 +01:00
|
|
|
|
|
|
|
while read pkg; do
|
2018-02-18 17:46:06 +01:00
|
|
|
if [ ! -e "$PKGLOGDIR/.$pkg" ]; then
|
|
|
|
include_pkg "$pkg"
|
|
|
|
install_build_deps
|
|
|
|
run_pkg_command "build"
|
|
|
|
run_pkg_command "deploy"
|
2018-06-17 13:28:18 +02:00
|
|
|
deploy_dev_cleanup "$PKGDEPLOYDIR/$PKGNAME"
|
2018-06-17 16:08:11 +02:00
|
|
|
strip_files ${PKGDEPLOYDIR}/${PKGNAME}/{bin,lib}
|
2018-02-18 17:46:06 +01:00
|
|
|
restore_toolchain
|
2017-12-09 21:51:48 +01:00
|
|
|
|
2018-02-19 12:43:22 +01:00
|
|
|
rm -rf "$PKGBUILDDIR"
|
2018-02-18 17:46:06 +01:00
|
|
|
touch "$PKGLOGDIR/.$pkg"
|
|
|
|
fi
|
2017-12-09 21:51:48 +01:00
|
|
|
done < "$PACKAGELIST"
|
|
|
|
|
2018-02-19 12:43:22 +01:00
|
|
|
echo "--- done ---"
|
|
|
|
|