Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/build_init.subr

Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
build_fini() {
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	: $((BUILD_TIMES_SECS=$(ex_rtl_date %s)-${BUILD_TIMES_SECS}));
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	: $((BUILD_TIMES_HOURS=${BUILD_TIMES_SECS}/3600));
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	: $((BUILD_TIMES_MINUTES=(${BUILD_TIMES_SECS}%3600)/60));
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	: $((BUILD_TIMES_SECS=(${BUILD_TIMES_SECS}%3600)%60));
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if [ -f "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ex_rtl_fileop rm ${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
build_init() {
Lucio Andrés Illanes Albornoz 907bd3
	local __="" _env_vars="" _env_vars_except="" _env_var="";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	set -o noglob;
Lucio Andrés Illanes Albornoz (arab, vxp) d01c02
	if [ -z "${DEFAULT_BUILD_CPUS}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) e2fea1
	&& [ -e /proc/cpuinfo ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d01c02
		DEFAULT_BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo);
Lucio Andrés Illanes Albornoz (arab, vxp) e2fea1
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	if [ "${ARG_PARALLEL}" = auto ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
		ARG_PARALLEL="${DEFAULT_BUILD_CPUS}";
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
	: ${ARCH:=nt64}; : ${BUILD:=debug};
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
	if [ "${ARCH}" = nt32 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		DEFAULT_TARGET="i686-nt32-midipix";
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
	elif [ "${ARCH}" = nt64 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		DEFAULT_TARGET="x86_64-nt64-midipix";
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
	else
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
		if [ "${BUILD}" != debug ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
		&& [ "${BUILD}" != release ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			ex_rtl_log_msg failexit "Error: unknown build type \`${BUILD}'.";
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ex_rtl_log_msg failexit "Error: invalid architecture \`${ARCH}'.";
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	for __ in ${HOME}/midipix_build.vars ../midipix_build.vars ./vars/env.vars ./vars/midipix.vars ./vars/build.vars; do
Lucio Andrés Illanes Albornoz (arab, vxp) e2fea1
		[ -e ${__} ] && . ${__};
Lucio Andrés Illanes Albornoz (arab, vxp) e2fea1
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 9ad97c
	if [ "${ARG_AS_NEEDED:-0}" -eq 1 ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 9ad97c
	&& [ -e "${PREFIX}/build.gitref" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 9ad97c
	&& [ "$(git rev-parse HEAD)" = "$(cat "${PREFIX}/build.gitref")" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 9ad97c
		ex_rtl_log_msg info "Git repository has not changed since last build and --as-needed was specified.";
Lucio Andrés Illanes Albornoz (arab, vxp) 9ad97c
		exit 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 9ad97c
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
	export PATH="${PREFIX}/bin${PATH:+:${PATH}}";
Lucio Andrés Illanes Albornoz (arab, vxp) f3562b
	if [ ${ARG_IPV4_ONLY:-0} -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d01c02
		DEFAULT_WGET_ARGS="-4${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}";
Lucio Andrés Illanes Albornoz (arab, vxp) f3562b
	elif [ ${ARG_IPV6_ONLY:-0} -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d01c02
		DEFAULT_WGET_ARGS="-6${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}";
Lucio Andrés Illanes Albornoz (arab, vxp) f3562b
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 3bb0a6
	_env_vars="$(export | sed -e 's/^export //' -e 's/=.*$//')";
Lucio Andrés Illanes Albornoz (arab, vxp) 3bb0a6
	_env_vars_except="${DEFAULT_CLEAR_ENV_VARS_EXCEPT}";
Lucio Andrés Illanes Albornoz (arab, vxp) 3bb0a6
	for _env_var in ${_env_vars}; do
Lucio Andrés Illanes Albornoz (arab, vxp) 26a97e
		if [ "${_env_var#DEFAULT_}" != "${_env_var}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 26a97e
		|| [ "${_env_var#PKG_}" != "${_env_var}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 3bb0a6
			_env_vars_except="${_env_vars_except:+${_env_vars_except} }${_env_var}";
Lucio Andrés Illanes Albornoz (arab, vxp) 3bb0a6
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 3bb0a6
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 3bb0a6
	ex_rtl_unset_vars $(ex_rtl_lfilter_not "${_env_vars}" "${_env_vars_except}");
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	ex_rtl_fileop mkdir "${BUILD_DLCACHEDIR}" "${BUILD_WORKDIR}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if [ -e "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ex_rtl_log_msg failexit "Error: another build targeting this architecture and build type is currently in progress.";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	else
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		touch "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if [ -e "${DEFAULT_BUILD_LOG_FNAME}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 5ec894
		ex_rtl_fileop mv "${DEFAULT_BUILD_LOG_FNAME}" "${DEFAULT_BUILD_LOG_LAST_FNAME}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) a43dbf
	ex_rtl_fileop touch "${DEFAULT_BUILD_LOG_FNAME}";
Lucio Andrés Illanes Albornoz (arab, vxp) a43dbf
	BUILD_IS_PARENT=1;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	BUILD_DATE_START="$(ex_rtl_date %Y-%m-%d-%H-%M-%S)";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	BUILD_NFINI="${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	BUILD_TIMES_SECS="$(ex_rtl_date %s)";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	BUILD_PKGS_FAILED="";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	trap "rm -f "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";	\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ex_rtl_log_msg failexit \"Build aborted.\";"		\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		HUP INT TERM USR1 USR2;
Lucio Andrés Illanes Albornoz (arab, vxp) 0b1fc0
	trap "rm -f "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 0b1fc0
		EXIT;
Lucio Andrés Illanes Albornoz (arab, vxp) e2fea1
};
Lucio Andrés Illanes Albornoz (arab, vxp) e2fea1
Lucio Andrés Illanes Albornoz (arab, vxp) e2fea1
# vim:filetype=sh