build.sh: automatically detect available targets and build them all

This commit is contained in:
Daniel Frank 2019-08-16 22:44:43 +02:00
parent bc82d9d6b7
commit 9eadb86c82
Signed by: tokudan
GPG key ID: 063CCCAD04182D32

View file

@ -8,6 +8,7 @@ function usage () {
echo "Usage: $0 -g GLUON_PATH" >&2 echo "Usage: $0 -g GLUON_PATH" >&2
echo " -g GLUON_PATH Path to a checkout of the gluon repository." >&2 echo " -g GLUON_PATH Path to a checkout of the gluon repository." >&2
echo " -t TARGETS Comma separated list of gluon targets to build" >&2 echo " -t TARGETS Comma separated list of gluon targets to build" >&2
echo " -a Automatically detect and build all targets." >&2
echo " -o OUT_PATH Path to the firmware output directory. Default: ${gluon_out}" >&2 echo " -o OUT_PATH Path to the firmware output directory. Default: ${gluon_out}" >&2
echo " -s SIGNATURE Sign firmware with signature" >&2 echo " -s SIGNATURE Sign firmware with signature" >&2
echo " -b BROKEN=1" >&2 echo " -b BROKEN=1" >&2
@ -20,6 +21,9 @@ gluon_out="${HOME}/firmware"
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
-a)
auto_targets=1
;;
-g) -g)
gluon_path="$2" gluon_path="$2"
shift shift
@ -72,15 +76,20 @@ pushd "$site_path"
[ "${GLUON_BRANCH}" = "experimental" ] && GLUON_RELEASE="${GLUON_RELEASE}~exp$(date +%Y%m%d)" [ "${GLUON_BRANCH}" = "experimental" ] && GLUON_RELEASE="${GLUON_RELEASE}~exp$(date +%Y%m%d)"
export GLUON_RELEASE export GLUON_RELEASE
export GLUON_BRANCH export GLUON_BRANCH
export GLUON_SITEDIR="${site_path}"
export GLUON_OUTPUTDIR="${gluon_out}/${GLUON_RELEASE}/${GLUON_BRANCH}"
pushd "${gluon_path}"
if [ "$auto_targets" = "1" ]; then
# detect available targets
targets="$(make | awk '$1 == "*" {print $2}' | sort | xargs)"
else
# if a list of build targets has been supplied, only build those # if a list of build targets has been supplied, only build those
targets="$(echo "${build_targets:-$targets}" | sed -e 's_,_ _g')" targets="$(echo "${build_targets:-$targets}" | sed -e 's_,_ _g')"
fi
announce "The following targets will be generated: $targets" >&2 announce "The following targets will be generated: $targets" >&2
popd popd
pushd "${gluon_path}"
announce Starting make update... announce Starting make update...
export GLUON_SITEDIR="${site_path}"
export GLUON_OUTPUTDIR="${gluon_out}/${GLUON_RELEASE}/${GLUON_BRANCH}"
rm -rf "${GLUON_OUTPUTDIR}" rm -rf "${GLUON_OUTPUTDIR}"
mkdir -p "${GLUON_OUTPUTDIR}" mkdir -p "${GLUON_OUTPUTDIR}"
make update make update