abuild: Add -Z / --clean-somewhat option

This option removes everything in the build tree but coreboot.rom,
config.build, config.h and make.log - a useful subset of the tree for
further testing.

Change-Id: I27e559d8d7dc90d8fe5c4ed8e25249e202e5da36
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/35136
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Patrick Georgi 2019-08-28 16:56:16 +02:00
parent e34c80256e
commit 93bcebcfff
1 changed files with 12 additions and 2 deletions

View File

@ -398,6 +398,10 @@ function compile_target
if [ "$clean_work" = "true" ]; then if [ "$clean_work" = "true" ]; then
rm -rf "${build_dir}" rm -rf "${build_dir}"
fi fi
if [ "$clean_objs" = "true" ]; then
find ${build_dir} \! \( -name coreboot.rom -o -name config.h -o -name config.build -o -name make.log \) -type f -exec rm {} +
find ${build_dir} -type d -exec rmdir -p {} + 2>/dev/null
fi
return $MAKE_FAILED return $MAKE_FAILED
} }
@ -595,6 +599,7 @@ Options:\n"
(defaults to $XMLFILE) (defaults to $XMLFILE)
[-y|--ccache] Use ccache [-y|--ccache] Use ccache
[-z|--clean] Remove build results when finished [-z|--clean] Remove build results when finished
[-Z|--clean-somewhat] Remove build but keep coreboot.rom + config
[-V|--version] Print version number and exit [-V|--version] Print version number and exit
[-h|--help] Print this help and exit [-h|--help] Print this help and exit
@ -641,12 +646,12 @@ getoptbrand="$(getopt -V)"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
if [ "${getoptbrand:0:6}" == "getopt" ]; then if [ "${getoptbrand:0:6}" == "getopt" ]; then
# Detected GNU getopt that supports long options. # Detected GNU getopt that supports long options.
args=$(getopt -l version,verbose,quiet,help,all,target:,board-variant:,payloads:,cpus:,silent,junit,config,loglevel:,remove,prefix:,update,scan-build,ccache,blobs,clang,any-toolchain,clean,outdir:,chromeos,xmlfile:,kconfig:,dir:,root:,recursive,checksum:,timeless,exitcode,asserts -o Vvqhat:b:p:c:sJCl:rP:uyBLAzo:xX:K:d:R:Ie -- "$@") || exit 1 args=$(getopt -l version,verbose,quiet,help,all,target:,board-variant:,payloads:,cpus:,silent,junit,config,loglevel:,remove,prefix:,update,scan-build,ccache,blobs,clang,any-toolchain,clean,clean-somewhat,outdir:,chromeos,xmlfile:,kconfig:,dir:,root:,recursive,checksum:,timeless,exitcode,asserts -o Vvqhat:b:p:c:sJCl:rP:uyBLAzZo:xX:K:d:R:Ie -- "$@") || exit 1
eval set -- $args eval set -- $args
retval=$? retval=$?
else else
# Detected non-GNU getopt # Detected non-GNU getopt
args=$(getopt Vvqhat:b:p:c:sJCl:rP:uyBLAzo:xX:K:d:R:Ie "$@") args=$(getopt Vvqhat:b:p:c:sJCl:rP:uyBLAZzo:xX:K:d:R:Ie "$@")
set -- $args set -- $args
retval=$? retval=$?
fi fi
@ -658,6 +663,7 @@ fi
chromeos=false chromeos=false
clean_work=false clean_work=false
clean_objs=false
verboseopt='V=0' verboseopt='V=0'
customizing="" customizing=""
configoptions="" configoptions=""
@ -730,6 +736,10 @@ while true ; do
customizing="${customizing}, clean" customizing="${customizing}, clean"
clean_work=true clean_work=true
;; ;;
-Z|--clean-somewhat) shift
customizing="${customizing}, clean-somewhat"
clean_objs=true
;;
-o|--outdir) shift -o|--outdir) shift
TARGET=$1; shift TARGET=$1; shift
;; ;;