diff options
| author | Leah Rowe <leah@libreboot.org> | 2023-05-20 17:53:03 +0100 | 
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2023-05-20 17:53:03 +0100 | 
| commit | 355a45b435ba6ef1dbceddf4d2cbeef9517ff370 (patch) | |
| tree | 2faa3dc3f8779f9b3cc2272ba2fd9cd4c57127dc | |
| parent | 9f58d4e481ac89858fdb19a88eb8bc53440c1af7 (diff) | |
build/cbutils: top-down coding style, main on top
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rwxr-xr-x | resources/scripts/build/module/cbutils | 66 | 
1 files changed, 30 insertions, 36 deletions
| diff --git a/resources/scripts/build/module/cbutils b/resources/scripts/build/module/cbutils index a24cac02..487e4fd9 100755 --- a/resources/scripts/build/module/cbutils +++ b/resources/scripts/build/module/cbutils @@ -18,40 +18,31 @@  #	along with this program.  If not, see <http://www.gnu.org/licenses/>.  # -# This script assumes that the current working directory is the root -  [ "x${DEBUG+set}" = 'xset' ] && set -v  set -u -e  printf "Building coreboot utils\n" -buildutils() { -	cbtree="${1}" -	if [ ! -d "coreboot/${cbtree}/" ]; then -		./download coreboot $cbtree || return 1 -	fi -	if [ ! -d "coreboot/${cbtree}/" ]; then -		printf "build/cbutils: coreboot/%s not found. Exiting\n" \ -				"${cbtree}" -		return 1 +main() +{ +	if [ $# -gt 0 ]; then +		for board in "${@}"; do +			buildfromboardconfig ${board} || exit 1 +		done +	else +		for boarddir in resources/coreboot/*; do +			[ ! -d "${boarddir}" ] && continue +			buildfromboardconfig ${boarddir##*/} || exit 1 +		done  	fi -	for util in cbfstool ifdtool; do -	( -		cd "coreboot/${cbtree}/util/${util}/" -		make -j$(nproc) || return 1 -	) -	done -	return 0  }  buildfromboardconfig() {  	board="${1}" -	if [ ! -d "resources/coreboot/${board}" ]; then +	[ ! -d "resources/coreboot/${board}" ] && \  		continue -	fi -	if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then +	[ ! -f "resources/coreboot/${board}/board.cfg" ] && \  		continue -	fi  	cbtree="undefined"  	. "resources/coreboot/${board}/board.cfg" # source  	if [ "${cbtree}" = "undefined" ]; then @@ -60,21 +51,24 @@ buildfromboardconfig() {  		return 1  	fi  	buildutils "${cbtree}" || return 1 -	return 0  } -if [ $# -gt 0 ]; then -	for board in "${@}"; do -		buildfromboardconfig ${board} || exit 1 -	done -else -	for boarddir in resources/coreboot/*; do -		if [ ! -d "${boarddir}" ]; then -			continue -		fi -		buildfromboardconfig ${boarddir##*/} || exit 1 +buildutils() { +	cbtree="${1}" +	if [ ! -d "coreboot/${cbtree}/" ]; then +		./download coreboot $cbtree || return 1 +	fi +	if [ ! -d "coreboot/${cbtree}/" ]; then +		printf "build/cbutils: coreboot/%s not found. Exiting\n" \ +				"${cbtree}" +		return 1 +	fi +	for util in cbfstool ifdtool; do +		( +		cd "coreboot/${cbtree}/util/${util}/" +		make -j$(nproc) || return 1 +		)  	done -fi +} -printf "\n\n" -exit 0 +main $@ | 
