summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2018-12-03 21:11:32 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2018-12-06 17:46:44 +0100
commita0b8075391cfeb324f60e42482b1c34f95d1de71 (patch)
tree405cf09eee6d109b7a25dea6cc64ef4432e4e87a /scripts
parent51a507e477a28a508af081e1bf6352b3f6c60fc2 (diff)
downloadptxdist-a0b8075391cfeb324f60e42482b1c34f95d1de71.tar.gz
ptxdist-a0b8075391cfeb324f60e42482b1c34f95d1de71.tar.xz
ptxdist: add --progress option
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/ptxd_make_progress.sh43
-rw-r--r--scripts/libptxdist.sh1
2 files changed, 44 insertions, 0 deletions
diff --git a/scripts/lib/ptxd_make_progress.sh b/scripts/lib/ptxd_make_progress.sh
new file mode 100644
index 000000000..ebcc24945
--- /dev/null
+++ b/scripts/lib/ptxd_make_progress.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Copyright (C) 2018 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+ptxd_make_setup_progress() {
+ if [ -n "${PTXDIST_PROGRESS}" ]; then
+ ptxd_make_target_count=$( \
+ "${PTXCONF_SETUP_HOST_MAKE}" --dry-run \
+ -f "${RULESDIR}/other/Toplevel.make" "${@}" 2>/dev/null | \
+ grep -E '^target=.*\.(get|extract|prepare|compile|install|targetinstall|report).* touch' | \
+ wc -l)
+ export ptxd_make_target_count
+ exec {ptxd_make_target_count_start}>> "${PTXDIST_TEMPDIR}/ptxd_make_target_count_start"
+ exec {ptxd_make_target_count_stop}>> "${PTXDIST_TEMPDIR}/ptxd_make_target_count_stop"
+ export ptxd_make_target_count_start ptxd_make_target_count_stop
+ :> "${PTXDIST_TEMPDIR}/ptxd_make_target_count"
+ fi
+}
+
+ptxd_make_print_progress() {
+ if [ -n "${ptxd_make_target_count}" ]; then
+ local start stop len
+ if [[ "${2}" =~ .*\.(get|extract|prepare|compile|install|targetinstall|report).* ]]; then
+ local ptr="ptxd_make_target_count_${1}"
+ echo -n + >&${!ptr}
+ if [ "${2}" = "world.targetinstall" ]; then
+ # world.targetinstall has no 'targetinfo'
+ echo -n + >&${ptxd_make_target_count_start}
+ fi
+ fi
+ start=$(wc -c < "${PTXDIST_TEMPDIR}/ptxd_make_target_count_start")
+ stop=$(wc -c < "${PTXDIST_TEMPDIR}/ptxd_make_target_count_stop")
+ len="$(wc -c <<<${ptxd_make_target_count})"
+ printf "[%$[len-1]d/%d] " "${stop}" "${ptxd_make_target_count}"
+ fi
+}
+export -f ptxd_make_print_progress
diff --git a/scripts/libptxdist.sh b/scripts/libptxdist.sh
index e386137a1..17441e9db 100644
--- a/scripts/libptxdist.sh
+++ b/scripts/libptxdist.sh
@@ -166,6 +166,7 @@ ptxd_make() {
source "${lib}" || ptxd_bailout "failed to source lib: ${lib}"
done
done
+ ptxd_make_setup_progress "${@}" &&
${PTX_NICE:+nice -n ${PTX_NICE}} "${PTXCONF_SETUP_HOST_MAKE}" \
"${PTX_MAKE_ARGS[@]}" ${PTXDIST_PARALLELMFLAGS_EXTERN} ${PTXDIST_LOADMFLAGS} \
-f "${RULESDIR}/other/Toplevel.make" "${@}" || return