Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame build.sh

lalbornoz 340f4c
#!/bin/sh
lalbornoz 340f4c
lalbornoz 340f4c
{
lalbornoz 340f4c
unset AR ARFLAGS CC CFLAGS CXX CXXFLAGS LD LDFLAGS;
lalbornoz 340f4c
. ./build.vars; . ./build.subr;
lalbornoz 340f4c
check_prereqs git make sed tar wget;
lalbornoz 340f4c
log_msg info "Build started by ${USER}@$(hostname).";
lalbornoz 340f4c
#trap
lalbornoz 340f4c
(set -o errexit; mkdir -p "${PREFIX}" "${WORKDIR}");
lalbornoz 340f4c
BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${_nbuild:=0}}};
lalbornoz 340f4c
for BUILD_LVL in 0 1 2; do
lalbornoz 340f4c
	for BUILD_SCRIPT_FNAME in ${BUILD_LVL}[0-9][0-9].*.build; do
lalbornoz 340f4c
		if [ -n "${DEBUG_SCRIPT}" ]\
lalbornoz 340f4c
		&& [ "x${DEBUG_SCRIPT}" != "x${BUILD_SCRIPT_FNAME}" ]; then
lalbornoz 340f4c
			continue;
lalbornoz 340f4c
		elif [ ! -f "${BUILD_SCRIPT_FNAME}" ]; then
lalbornoz 340f4c
			continue;
lalbornoz 340f4c
		else
lalbornoz 340f4c
			unset BUILD_SCRIPT_RC; : $((_nbuild+=1));
lalbornoz 340f4c
			log_msg info "Invoking build script \`${BUILD_SCRIPT_FNAME}'";
lalbornoz 340f4c
			(set -o errexit -- $(split "." "${BUILD_SCRIPT_FNAME%.build}");	\
lalbornoz 340f4c
			 SCRIPT_FNAME="${BUILD_SCRIPT_FNAME}"; _pwd="$(pwd)";		\
lalbornoz 340f4c
			 cd "${WORKDIR}"; . "${_pwd}/build.subr";		\
lalbornoz 340f4c
			 . "${_pwd}/${BUILD_SCRIPT_FNAME}");
lalbornoz 340f4c
			case ${BUILD_SCRIPT_RC:=${?}} in
lalbornoz 340f4c
			0) log_msg succ "Finished build script \`${BUILD_SCRIPT_FNAME}'.";
lalbornoz 340f4c
				: $((BUILD_NFINI+=1)); continue; ;;
lalbornoz 340f4c
			212) log_msg info "Skipped build script \`${BUILD_SCRIPT_FNAME}' (already built.)";
lalbornoz 340f4c
				: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue; ;;
lalbornoz 340f4c
			*) log_msg fail "Build failed in build script \`${BUILD_SCRIPT_FNAME}' (last return code ${BUILD_SCRIPT_RC}.).";
lalbornoz 340f4c
				: $((BUILD_NFAIL+=1)); break; ;;
lalbornoz 340f4c
			esac;
lalbornoz 340f4c
		fi;
lalbornoz 340f4c
	done;
lalbornoz 340f4c
	if [ ${BUILD_SCRIPT_RC:-0} != 0 ]; then
lalbornoz 340f4c
		break;
lalbornoz 340f4c
	fi;
lalbornoz 340f4c
done;
lalbornoz 340f4c
log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${_nbuild} build script(s).";
lalbornoz 340f4c
exit ${BUILD_SCRIPT_RC};
lalbornoz 340f4c
} 2>&1 | tee build.log;
lalbornoz 340f4c
lalbornoz 340f4c
# vim:filetype=sh