summaryrefslogtreecommitdiffhomepage
path: root/subr/build_args.subr
blob: c41a16f387a968ee15b68442156ea1c716dff85f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#
# set -o noglob is assumed.
#

build_args() {
	local _opt="" _shiftfl=0;
	while [ "${#}" -gt 0 ]; do
		case "${1}" in
		--as-needed)	ARG_AS_NEEDED=1; _shiftfl=1; ;;
		--debug-minipx)	ARG_DEBUG_MINIPIX=1; _shiftfl=1; ;;
		-v*)		_opt="${1#-}"; while [ -n "${_opt}" ]; do
					: $((ARG_VERBOSE+=1)); _opt="${_opt#?}";
				done; _shiftfl=1; ;;
		*)		_shiftfl=0; ;;
		esac;
		if [ "${_shiftfl}" -gt 0 ]; then
			shift "${_shiftfl}"; continue;
		elif getopts a:b:C:D:FhPr:R _opt; then
			case "${_opt}" in
			a)	ARCH="${OPTARG}"; ;;
			b)	BUILD="${OPTARG}"; ;;	
			C)	ARG_CLEAN_BUILDS="${OPTARG}"; ;;
			D)	ARG_DIST="${OPTARG}"; ;;
			F)	ARG_FETCH_FORCE=1; ;;
			h)	cat etc/build.usage; exit 0; ;;
			P)	ARG_PARALLEL="${OPTARG:-auto}"; ;;
			r)	ARG_RESTART="${OPTARG}"; ;;
			R)	ARG_RELAXED=1; ;;
			*)	cat etc/build.usage; exit 1; ;;
			esac; shift $((${OPTIND}-1));
		else
			break;
		fi;
	done;
	if [ -n "${ARG_RESTART}" ]\
	&& [ "${ARG_RESTART#\*}" != "${ARG_RESTART}" ]; then
		ARG_RESTART="${ARG_RESTART#\*}"; ARG_RESTART_RECURSIVE=1;
	fi;
	case "${ARG_RESTART}" in
	ALL)	ARG_RESTART_AT=ALL; ;;
	LAST)	ARG_RESTART_AT=""; ;;
	"")	;;
	*:*)	ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="${ARG_RESTART%:*}"; ;;
	*)	ARG_RESTART="$(echo "${ARG_RESTART}" | sed "s/,/ /g")"; ARG_RESTART_AT=ALL; ;;
	esac;
	while [ ${#} -gt 0 ]; do
	case "${1}" in
	*=*)	ex_rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
	*)	BUILD_GROUPS="${BUILD_GROUPS:+${BUILD_GROUPS} }${1}"; ;;
	esac; shift; done;
};

# vim:filetype=sh