From 91e186b7e263e83f8512097386f903a06e8d3531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Tue, 24 Sep 2019 14:58:10 +0200 Subject: [PATCH] fine logging including make output --- build/usr/local/bin/autodoc | 1 + build/usr/local/lib/autodoc/handle_inotify | 8 ++++---- build/usr/local/lib/autodoc/logging | 12 ++++++++++++ build/usr/local/lib/autodoc/plugins/make.sh | 14 +++++++++----- 4 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 build/usr/local/lib/autodoc/logging diff --git a/build/usr/local/bin/autodoc b/build/usr/local/bin/autodoc index a9a33f2..6c92403 100755 --- a/build/usr/local/bin/autodoc +++ b/build/usr/local/bin/autodoc @@ -14,6 +14,7 @@ declare -A g_build_systems_glob # source "${g_lib}/globals" +source "${g_lib}/logging" source "${g_lib}/plugins/"*".sh" source "${g_lib}/handle_inotify" diff --git a/build/usr/local/lib/autodoc/handle_inotify b/build/usr/local/lib/autodoc/handle_inotify index 6429c36..63e7f94 100644 --- a/build/usr/local/lib/autodoc/handle_inotify +++ b/build/usr/local/lib/autodoc/handle_inotify @@ -15,8 +15,9 @@ do_handle() { # $FLAGS $OBJECT fi # start using toolchain - echo -n "'${object}': '${flags}' in '${dir}'. " + logline_append "'${object}': '${flags}' in '${dir}'." do_compile "${dir}" "${object}" + logline_flush } # compile an OBJECT using build instructions found in DIRectory @@ -39,7 +40,7 @@ do_compile() { # $DIR $OBJECT $DONE elif [ "${done}" == "0" ]; then # hit $g_watchroot - echo "No build instructions found!" + logline_append "Not a source file." fi } @@ -60,10 +61,9 @@ do_build_system() { # $DIR $OBJECT $BUILD_SYSTEM # check file readability if [ -r "${file}" ]; then # actually call into build system - echo -n "Found '${file}': " + logline_append "Found '${file}':" do_${build_system} "${dir}" "${object}" "$(basename "${file}")" \ && local result=0 - echo "" fi done done diff --git a/build/usr/local/lib/autodoc/logging b/build/usr/local/lib/autodoc/logging new file mode 100644 index 0000000..802d576 --- /dev/null +++ b/build/usr/local/lib/autodoc/logging @@ -0,0 +1,12 @@ +#!/bin/bash + +g_logline="" + +logline_append() { # $STRING + g_logline="${g_logline}${1} " +} + +logline_flush() { + echo "${g_logline}" + g_logline="" +} diff --git a/build/usr/local/lib/autodoc/plugins/make.sh b/build/usr/local/lib/autodoc/plugins/make.sh index 5eaff77..6ee1ef8 100644 --- a/build/usr/local/lib/autodoc/plugins/make.sh +++ b/build/usr/local/lib/autodoc/plugins/make.sh @@ -17,7 +17,7 @@ do_make() { # $DIR $OBJECT $MAKEFILE local srcpat="$(grep -E "^#%SRCPAT%" "${dir}/${makefile}" | tail -n 1 | sed -r "s/^#%SRCPAT%\s+//")" if [ -z "${srcpat}" ]; then - echo -n "Empty source pattern, check '#%SRCPAT%' annotation! " + logline_append "Empty source pattern, check '#%SRCPAT%' annotation!" return 1 elif [[ "${object}" =~ ${srcpat} ]]; then @@ -25,15 +25,19 @@ do_make() { # $DIR $OBJECT $MAKEFILE local target="$(grep -E "^autodoc:" "${dir}/${makefile}" | sed -r "s/:.*$//")" if [ -z "${target}" ]; then - echo "Running 'make'. " + logline_append "Running 'make'!" else - echo "Making '${target}'. " + logline_append "Making '${target}'!" fi - make --no-print-directory -C "${dir}" -f "${makefile}" -j ${target} + # actually run "make" and save (truncated) output + local makelog="$(make --no-print-directory -C "${dir}" -f "${makefile}" -j ${target})" + logline_append "$(echo "${makelog}" | head -n 10 | sed 's/$/;/g' | tr '\n' ' ' | sed 's/ *$//')" + + logline_append "Done." else - echo -n "SRCPAT '${srcpat}' mismatch. " + logline_append "SRCPAT '${srcpat}' mismatch." return 1 fi