summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2012-05-11 14:22:01 +0000
committerMike Frysinger <vapier@gentoo.org>2012-05-11 14:22:01 +0000
commitd97797f4878b3c10a19228c91123abbde4b27fbe (patch)
tree141cecf681c844b9d794a3049f069359aadfa819 /eclass/eutils.eclass
parentRevert homepage (it is back to original now) (diff)
downloadgentoo-2-d97797f4878b3c10a19228c91123abbde4b27fbe.tar.gz
gentoo-2-d97797f4878b3c10a19228c91123abbde4b27fbe.tar.bz2
gentoo-2-d97797f4878b3c10a19228c91123abbde4b27fbe.zip
support extended makeflag syntax and not just -j#
Diffstat (limited to 'eclass/eutils.eclass')
-rw-r--r--eclass/eutils.eclass15
1 files changed, 10 insertions, 5 deletions
diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
index ea8448717476..c88ef3541d2a 100644
--- a/eclass/eutils.eclass
+++ b/eclass/eutils.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.391 2012/04/20 19:35:37 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.392 2012/05/11 14:22:01 vapier Exp $
# @ECLASS: eutils.eclass
# @MAINTAINER:
@@ -1314,14 +1314,19 @@ usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } #382963
# @USAGE: [${MAKEOPTS}]
# @DESCRIPTION:
# Searches the arguments (defaults to ${MAKEOPTS}) and extracts the jobs number
-# specified therein. i.e. if the user has MAKEOPTS=-j9, this will show "9".
+# specified therein. Useful for running non-make tools in parallel too.
+# i.e. if the user has MAKEOPTS=-j9, this will show "9".
# We can't return the number as bash normalizes it to [0, 255]. If the flags
# haven't specified a -j flag, then "1" is shown as that is the default `make`
-# uses. Useful for running non-make tools in parallel too.
+# uses. Since there's no way to represent infinity, we return 999 if the user
+# has -j without a number.
makeopts_jobs() {
[[ $# -eq 0 ]] && set -- ${MAKEOPTS}
- local x jobs
- for x ; do [[ ${x} == -j* ]] && jobs=${x#-j} ; done
+ # This assumes the first .* will be more greedy than the second .*
+ # since POSIX doesn't specify a non-greedy match (i.e. ".*?").
+ local jobs=$(echo " $* " | sed -r -n \
+ -e 's:.*[[:space:]](-j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \
+ -e 's:.*[[:space:]](-j|--jobs)[[:space:]].*:999:p')
echo ${jobs:-1}
}