From cbc8e0b7ea70c0e118b51ac479a08eb95a9779ca Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz (arab, vxp) Date: Dec 05 2017 21:19:54 +0000 Subject: etc/build.usage: adds -P [jobs]. subr/build_args.subr: adds `optarg' arg type & ARG_PARALLEL:optarg:-P:auto. subr/build_init.subr: default ${ARG_PARALLEL} ([jobs]) to ${DEFAULT_BUILD_CPUS}. subr/ex_pkg_dispatch.subr: honour ${ARG_PARALLEL}, defaulting to no parallelisation. --- diff --git a/etc/build.usage b/etc/build.usage index e28a5b6..3267d2a 100644 --- a/etc/build.usage +++ b/etc/build.usage @@ -1,15 +1,19 @@ -usage: ./build.sh [-4|6] [-a nt32|nt64] [-b debug|release] - [-c] [-h] [-N] [-r ALL[:step,..]] [-r name[,..][:step,..]] - [-R] [-t[.gz|.bz2|.xz] [-v[v[v]]] [-x] [[ ..]] +usage: ./build.sh [-4|6] [-a nt32|nt64] [-b debug|release] + [-c] [-h] [-N] [-P [jobs]] [-r ALL[:step,..]] + [-r name[,..][:step,..]] [-R] [-t[.gz|.bz2|.xz] + [-v[v[v]]] [-x] [[ ..]] -4|-6 Force IPv[46] when downloading files. -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. -b debug|release Selects debug or release build; defaults to debug. -c Clean ${PREFIX} before processing build scripts. -h Show this screen. -N Offline mode: no {wget,git-{clone,pull}}(1) calls. + -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. -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). + completely or at optionally specified comma-separated step(s). Currently defined steps are: fetch_wget, fetch_git, fetch_extract, configure_patch_pre, configure_autotools, configure_patch, diff --git a/subr/build_args.subr b/subr/build_args.subr index 2175665..8bf668a 100644 --- a/subr/build_args.subr +++ b/subr/build_args.subr @@ -3,23 +3,24 @@ # BUILD_ARGS_SPEC=" - ARG_IPV4_ONLY:-4 - ARG_IPV6_ONLY:-6 - ARCH:arg:-a - BUILD:arg:-b - ARG_CLEAN:-c - ARG_DEBUG_MINIPIX:--debug-minipix - ARG_OFFLINE:-N - ARG_RELAXED:-R - ARG_RESTART:arg:-r - ARG_TARBALL:selfarg:-t - ARG_TARBALL:selfarg:-t.bz2 - ARG_TARBALL:selfarg:-t.gz - ARG_TARBALL:selfarg:-t.xz - ARG_VERBOSE:selfarg:-v - ARG_VERBOSE:selfarg:-vv - ARG_VERBOSE:selfarg:-vvv - ARG_XTRACE:-x"; + ARG_IPV4_ONLY:-4: + ARG_IPV6_ONLY:-6: + ARCH:arg:-a: + BUILD:arg:-b: + ARG_CLEAN:-c: + ARG_DEBUG_MINIPIX:--debug-minipix: + ARG_OFFLINE:-N: + ARG_PARALLEL:optarg:-P:auto + ARG_RELAXED:-R: + ARG_RESTART:arg:-r: + ARG_TARBALL:selfarg:-t: + ARG_TARBALL:selfarg:-t.bz2; + ARG_TARBALL:selfarg:-t.gz: + ARG_TARBALL:selfarg:-t.xz: + ARG_VERBOSE:selfarg:-v: + ARG_VERBOSE:selfarg:-vv: + ARG_VERBOSE:selfarg:-vvv: + ARG_XTRACE:-x:"; build_args() { local _spec="${BUILD_ARGS_SPEC}" _spec_arg _found; @@ -29,9 +30,19 @@ build_args() { fi; for _spec_arg in ${_spec}; do case "${_spec_arg}" in - *:${1}) case "${_spec_arg#*:}" in + *:${1}:*) + case "${_spec_arg#*:}" in arg:*) ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;; + optarg:*) + if [ -n "${2}" ]\ + && [ "x${2#-}" = "x${2}" ]; then + ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${2}"; + shift; + else + ex_rtl_set_var_unsafe "${_spec_arg%%:*}" \ + "${_spec_arg##*:}"; + fi; ;; selfarg:*) ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;; *) diff --git a/subr/build_init.subr b/subr/build_init.subr index 95ac397..8b3e618 100644 --- a/subr/build_init.subr +++ b/subr/build_init.subr @@ -15,6 +15,9 @@ build_init() { && [ -e /proc/cpuinfo ]; then DEFAULT_BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo); fi; + if [ "${ARG_PARALLEL}" = auto ]; then + ARG_PARALLEL="${DEFAULT_BUILD_CPUS}"; + fi; : ${ARCH:=nt64}; : ${BUILD:=debug}; if [ "${ARCH}" = nt32 ]; then DEFAULT_TARGET="i686-nt32-midipix"; diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index f56146b..92890ba 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -46,7 +46,8 @@ ex_pkg_dispatch() { && [ "${_restart}" != ALL ]; then _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_restart}")"; fi; - if [ "$(ex_rtl_get_var_unsafe ${_tgt_name_uc}_PARALLELISE)" = 1 ]; then + if [ "$(ex_rtl_get_var_unsafe ${_tgt_name_uc}_PARALLELISE)" = 1 ]\ + && [ "${ARG_PARALLEL:-0}" -gt 1 ]; then _njobs_max="${DEFAULT_BUILD_CPUS}"; else _njobs_max=1;