From 30ae149529f8ce02bee49c0706d67e677e44f24c Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz (arab, vxp) Date: Dec 22 2017 18:47:27 +0000 Subject: build.sh:fail_pkg: terminate pending builds given build failure, -P, and absence of -R. etc/build.usage: clarify the consequences of parallelising builds to guide the perplexed and to confuse the people of the tribe of certainty into enlightenment (or not?) subr/ex_pkg_dispatch.subr:exp_pkg_dispatch(): moved traps. subr/ex_pkg_exec.subr:ex_pkg_exec(): forcibly pkill(1) child processes on failure. --- diff --git a/build.sh b/build.sh index 479cdce..8e1ac80 100755 --- a/build.sh +++ b/build.sh @@ -45,7 +45,10 @@ buildp_dispatch() { else ex_rtl_log_msg fail "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log:"; cat "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log"; - ex_rtl_log_msg failexit "Build failed in \`${_pkg_name}'."; + ex_rtl_log_msg fail "Build failed in \`${_pkg_name}'."; + ex_rtl_log_msg fail "Terminating pending builds..."; + pkill -P "${$}"; + exit 1; fi; ;; disabled_pkg) ex_rtl_log_msg vnfo "Skipping disabled package \`${_pkg_name}.'"; ;; skipped_pkg) ex_rtl_log_msg vnfo "Skipping finished package \`${_pkg_name}.'"; ;; diff --git a/etc/build.usage b/etc/build.usage index d314484..c9a0466 100644 --- a/etc/build.usage +++ b/etc/build.usage @@ -15,6 +15,8 @@ usage: ./build.sh [-4|6] [-a nt32|nt64] [-b debug|release] -P [jobs] Enables parallelisation at target-level, whenever applicable. The maximum count of jobs defaults to the number of logical processors on the host system. + If -R is not specified and at least one (1) package fails to build, + all remaining package builds will be forcibly aborted for convenience. -r ALL[:step,..] -r name[,..][:step,..] Restart the all packages/the specified comma-separated package(s) completely or at optionally specified comma-separated step(s). diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index fea64c8..21fa673 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -21,11 +21,6 @@ exp_pkg_dispatch() { "${_dispatch_fn}" start_pkg "${_pkg_name}" "${_tgt_name}"; (set -o errexit -o noglob; BUILD_IS_PARENT=0; ex_pkg_env "${_pkg_name}" "${_tgt_name}" "${_restart_at}"; - trap "if [ \${?} -eq 0 ]; then \ - echo \"done ${_pkg_name} ${_tgt_name}\" >&3; \ - else \ - echo \"fail ${_pkg_name} ${_tgt_name}\" >&3; \ - fi;" EXIT HUP INT TERM USR1 USR2; ex_pkg_exec "${_pkg_name}" "${_tgt_name}" "${_restart_at}" \ "${_dispatch_fn}";) 1>"${_stderrout_path}" 2>&1 3>"${_pipe_path}" & : $((${_njobs_vname}+=1)); diff --git a/subr/ex_pkg_exec.subr b/subr/ex_pkg_exec.subr index ceb9579..7629476 100644 --- a/subr/ex_pkg_exec.subr +++ b/subr/ex_pkg_exec.subr @@ -24,6 +24,12 @@ exp_pkg_exec_pre() { ex_pkg_exec() { local _pkg_name="${1}" _tgt_name="${2}" _restart_at="${3}" \ _step _step_cmd _step_cmd_pfx _step_rc; + trap "if [ \${?} -eq 0 ]; then \ + echo \"done ${_pkg_name} ${_tgt_name}\" >&3; \ + else \ + echo \"fail ${_pkg_name} ${_tgt_name}\" >&3; \ + pkill -U "${$}"; \ + fi;" EXIT HUP INT TERM USR1 USR2; exp_pkg_exec_pre "${_pkg_name}" "${_tgt_name}" "${_restart_at}"; "${_dispatch_fn}" exec_start "${_pkg_name}" "${_tgt_name}"; if ex_rtl_test_cmd "pkg_${_pkg_name}_all"; then