2017-12-09 21:51:48 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ ! $# -eq 1 ]; then
|
|
|
|
echo "usage: $0 <config>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
CFG="$1"
|
|
|
|
|
|
|
|
################################ basic setup ################################
|
|
|
|
BUILDROOT=$(pwd)
|
|
|
|
SCRIPTDIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
|
|
|
|
NUMJOBS=$(grep -e "^processor" /proc/cpuinfo | wc -l)
|
|
|
|
HOSTTUPLE=$(uname -m)-$OSTYPE
|
|
|
|
|
|
|
|
TCDIR="$BUILDROOT/$CFG/toolchain"
|
|
|
|
PKGBUILDDIR="$BUILDROOT/$CFG/build"
|
|
|
|
PKGSRCDIR="$BUILDROOT/src"
|
|
|
|
PKGDEPLOYDIR="$BUILDROOT/$CFG/deploy"
|
|
|
|
PKGLOGDIR="$BUILDROOT/$CFG/log"
|
|
|
|
PKGDOWNLOADDIR="$BUILDROOT/download"
|
|
|
|
PACKAGELIST="$BUILDROOT/$CFG/pkglist"
|
|
|
|
|
|
|
|
mkdir -p "$PKGDOWNLOADDIR" "$PKGSRCDIR" "$PKGBUILDDIR" "$PKGLOGDIR"
|
|
|
|
mkdir -p "$PKGDEPLOYDIR" "$TCDIR/bin"
|
|
|
|
|
|
|
|
export PATH="$TCDIR/bin:$PATH"
|
|
|
|
|
|
|
|
source "$SCRIPTDIR/cfg/$CFG/TOOLCHAIN"
|
|
|
|
|
|
|
|
mkdir -p "$TCDIR/$TARGET"
|
|
|
|
|
|
|
|
CMAKETCFILE="$TCDIR/toolchain.cmake"
|
|
|
|
|
|
|
|
############################# include utilities ##############################
|
|
|
|
source "$SCRIPTDIR/util/depends.sh"
|
|
|
|
source "$SCRIPTDIR/util/download.sh"
|
|
|
|
source "$SCRIPTDIR/util/pkgcmd.sh"
|
|
|
|
source "$SCRIPTDIR/util/toolchain.sh"
|
|
|
|
source "$SCRIPTDIR/util/cmake.sh"
|
|
|
|
|
|
|
|
############################## build toolchain ###############################
|
|
|
|
echo "--- resolving toolchain dependencies ---"
|
|
|
|
|
2018-01-24 21:48:10 +01:00
|
|
|
include_pkg "tcpkg" "toolchain"
|
|
|
|
dependencies | tsort | tac > "$PACKAGELIST"
|
2017-12-09 21:51:48 +01:00
|
|
|
cat "$PACKAGELIST"
|
|
|
|
|
|
|
|
echo "--- downloading toolchain files ---"
|
|
|
|
|
|
|
|
while read pkg; do
|
2018-01-24 21:48:10 +01:00
|
|
|
include_pkg "tcpkg" "$pkg"
|
|
|
|
fetch_package
|
2017-12-09 21:51:48 +01:00
|
|
|
done < "$PACKAGELIST"
|
|
|
|
|
|
|
|
echo "--- building toolchain ---"
|
|
|
|
|
|
|
|
gen_cmake_toolchain_file
|
|
|
|
|
|
|
|
while read pkg; do
|
2018-01-24 21:48:10 +01:00
|
|
|
include_pkg "tcpkg" "$pkg"
|
2018-01-25 00:09:29 +01:00
|
|
|
run_pkg_command "build" "toolchain"
|
|
|
|
run_pkg_command "deploy" "toolchain"
|
2017-12-09 21:51:48 +01:00
|
|
|
done < "$PACKAGELIST"
|
|
|
|
|
|
|
|
echo "--- backing up toolchain sysroot ---"
|
|
|
|
|
|
|
|
save_toolchain
|
|
|
|
|
|
|
|
############################### build packages ###############################
|
|
|
|
echo "--- resolving package dependencies ---"
|
|
|
|
|
2018-01-24 21:48:10 +01:00
|
|
|
include_pkg "pkg" "release-${CFG}"
|
|
|
|
dependencies | tsort | tac > "$PACKAGELIST"
|
2017-12-09 21:51:48 +01:00
|
|
|
cat "$PACKAGELIST"
|
|
|
|
|
|
|
|
echo "--- downloading package files ---"
|
|
|
|
|
|
|
|
while read pkg; do
|
2018-01-24 21:48:10 +01:00
|
|
|
include_pkg "pkg" "$pkg"
|
|
|
|
fetch_package
|
2017-12-09 21:51:48 +01:00
|
|
|
done < "$PACKAGELIST"
|
|
|
|
|
|
|
|
echo "--- building package ---"
|
|
|
|
|
|
|
|
while read pkg; do
|
2018-01-24 21:48:10 +01:00
|
|
|
include_pkg "pkg" "$pkg"
|
2017-12-09 21:51:48 +01:00
|
|
|
|
2018-01-24 21:48:10 +01:00
|
|
|
install_build_deps
|
|
|
|
|
2018-01-25 00:09:29 +01:00
|
|
|
run_pkg_command "build" "$PKGNAME"
|
|
|
|
run_pkg_command "deploy" "$PKGNAME"
|
2017-12-09 21:51:48 +01:00
|
|
|
|
|
|
|
restore_toolchain
|
|
|
|
done < "$PACKAGELIST"
|
|
|
|
|