From 487c40f31185b5bbcf3c1f278af2fe05150ac9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Thu, 5 Mar 2020 13:43:03 +0000 Subject: subr/ex_pkg_dispatch.subr: implement *: inhibit group-group dependency expansion. etc/{build.usage,README.md}, subr/build_init.subr: updated. --- build.sh | 6 +-- etc/README.md | 12 +++--- etc/build.usage | 10 +++-- subr/build_init.subr | 103 +++++++++++++++++++++++++--------------------- subr/ex_pkg_dispatch.subr | 10 +++-- 5 files changed, 79 insertions(+), 62 deletions(-) diff --git a/build.sh b/build.sh index f34025ef..51c2a23b 100755 --- a/build.sh +++ b/build.sh @@ -100,9 +100,9 @@ build() { BUILD_DATE_START="$(rtl_date %Y-%m-%d-%H-%M-%S)"; _build_time_secs="$(rtl_date %s)"; rtl_log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}."; rtl_log_env_vars "build (global)" ${DEFAULT_LOG_ENV_VARS}; - if ! ex_pkg_dispatch "${DEFAULT_BUILD_STEPS}" "${DEFAULT_BUILD_VARS}" \ - buildp_dispatch "${BUILD_GROUPS}" "${ARG_PARALLEL:-1}" \ - "${BUILD_WORKDIR}/build.fifo" "${ARG_RESTART}" \ + if ! ex_pkg_dispatch "${DEFAULT_BUILD_STEPS}" "${DEFAULT_BUILD_VARS}" \ + buildp_dispatch "${BUILD_GROUPS}" "${BUILD_GROUPS_INHIBIT_DEPS:-0}" \ + "${ARG_PARALLEL:-1}" "${BUILD_WORKDIR}/build.fifo" "${ARG_RESTART}" \ "${ARG_RESTART_AT}" "${ARG_RESTART_RECURSIVE}" "${BUILD_WORKDIR}"; then for _pkg_name in ${EX_PKG_DISPATCH_UNKNOWN}; do rtl_log_msg fail "Error: package \`${_pkg_name}' unknown."; diff --git a/etc/README.md b/etc/README.md index 3543254a..9938ebf6 100644 --- a/etc/README.md +++ b/etc/README.md @@ -175,10 +175,10 @@ Rebuild entire build group: ## 3.1. Fault-tolerant & highly optimised 3D laser show-equipped usage screen ``` -usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]] - [-F ipv4|ipv6|offline] [-h] [-p jobs] [-P] [-r ALL|LAST] - [-r [*[*]]name[,..][:step,..]] [-R] [-v[v[v[v]]]] [--as-needed] - [--debug-minipix] [|=[ ..]] +usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]] + [-F ipv4|ipv6|offline] [-h] [-p jobs] [-P] [-r ALL|LAST] + [-r [*[*[*]]]name[,..][:step,..]] [-R] [-v[v[v[v]]]] [--as-needed] + [--debug-minipix] [[*]|=[ ..]] -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. -b debug|release Selects debug or release build; defaults to debug. @@ -202,7 +202,7 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..] -r ALL|LAST Restart all packages or the last failed package and resume build, resp. - -r [*[*]]name[,..][:step,..] + -r [*[*[*]]]name[,..][:step,..] Restart the specified comma-separated package(s) completely or at optionally specified comma-separated list of build steps. @@ -226,6 +226,8 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..] [ ..] One of: dev_packages, dist, host_deps, host_deps_rpm, host_toolchain, host_tools, minipix, native_packages, native_runtime, native_toolchain, native_tools. + + Prepend w/ `*' to inhibit group-group dependency expansion. ``` [Back to top](#table-of-contents) diff --git a/etc/build.usage b/etc/build.usage index d0b900b4..fe87b133 100644 --- a/etc/build.usage +++ b/etc/build.usage @@ -1,7 +1,7 @@ -usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]] - [-F ipv4|ipv6|offline] [-h] [-p jobs] [-P] [-r ALL|LAST] - [-r [*[*[*]]]name[,..][:step,..]] [-R] [-v[v[v[v]]]] [--as-needed] - [--debug-minipix] [|=[ ..]] +usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]] + [-F ipv4|ipv6|offline] [-h] [-p jobs] [-P] [-r ALL|LAST] + [-r [*[*[*]]]name[,..][:step,..]] [-R] [-v[v[v[v]]]] [--as-needed] + [--debug-minipix] [[*]|=[ ..]] -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. -b debug|release Selects debug or release build; defaults to debug. @@ -49,3 +49,5 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind [ ..] One of: dev_packages, dist, host_deps, host_deps_rpm, host_toolchain, host_tools, minipix, native_packages, native_runtime, native_toolchain, native_tools. + + Prepend w/ `*' to inhibit group-group dependency expansion. diff --git a/subr/build_init.subr b/subr/build_init.subr index 075affb3..95641d5d 100644 --- a/subr/build_init.subr +++ b/subr/build_init.subr @@ -53,7 +53,8 @@ buildp_init_defaults() { ARG_FETCH_FORCE=0; ARG_PARALLEL=1; ARG_RELAXED=0; ARG_RESTART=""; ARG_VERBOSE=0; # Build parameters & state - BUILD_DLCACHEDIR="";BUILD_HNAME=""; BUILD_IS_PARENT=1; BUILD_GROUPS=""; BUILD_TARGET=""; BUILD_USER=""; BUILD_WORKDIR=""; + BUILD_DLCACHEDIR=""; BUILD_HNAME=""; BUILD_IS_PARENT=1; BUILD_GROUPS=""; + BUILD_GROUPS_INHIBIT_DEPS=0; BUILD_TARGET=""; BUILD_USER=""; BUILD_WORKDIR=""; MIDIPIX_BUILD_PWD=""; PREFIX=""; PREFIX_RPM=""; # Global defaults @@ -121,7 +122,7 @@ buildp_init_files() { }; buildp_init_getopts() { - local _opt="" _rc=0 _shiftfl=0 OPTIND=0; _status=""; + local _arg="" _opt="" _rc=0 _shiftfl=0 OPTIND=0; _status=""; while [ "${#}" -gt 0 ]; do case "${1}" in --as-needed) ARG_AS_NEEDED=1; _shiftfl=1; ;; @@ -153,16 +154,60 @@ buildp_init_getopts() { done; if [ "${_rc}" -eq 0 ]; then while [ ${#} -gt 0 ]; do - case "${1}" in - *=*) rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;; - [^a-zA-Z]*) _rc=1; _status="Error: build group names must start with [a-zA-Z]."; ;; - *[^_a-zA-Z]*) _rc=1; _status="Error: build group names must not contain [^_a-zA-Z]."; ;; - *) BUILD_GROUPS="$(rtl_lconcat "${BUILD_GROUPS}" "${1}")"; + if [ "${1#\*}" != "${1}" ]; then + BUILD_GROUPS_INHIBIT_DEPS=1; _arg="${1#\*}"; + else + _arg="${1}"; + fi; + case "${_arg}" in + *=*) rtl_set_var_unsafe "${_arg%%=*}" "${_arg#*=}"; ;; + [^a-zA-Z]*) _rc=1; _status="Error: build group names must start with [a-zA-Z] (in argument \`${_arg}'.)"; ;; + *[^_a-zA-Z]*) _rc=1; _status="Error: build group names must not contain [^_a-zA-Z] (in argument \`${_arg}'.)"; ;; + *) BUILD_GROUPS="$(rtl_lconcat "${BUILD_GROUPS}" "${_arg}")"; ;; esac; shift; done; fi; return "${_rc}"; }; +buildp_init_groups() { + local _default_build_groups="" _fname="" _group="" _groups="" _rc=0; _status=""; + for _fname in $(find ./groups -name *.group | sort); do + rtl_fileop source_opt "${_fname}"; + if [ -n "${GROUP_TARGET}" ]; then + _group="${GROUP_TARGET}"; unset GROUP_TARGET; + else + _group="${_fname##*/}"; _group="${_group%.group}"; _group="${_group#*.}"; + fi; + if ! rtl_lmatch "${_groups}" "${_group}"; then + _groups="$(rtl_lconcat "${_groups}" "${_group}")"; + if [ -n "${GROUP_AUTO}" ]; then + if [ "${GROUP_AUTO:-0}" -ne 0 ]; then + _default_build_groups="$(rtl_lconcat "${_default_build_groups}" "${_group}")"; + fi; + unset GROUP_AUTO; + else + _default_build_groups="$(rtl_lconcat "${_default_build_groups}" "${_group}")"; + fi; + fi; + done; + _default_build_groups="$(rtl_uniq "${_default_build_groups}")"; + if ! rtl_lmatch "${ARG_DIST}" "rpm" ","; then + _default_build_groups="$(rtl_lfilter "${_default_build_groups}" "host_deps_rpm")"; + fi; + if [ -z "${BUILD_GROUPS}" ]; then + BUILD_GROUPS="${_default_build_groups}"; + fi; + if [ -n "${ARG_DIST}" ]; then + BUILD_GROUPS="$(rtl_lconcat "$(rtl_lfilter "${BUILD_GROUPS}" "dist")" "dist")"; + fi; + for _group in ${BUILD_GROUPS}; do + if ! rtl_lmatch "${_groups}" "${_group}"; then + _rc=1; _status="Error: unknown build group \`${_group}'."; break; + fi; + done; + return "${_rc}"; +}; + buildp_init_prereqs() { local _cmd="" _cmds_missing="" _rc=0; _status=""; for _cmd in \ @@ -186,7 +231,7 @@ buildp_init_prereqs() { }; buildp_init_vars() { - local _default_build_groups="" _fname="" _group="" _groups="" _rc=0; _status=""; + local _rc=0; _status=""; if ! rtl_lmatch "${ARCH}" "nt32 nt64"; then _rc=1; _status="Error: invalid architecture \`${ARCH}'."; elif ! rtl_lmatch "${BUILD}" "debug release"; then @@ -194,8 +239,7 @@ buildp_init_vars() { elif [ -n "${ARG_PARALLEL}" ] && [ "${ARG_PARALLEL}" != "auto" ]\ && ! rtl_isnumber "${ARG_PARALLEL}"; then _rc=1; _status="Error: invalid jobs count \`${ARG_PARALLEL}'."; - else - case "${ARCH}" in + else case "${ARCH}" in nt32) DEFAULT_TARGET="i686-nt32-midipix"; ;; nt64) DEFAULT_TARGET="x86_64-nt64-midipix"; ;; esac; @@ -211,43 +255,7 @@ buildp_init_vars() { ../midipix_build.vars ./midipix.env; if [ -z "${PREFIX}" ]; then _rc=1; _status="Error: \${PREFIX} empty or unset."; - else - for _fname in $(find ./groups -name *.group | sort); do - rtl_fileop source_opt "${_fname}"; - if [ -n "${GROUP_TARGET}" ]; then - _group="${GROUP_TARGET}"; unset GROUP_TARGET; - else - _group="${_fname##*/}"; _group="${_group%.group}"; _group="${_group#*.}"; - fi; - if ! rtl_lmatch "${_groups}" "${_group}"; then - _groups="$(rtl_lconcat "${_groups}" "${_group}")"; - if [ -n "${GROUP_AUTO}" ]; then - if [ "${GROUP_AUTO:-0}" -ne 0 ]; then - _default_build_groups="$(rtl_lconcat "${_default_build_groups}" "${_group}")"; - fi; - unset GROUP_AUTO; - else - _default_build_groups="$(rtl_lconcat "${_default_build_groups}" "${_group}")"; - fi; - fi; - done; - _default_build_groups="$(rtl_uniq "${_default_build_groups}")"; - if ! rtl_lmatch "${ARG_DIST}" "rpm" ","; then - _default_build_groups="$(rtl_lfilter "${_default_build_groups}" "host_deps_rpm")"; - fi; - if [ -z "${BUILD_GROUPS}" ]; then - BUILD_GROUPS="${_default_build_groups}"; - fi; - if [ -n "${ARG_DIST}" ]; then - BUILD_GROUPS="$(rtl_lconcat "$(rtl_lfilter "${BUILD_GROUPS}" "dist")" "dist")"; - fi; - for _group in ${BUILD_GROUPS}; do - if ! rtl_lmatch "${_groups}" "${_group}"; then - _rc=1; _status="Error: unknown build group \`${_group}'."; break; - fi; - done; - fi; - fi; + fi; fi; return "${_rc}"; }; @@ -258,6 +266,7 @@ build_init() { || ! buildp_init_getopts "${@}" \ || ! buildp_init_prereqs \ || ! buildp_init_vars \ + || ! buildp_init_groups \ || ! buildp_init_args \ || ! buildp_init_files; then _rc="${?}"; rtl_log_msg fail "${_status}"; exit "${_rc}"; diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index 5d7081c9..f0c0a2b6 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -150,6 +150,7 @@ exp_pkg_dispatch_packages() { # @_build_vars_default: list of default build variables # @_dispatch_fn: top-level dispatch function name # @_group_names: build group name(s) +# @_groups_inhibit_deps: inhibit group-group dependency expansion # @_njobs_max: maximum count of simultaneous jobs # @_pipe_path: pathname to build FIFO # @_restart: optional whitespace-separated list of package names to rebuild @@ -161,13 +162,16 @@ exp_pkg_dispatch_packages() { # ex_pkg_dispatch() { local _build_steps_default="${1}" _build_vars_default="${2}" _dispatch_fn="${3}" \ - _group_names="${4}" _njobs_max="${5}" _pipe_path="${6}" _restart="${7}" \ - _restart_at="${8}" _restart_recursive="${9}" _workdir="${10}" \ + _group_names="${4}" _groups_inhibit_deps="${5}" _njobs_max="${6}" _pipe_path="${7}" \ + _restart="${8}" _restart_at="${9}" _restart_recursive="${10}" _workdir="${11}" \ _pkg_name="" _pkg_names="" _rc=0 \ EXP_PKG_COMPLETE EXP_PKG_DISABLED EXP_PKG_FINISHED EXP_PKG_DISPATCH_COUNT \ EXP_PKG_DISPATCH_COUNT_MAX EXP_PKG_DISPATCH_NJOBS EXP_PKG_NAMES; EX_PKG_DISPATCH_WAIT=""; - for _group_name in $(rtl_uniq $(rtl_lunfold_depends '${_name}_GROUP_DEPENDS' ${_group_names})); do + if [ "${_groups_inhibit_deps:-0}" -eq 0 ]; then + _group_names="$(rtl_uniq $(rtl_lunfold_depends '${_name}_GROUP_DEPENDS' ${_group_names}))"; + fi; + for _group_name in ${_group_names}; do EXP_PKG_COMPLETE="" EXP_PKG_DISABLED="" EXP_PKG_FINISHED=""; EXP_PKG_DISPATCH_COUNT=0 EXP_PKG_DISPATCH_COUNT_MAX=0 EXP_PKG_DISPATCH_NJOBS=0; EXP_PKG_NAMES="" EX_PKG_DISPATCH_WAIT=""; -- cgit v1.2.3