midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/build_args.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
#
Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
# set -o noglob is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
#
Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
Lucio Andrés Illanes Albornoz 03dd23
BUILD_ARGS_SPEC="
Lucio Andrés Illanes Albornoz 03dd23
	ARCH:arg:-a:
Lucio Andrés Illanes Albornoz 03dd23
	ARG_AS_NEEDED:--as-needed:
Lucio Andrés Illanes Albornoz 03dd23
	ARG_CLEAN_BUILDS:arg:-C:
Lucio Andrés Illanes Albornoz 03dd23
	ARG_DEBUG_MINIPIX:--debug-minipix:
Lucio Andrés Illanes Albornoz 03dd23
	ARG_DIST:arg:-D:
Lucio Andrés Illanes Albornoz 03dd23
	ARG_FETCH_FORCE:-F:
Lucio Andrés Illanes Albornoz 03dd23
	ARG_PARALLEL:optarg:-P:auto
Lucio Andrés Illanes Albornoz 03dd23
	ARG_RELAXED:-R:
Lucio Andrés Illanes Albornoz 03dd23
	ARG_RESTART:arg:-r:
Lucio Andrés Illanes Albornoz 03dd23
	ARG_VERBOSE:selfarg:-v:
Lucio Andrés Illanes Albornoz 03dd23
	ARG_VERBOSE:selfarg:-vv:
Lucio Andrés Illanes Albornoz 03dd23
	ARG_VERBOSE:selfarg:-vvv:
Lucio Andrés Illanes Albornoz 03dd23
	ARG_VERBOSE:selfarg:-vvvv:
Lucio Andrés Illanes Albornoz 03dd23
	BUILD:arg:-b:";
Lucio Andrés Illanes Albornoz 03dd23
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
build_args() {
Lucio Andrés Illanes Albornoz 03dd23
	local _spec="${BUILD_ARGS_SPEC}" _spec_arg="" _found="";
Lucio Andrés Illanes Albornoz 03dd23
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz 03dd23
		if [ "${1#-}" = "${1}" ]; then
Lucio Andrés Illanes Albornoz 03dd23
			break;
Lucio Andrés Illanes Albornoz 03dd23
		fi;
Lucio Andrés Illanes Albornoz 03dd23
		for _spec_arg in ${_spec}; do
Lucio Andrés Illanes Albornoz 03dd23
			case "${_spec_arg}" in
Lucio Andrés Illanes Albornoz 03dd23
			*:${1}:*)
Lucio Andrés Illanes Albornoz 03dd23
				case "${_spec_arg#*:}" in
Lucio Andrés Illanes Albornoz 03dd23
				arg:*)
Lucio Andrés Illanes Albornoz 03dd23
					ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;;
Lucio Andrés Illanes Albornoz 03dd23
				optarg:*)
Lucio Andrés Illanes Albornoz 03dd23
					if [ -n "${2}" ]\
Lucio Andrés Illanes Albornoz 03dd23
					&& [ "x${2#-}" = "x${2}" ]; then
Lucio Andrés Illanes Albornoz 03dd23
						ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${2}";
Lucio Andrés Illanes Albornoz 03dd23
						shift;
Lucio Andrés Illanes Albornoz 03dd23
					else
Lucio Andrés Illanes Albornoz 03dd23
						ex_rtl_set_var_unsafe "${_spec_arg%%:*}"	\
Lucio Andrés Illanes Albornoz 03dd23
							"${_spec_arg##*:}";
Lucio Andrés Illanes Albornoz 03dd23
					fi; ;;
Lucio Andrés Illanes Albornoz 03dd23
				selfarg:*)
Lucio Andrés Illanes Albornoz 03dd23
					ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;;
Lucio Andrés Illanes Albornoz 03dd23
				*)
Lucio Andrés Illanes Albornoz 03dd23
					ex_rtl_set_var_unsafe "${_spec_arg%%:*}" 1; ;;
Lucio Andrés Illanes Albornoz 03dd23
				esac; _found=1; break; ;;
Lucio Andrés Illanes Albornoz 03dd23
			*)	_found=0; ;;
Lucio Andrés Illanes Albornoz 03dd23
			esac;
Lucio Andrés Illanes Albornoz 03dd23
		done;
Lucio Andrés Illanes Albornoz 03dd23
		if [ "${_found:-0}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz 03dd23
			exec cat etc/build.usage;
Lucio Andrés Illanes Albornoz 03dd23
		else
Lucio Andrés Illanes Albornoz 03dd23
			shift;
Lucio Andrés Illanes Albornoz 03dd23
		fi;
Lucio Andrés Illanes Albornoz 03dd23
	done;
Lucio Andrés Illanes Albornoz 8c791c
	if ex_rtl_lmatch "${ARG_DIST}" , zipdist\
Lucio Andrés Illanes Albornoz 8c791c
	&& ! ex_rtl_lmatch "${ARG_DIST}" , minipix; then
Lucio Andrés Illanes Albornoz 8c791c
		ARG_DIST="${ARG_DIST:+${ARG_DIST},}minipix";
Lucio Andrés Illanes Albornoz 8c791c
	fi;
Lucio Andrés Illanes Albornoz 8c791c
	if [ -n "${ARG_RESTART}" ]\
Lucio Andrés Illanes Albornoz 8c791c
	&& [ "${ARG_RESTART#\*}" != "${ARG_RESTART}" ]; then
Lucio Andrés Illanes Albornoz 8c791c
		ARG_RESTART="${ARG_RESTART#\*}"; ARG_RESTART_RECURSIVE=1;
Lucio Andrés Illanes Albornoz f84af6
	fi;
Lucio Andrés Illanes Albornoz cc86a5
	case "${ARG_RESTART}" in
Lucio Andrés Illanes Albornoz cc86a5
	ALL)	ARG_RESTART_AT=ALL; ;;
Lucio Andrés Illanes Albornoz cc86a5
	LAST)	ARG_RESTART_AT=""; ;;
Lucio Andrés Illanes Albornoz cc86a5
	"")	;;
Lucio Andrés Illanes Albornoz cc86a5
	*)	if [ "${ARG_RESTART%:*}" != "${ARG_RESTART}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="${ARG_RESTART%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		else
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			ARG_RESTART_AT=ALL;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
		ARG_RESTART="$(echo "${ARG_RESTART}" | sed "s/,/ /g")";
Lucio Andrés Illanes Albornoz cc86a5
		;;
Lucio Andrés Illanes Albornoz cc86a5
	esac;
Lucio Andrés Illanes Albornoz 03dd23
	case "${ARG_VERBOSE}" in
Lucio Andrés Illanes Albornoz 03dd23
	-v)	ARG_VERBOSE=1; ;;
Lucio Andrés Illanes Albornoz 03dd23
	-vv)	ARG_VERBOSE=2; ;;
Lucio Andrés Illanes Albornoz 03dd23
	-vvv)	ARG_VERBOSE=3; ;;
Lucio Andrés Illanes Albornoz 03dd23
	-vvvv)	ARG_VERBOSE=4; ;;
Lucio Andrés Illanes Albornoz 03dd23
	esac;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	case "${1}" in
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	*=*)	ex_rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
Lucio Andrés Illanes Albornoz b96c60
	*)	BUILD_GROUPS="${BUILD_GROUPS:+${BUILD_GROUPS} }${1}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	esac; shift; done;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
};
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
# vim:filetype=sh