Improve parsing of --cpu parameter in abuild script.
* -c "" need never be tested if getopt params are handled; fail abuild script when getopt parsing fails * use expr to resolve numeric test fails with -c max * cpus variable may be being passed in the environment. Don't overwrite MAKEFLAGS if it is not. Change-Id: I96236ef719a1a9f942b8e15bfcf015d60068e58a Signed-off-by: Raymond Danks <ray.danks@se-eng.com> Reviewed-on: http://review.coreboot.org/1068 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
parent
bdca15337b
commit
c95da25ac6
|
@ -527,7 +527,7 @@ cmdline="$* -c 1"
|
||||||
getoptbrand="`getopt -V`"
|
getoptbrand="`getopt -V`"
|
||||||
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,help,all,target:,payloads:,test,cpus:,silent,junit,xml,config,loglevel:,remove,prefix:,update,nostackprotect,scan-build,ccache,blobs -o Vvhat:p:Tc:sJxCl:rP:uyB -- "$@"`
|
args=`getopt -l version,verbose,help,all,target:,payloads:,test,cpus:,silent,junit,xml,config,loglevel:,remove,prefix:,update,nostackprotect,scan-build,ccache,blobs -o Vvhat:p:Tc:sJxCl:rP:uyB -- "$@"` || exit 1
|
||||||
eval set -- $args
|
eval set -- $args
|
||||||
else
|
else
|
||||||
# Detected non-GNU getopt
|
# Detected non-GNU getopt
|
||||||
|
@ -556,10 +556,9 @@ while true ; do
|
||||||
-T|--test) shift; hwtest=true;;
|
-T|--test) shift; hwtest=true;;
|
||||||
-c|--cpus) shift
|
-c|--cpus) shift
|
||||||
export MAKEFLAGS="-j $1"
|
export MAKEFLAGS="-j $1"
|
||||||
test "$MAKEFLAGS" == "-j max" && export MAKEFLAGS="-j"
|
test "$MAKEFLAGS" == "-j max" && export MAKEFLAGS="-j" && cpuconfig="in parallel"
|
||||||
test "$1" == "" && cpuconfig="in parallel"
|
|
||||||
test "$1" == "1" && cpuconfig="on 1 cpu"
|
test "$1" == "1" && cpuconfig="on 1 cpu"
|
||||||
test 0$1 -gt 1 && cpuconfig="on $1 cpus in parallel"
|
expr "$1" : '-\?[0-9]\+$' > /dev/null && test 0$1 -gt 1 && cpuconfig="on $1 cpus in parallel"
|
||||||
shift;;
|
shift;;
|
||||||
-s|--silent) shift; silent="-s";;
|
-s|--silent) shift; silent="-s";;
|
||||||
-ns|--nostackprotect) shift; stackprotect=true;;
|
-ns|--nostackprotect) shift; stackprotect=true;;
|
||||||
|
@ -608,11 +607,12 @@ if [ "$cpus" != "1" ]; then
|
||||||
if [ "$target" = "" ]; then
|
if [ "$target" = "" ]; then
|
||||||
# Test if xargs supports the non-standard -P flag
|
# Test if xargs supports the non-standard -P flag
|
||||||
# FIXME: disabled until we managed to eliminate all the make(1) quirks
|
# FIXME: disabled until we managed to eliminate all the make(1) quirks
|
||||||
echo | xargs -P 0$cpus -n 1 echo 2>/dev/null >/dev/null # && USE_XARGS=1
|
echo | xargs -P 0$cpus -n 1 echo 2>/dev/null >/dev/null # && USE_XARGS=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$USE_XARGS" = "0" ]; then
|
if [ "$USE_XARGS" = "0" ]; then
|
||||||
|
test "$MAKEFLAGS" == "" && test "$cpus" != "" && export MAKEFLAGS="-j $cpus"
|
||||||
build_all_targets()
|
build_all_targets()
|
||||||
{
|
{
|
||||||
for VENDOR in $( vendors ); do
|
for VENDOR in $( vendors ); do
|
||||||
|
|
Loading…
Reference in New Issue