public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2015-11-11 10:27 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2015-11-11 10:27 UTC (permalink / raw
  To: gentoo-commits

commit:     0f076c65649b8eda6480f8c44e4b85f583cdd014
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  8 08:27:50 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Nov 11 10:21:33 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0f076c65

python-utils-r1.eclass: Support getting PYTHON_CONFIG path

 eclass/python-utils-r1.eclass   | 47 +++++++++++++++++++++++++++++++++++++++++
 eclass/tests/python-utils-r1.sh |  2 ++
 2 files changed, 49 insertions(+)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index e8de6b9..68926ab 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -190,6 +190,20 @@ _python_impl_supported() {
 # -lpython2.7
 # @CODE
 
+# @ECLASS-VARIABLE: PYTHON_CONFIG
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Path to the python-config executable.
+#
+# Set and exported on request using python_export().
+# Valid only for CPython. Requires a proper build-time dependency
+# on the Python implementation and on pkg-config.
+#
+# Example value:
+# @CODE
+# /usr/bin/python2.7-config
+# @CODE
+
 # @ECLASS-VARIABLE: PYTHON_PKG_DEP
 # @DEFAULT_UNSET
 # @DESCRIPTION:
@@ -323,6 +337,22 @@ python_export() {
 				export PYTHON_LIBS=${val}
 				debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
 				;;
+			PYTHON_CONFIG)
+				local flags val
+
+				case "${impl}" in
+					python*)
+						flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")')
+						val=${PYTHON}${flags}-config
+						;;
+					*)
+						die "${impl}: obtaining ${var} not supported"
+						;;
+				esac
+
+				export PYTHON_CONFIG=${val}
+				debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
+				;;
 			PYTHON_PKG_DEP)
 				local d
 				case ${impl} in
@@ -443,6 +473,23 @@ python_get_LIBS() {
 	echo "${PYTHON_LIBS}"
 }
 
+# @FUNCTION: python_get_PYTHON_CONFIG
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the PYTHON_CONFIG location for the given
+# implementation. If no implementation is provided, ${EPYTHON} will be
+# used.
+#
+# Please note that this function can be used with CPython only.
+# It requires Python installed, and therefore proper build-time
+# dependencies need be added to the ebuild.
+python_get_PYTHON_CONFIG() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	python_export "${@}" PYTHON_CONFIG
+	echo "${PYTHON_CONFIG}"
+}
+
 # @FUNCTION: python_get_scriptdir
 # @USAGE: [<impl>]
 # @DESCRIPTION:

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 457756d..b683c51 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -67,6 +67,7 @@ if [[ -x /usr/bin/python2.7 ]]; then
 	test_var PYTHON_SITEDIR python2_7 "/usr/lib*/python2.7/site-packages"
 	test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7
 	test_var PYTHON_LIBPATH python2_7 "/usr/lib*/libpython2.7$(get_libname)"
+	test_var PYTHON_CONFIG python2_7 /usr/bin/python2.7-config
 fi
 test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7'
 test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
@@ -78,6 +79,7 @@ if [[ -x /usr/bin/python3.4 ]]; then
 	test_var PYTHON_SITEDIR python3_4 "/usr/lib*/python3.4/site-packages"
 	test_var PYTHON_INCLUDEDIR python3_4 "/usr/include/python3.4${abiflags}"
 	test_var PYTHON_LIBPATH python3_4 "/usr/lib*/libpython3.4${abiflags}$(get_libname)"
+	test_var PYTHON_CONFIG python3_4 "/usr/bin/python3.4${abiflags}-config"
 fi
 test_var PYTHON_PKG_DEP python3_4 '*dev-lang/python*:3.4'
 test_var PYTHON_SCRIPTDIR python3_4 /usr/lib/python-exec/python3.4


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2015-11-24 17:03 Mike Frysinger
  0 siblings, 0 replies; 41+ messages in thread
From: Mike Frysinger @ 2015-11-24 17:03 UTC (permalink / raw
  To: gentoo-commits

commit:     ddd7a0bc1e06c0f7737799b784c110b7903f0a58
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 24 17:02:31 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Nov 24 17:03:49 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ddd7a0bc

multiprocessing.eclass: makeopts_loadavg: various fixes #543116

- Add support for --max-load option
- Fix default load value if not specified (999)
- Fix trailing flag consumption so we don't leave garbage behind
- Add tests!

 eclass/multiprocessing.eclass                    |  7 +++--
 eclass/tests/multiprocessing_makeopts_loadavg.sh | 36 ++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
index 534b35c..06e004a 100644
--- a/eclass/multiprocessing.eclass
+++ b/eclass/multiprocessing.eclass
@@ -86,9 +86,10 @@ makeopts_loadavg() {
 	# This assumes the first .* will be more greedy than the second .*
 	# since POSIX doesn't specify a non-greedy match (i.e. ".*?").
 	local lavg=$(echo " $* " | sed -r -n \
-		-e 's:.*[[:space:]](-l|--load-average[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+)[^0-9.]*:\2:p' \
-		-e 's:.*[[:space:]](-l|--load-average)[[:space:]].*:999:p')
-	echo ${lavg:-1}
+		-e 's:.*[[:space:]](-l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+).*:\3:p' \
+		-e 's:.*[[:space:]](-l|--(load-average|max-load))[[:space:]].*:999:p')
+	# Default to 999 since the default is to not use a load limit.
+	echo ${lavg:-999}
 }
 
 # @FUNCTION: multijob_init

diff --git a/eclass/tests/multiprocessing_makeopts_loadavg.sh b/eclass/tests/multiprocessing_makeopts_loadavg.sh
new file mode 100755
index 0000000..12f9d01
--- /dev/null
+++ b/eclass/tests/multiprocessing_makeopts_loadavg.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source tests-common.sh
+
+inherit multiprocessing
+
+test-makeopts_loadavg() {
+	local exp=$1; shift
+	tbegin "makeopts_loadavg($*) == ${exp}"
+	local act=$(makeopts_loadavg "$@")
+	[[ ${act} == "${exp}" ]]
+	tend $? "Got back: ${act}"
+}
+
+tests=(
+	999 "-j"
+	999 "-l"
+	999 ""
+	9 "-l9 -w"
+	9 "-l 9 -w-j4"
+	3 "-l3 -j 4 -w"
+	5 "--load-average=5"
+	6 "--load-average 6"
+	7 "-l3 --load-average 7 -w"
+	4 "-j1 -j 2 --load-average 3 --load-average=4"
+	3 " --max-load=3 -x"
+	8 "     -l        			8     "
+)
+for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do
+	test-makeopts_loadavg "${tests[i]}" "${tests[i+1]}"
+done
+
+texit


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2015-12-09 20:42 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2015-12-09 20:42 UTC (permalink / raw
  To: gentoo-commits

commit:     f16b1c0b5321673d017ac61af3623041f155c71a
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Dec  9 19:21:32 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Dec  9 20:41:16 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f16b1c0b

python-utils-r1.eclass: Disable jython2_5

 eclass/python-utils-r1.eclass   | 6 ++----
 eclass/tests/python-utils-r1.sh | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 3ea23a8..cf0e134 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -44,7 +44,7 @@ declare -g -r _PYTHON_ALL_IMPLS=(
 	python2_7
 	python3_3 python3_4 python3_5
 	pypy pypy3
-	jython2_5 jython2_7
+	jython2_7
 )
 
 # @FUNCTION: _python_impl_supported
@@ -67,7 +67,7 @@ _python_impl_supported() {
 	# keep in sync with _PYTHON_ALL_IMPLS!
 	# (not using that list because inline patterns shall be faster)
 	case "${impl}" in
-		python2_7|python3_[345]|jython2_[57])
+		python2_7|python3_[345]|jython2_7)
 			return 0
 			;;
 		pypy1_[89]|pypy2_0|python2_[56]|python3_[12])
@@ -368,8 +368,6 @@ python_export() {
 						PYTHON_PKG_DEP='virtual/pypy:0=';;
 					pypy3)
 						PYTHON_PKG_DEP='virtual/pypy3:0=';;
-					jython2.5)
-						PYTHON_PKG_DEP='>=dev-java/jython-2.5.3-r2:2.5';;
 					jython2.7)
 						PYTHON_PKG_DEP='dev-java/jython:2.7';;
 					*)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index b89acfd..922b690 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -175,7 +175,6 @@ test_is "_python_impl_supported pypy1_9" 1
 test_is "_python_impl_supported pypy2_0" 1
 test_is "_python_impl_supported pypy" 0
 test_is "_python_impl_supported pypy3" 0
-test_is "_python_impl_supported jython2_5" 0
 test_is "_python_impl_supported jython2_7" 0
 
 rm "${tmpfile}"


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2016-01-08  5:14 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2016-01-08  5:14 UTC (permalink / raw
  To: gentoo-commits

commit:     a4de8aa2e9ef28100fb8834aaeb4495f66efb8d9
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  1 12:52:26 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jan  8 05:14:36 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a4de8aa2

scons-utils.eclass: scons_clean_makeopts, mark internal

 eclass/scons-utils.eclass   | 7 ++++---
 eclass/tests/scons-utils.sh | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/eclass/scons-utils.eclass b/eclass/scons-utils.eclass
index b8051b0..e5e309b 100644
--- a/eclass/scons-utils.eclass
+++ b/eclass/scons-utils.eclass
@@ -124,7 +124,7 @@ escons() {
 	fi
 
 	# if SCONSOPTS are _unset_, use cleaned MAKEOPTS
-	set -- scons ${SCONSOPTS-$(scons_clean_makeopts)} ${EXTRA_ESCONS} \
+	set -- scons ${SCONSOPTS-$(_scons_clean_makeopts)} ${EXTRA_ESCONS} \
 		"${@}"
 	echo "${@}" >&2
 	"${@}"
@@ -145,14 +145,15 @@ escons() {
 	return ${ret}
 }
 
-# @FUNCTION: scons_clean_makeopts
+# @FUNCTION: _scons_clean_makeopts
+# @INTERNAL
 # @USAGE: [makeflags] [...]
 # @DESCRIPTION:
 # Strip the supplied makeflags (or ${MAKEOPTS} if called without
 # an argument) of options not supported by SCons and make sure --jobs
 # gets an argument. Output the resulting flag list (suitable
 # for an assignment to SCONSOPTS).
-scons_clean_makeopts() {
+_scons_clean_makeopts() {
 	local new_makeopts
 
 	debug-print-function ${FUNCNAME} "${@}"

diff --git a/eclass/tests/scons-utils.sh b/eclass/tests/scons-utils.sh
index 7387135..df8af7a 100755
--- a/eclass/tests/scons-utils.sh
+++ b/eclass/tests/scons-utils.sh
@@ -10,7 +10,7 @@ inherit scons-utils
 test-scons_clean_makeopts() {
 	tbegin "scons_clean_makeopts() for ${1}"
 
-	local sconsopts=$(scons_clean_makeopts ${1}) ret=0
+	local sconsopts=$(_scons_clean_makeopts ${1}) ret=0
 
 	if [[ ${sconsopts} != ${2-${1}} ]]; then
 		eerror "Self-test failed:"


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2016-01-08  5:14 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2016-01-08  5:14 UTC (permalink / raw
  To: gentoo-commits

commit:     de0c03eda7a5570984491fe6fc2e4959b36ce128
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  1 12:55:26 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jan  8 05:14:36 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=de0c03ed

scons-utils.eclass: _scons_clean_makeopts, fix result caching

Stop calling _scons_clean_makeopts in a subshell in order to make
it possible for the cache to be preserved. Pass the result through
SCONSOPTS variable.

 eclass/scons-utils.eclass   | 15 +++++++++------
 eclass/tests/scons-utils.sh |  7 ++++---
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/eclass/scons-utils.eclass b/eclass/scons-utils.eclass
index e5e309b..4da2c4a 100644
--- a/eclass/scons-utils.eclass
+++ b/eclass/scons-utils.eclass
@@ -124,8 +124,12 @@ escons() {
 	fi
 
 	# if SCONSOPTS are _unset_, use cleaned MAKEOPTS
-	set -- scons ${SCONSOPTS-$(_scons_clean_makeopts)} ${EXTRA_ESCONS} \
-		"${@}"
+	if [[ ! ${SCONSOPTS+set} ]]; then
+		local SCONSOPTS
+		_scons_clean_makeopts
+	fi
+
+	set -- scons ${SCONSOPTS} ${EXTRA_ESCONS} "${@}"
 	echo "${@}" >&2
 	"${@}"
 	ret=${?}
@@ -169,9 +173,8 @@ _scons_clean_makeopts() {
 	# empty MAKEOPTS give out empty SCONSOPTS
 	# thus, we do need to worry about the initial setup
 	if [[ ${*} = ${_SCONS_CACHE_MAKEOPTS} ]]; then
-		set -- ${_SCONS_CACHE_SCONSOPTS}
-		debug-print "Cache hit: [${*}]"
-		echo ${*}
+		SCONSOPTS=${_SCONS_CACHE_SCONSOPTS}
+		debug-print "Cache hit: [${SCONSOPTS}]"
 		return
 	fi
 	export _SCONS_CACHE_MAKEOPTS=${*}
@@ -235,7 +238,7 @@ _scons_clean_makeopts() {
 	set -- ${new_makeopts}
 	export _SCONS_CACHE_SCONSOPTS=${*}
 	debug-print "New SCONSOPTS: [${*}]"
-	echo ${*}
+	SCONSOPTS=${*}
 }
 
 # @FUNCTION: use_scons

diff --git a/eclass/tests/scons-utils.sh b/eclass/tests/scons-utils.sh
index df8af7a..6355c54 100755
--- a/eclass/tests/scons-utils.sh
+++ b/eclass/tests/scons-utils.sh
@@ -10,14 +10,15 @@ inherit scons-utils
 test-scons_clean_makeopts() {
 	tbegin "scons_clean_makeopts() for ${1}"
 
-	local sconsopts=$(_scons_clean_makeopts ${1}) ret=0
+	local SCONSOPTS ret=0
+	_scons_clean_makeopts ${1}
 
-	if [[ ${sconsopts} != ${2-${1}} ]]; then
+	if [[ ${SCONSOPTS} != ${2-${1}} ]]; then
 		eerror "Self-test failed:"
 		eindent
 		eerror "MAKEOPTS: ${1}"
 		eerror "Expected: ${2-${1}}"
-		eerror "Actual: ${sconsopts}"
+		eerror "Actual: ${SCONSOPTS}"
 		eoutdent
 		ret=1
 	fi


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2016-06-26 15:36 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2016-06-26 15:36 UTC (permalink / raw
  To: gentoo-commits

commit:     2fea606eba41d9246f510814ce833879368bd835
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 22 19:50:21 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jun 26 15:34:47 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2fea606e

toolchain-funcs.eclass: Add tc-get-compiler-type()

Add a tc-get-compiler-type() function that can be used to identify
the compiler being used, using the preprocessor defines. Alike
gcc-*version() routines, it uses CPP (which in turn uses CC).

The major usage would be applying compiler-specific quirks and limiting
gcc version checks to compilers that actually are gcc, since e.g. clang
reports gcc version 4.2 -- which would incorrectly cause numerous gcc
version checks in ebuilds to fail.

 eclass/tests/toolchain-funcs.sh | 40 ++++++++++++++++++++++++++++++++++++++++
 eclass/toolchain-funcs.eclass   | 22 ++++++++++++++++++++++
 2 files changed, 62 insertions(+)

diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh
index 41c1ae5..6f37996 100755
--- a/eclass/tests/toolchain-funcs.sh
+++ b/eclass/tests/toolchain-funcs.sh
@@ -111,5 +111,45 @@ tc-ld-disable-gold
 )
 tend $?
 
+unset CPP
+
+tbegin "tc-get-compiler-type (gcc)"
+(
+export CC=gcc
+[[ $(tc-get-compiler-type) == gcc ]]
+)
+tend $?
+
+if type -P clang &>/dev/null; then
+	tbegin "tc-get-compiler-type (clang)"
+	(
+	export CC=clang
+	[[ $(tc-get-compiler-type) == clang ]]
+	)
+	tend $?
+fi
+
+if type -P pathcc &>/dev/null; then
+	tbegin "tc-get-compiler-type (pathcc)"
+	(
+	export CC=pathcc
+	[[ $(tc-get-compiler-type) == pathcc ]]
+	)
+	tend $?
+
+	tbegin "! tc-is-gcc (pathcc)"
+	(
+	export CC=pathcc
+	! tc-is-gcc
+	)
+	tend $?
+
+	tbegin "! tc-is-clang (pathcc)"
+	(
+	export CC=pathcc
+	! tc-is-clang
+	)
+	tend $?
+fi
 
 texit

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 1baab96..a29784c 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -585,6 +585,28 @@ tc-endian() {
 	esac
 }
 
+# @FUNCTION: tc-get-compiler-type
+# @RETURN: keyword identifying the compiler: gcc, clang, pathcc, unknown
+tc-get-compiler-type() {
+	local code='
+#if defined(__PATHSCALE__)
+	HAVE_PATHCC
+#elif defined(__clang__)
+	HAVE_CLANG
+#elif defined(__GNUC__)
+	HAVE_GCC
+#endif
+'
+	local res=$($(tc-getCPP "$@") -E -P - <<<"${code}")
+
+	case ${res} in
+		*HAVE_PATHCC*)	echo pathcc;;
+		*HAVE_CLANG*)	echo clang;;
+		*HAVE_GCC*)		echo gcc;;
+		*)				echo unknown;;
+	esac
+}
+
 # Internal func.  The first argument is the version info to expand.
 # Query the preprocessor to improve compatibility across different
 # compilers rather than maintaining a --version flag matrix. #335943


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2016-06-27  5:58 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2016-06-27  5:58 UTC (permalink / raw
  To: gentoo-commits

commit:     81c226e451be564a545696f93fc5880ebc160812
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 27 05:52:14 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jun 27 05:58:14 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=81c226e4

toolchain-funcs.eclass: tc-ninja_magic_to_arch, remove old KV support

Remove the support for old kernel versions that are no longer used
in Gentoo, and rely on KV_to_int() function. This functions is provided
by Portage but not listed in PMS. Furthermore, for a long time Portage
replaced it with 'return 1' in global scope, so they did not really work
as expected anyway.

 eclass/tests/toolchain-funcs.sh |  7 -------
 eclass/toolchain-funcs.eclass   | 16 +++-------------
 2 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh
index e6a1538..bfbe26f 100755
--- a/eclass/tests/toolchain-funcs.sh
+++ b/eclass/tests/toolchain-funcs.sh
@@ -25,13 +25,6 @@ test-tc-arch-kernel() {
 	done
 	return ${ret}
 }
-tbegin "tc-arch-kernel() (KV=2.6.0)"
-test-tc-arch-kernel 2.6.0 \
-	alpha arm{,eb}:arm avr32 bfin:blackfin cris hppa:parisc \
-	i{3..6}86:i386 ia64 m68k mips{,eb}:mips nios2 powerpc:ppc powerpc64:ppc64 \
-	s390{,x}:s390 sh{1..4}{,eb}:sh sparc{,64} vax x86_64 \
-	i{3..6}86-gentoo-freebsd:i386
-tend $?
 tbegin "tc-arch-kernel() (KV=2.6.30)"
 test-tc-arch-kernel 2.6.30 \
 	i{3..6}86:x86 x86_64:x86 \

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index d3abfb5..2652e0e 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -460,10 +460,6 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
 	local host=$2
 	[[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
 
-	local KV=${KV:-${KV_FULL}}
-	[[ ${type} == "kern" ]] && [[ -z ${KV} ]] && \
-	ewarn "QA: Kernel version could not be determined, please inherit kernel-2 or linux-info"
-
 	case ${host} in
 		aarch64*)	echo arm64;;
 		alpha*)		echo alpha;;
@@ -479,7 +475,7 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
 			# Starting with linux-2.6.24, the 'x86_64' and 'i386'
 			# trees have been unified into 'x86'.
 			# FreeBSD still uses i386
-			if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]] ; then
+			if [[ ${type} == "kern" && ${host} == *freebsd* ]] ; then
 				echo i386
 			else
 				echo x86
@@ -497,14 +493,8 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
 			# Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees
 			# have been unified into simply 'powerpc', but until 2.6.16,
 			# ppc32 is still using ARCH="ppc" as default
-			if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] ; then
+			if [[ ${type} == "kern" ]] ; then
 				echo powerpc
-			elif [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]] ; then
-				if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]] ; then
-					echo powerpc
-				else
-					echo ppc
-				fi
 			elif [[ ${host} == powerpc64* ]] ; then
 				echo ppc64
 			elif [[ ${PROFILE_ARCH} == "ppc64" ]] ; then
@@ -529,7 +519,7 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
 		x86_64*)
 			# Starting with linux-2.6.24, the 'x86_64' and 'i386'
 			# trees have been unified into 'x86'.
-			if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]] ; then
+			if [[ ${type} == "kern" ]] ; then
 				echo x86
 			else
 				ninj x86_64 amd64


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2016-12-18 13:46 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2016-12-18 13:46 UTC (permalink / raw
  To: gentoo-commits

commit:     639d76a02d2965f426944f7fa6d0259a99a613f9
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 13 08:57:46 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Dec 18 13:45:43 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=639d76a0

multiprocessing.eclass: Fix handling multiple short options (e.g. -kj)

Improve the regular expressions to handle parameters consisting of
multiple short options (such as -kj). It should be noted that the code
is not perfect but should handle all common (valid) cases; it could e.g.
incorrectly process a short option followed by string arg such as
'-Wfoo.j' although having this in MAKEOPTS is extremely unlikely.

 eclass/multiprocessing.eclass                    | 8 ++++----
 eclass/tests/multiprocessing_makeopts_jobs.sh    | 3 +++
 eclass/tests/multiprocessing_makeopts_loadavg.sh | 3 +++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
index 06e004a..5a5fe9a 100644
--- a/eclass/multiprocessing.eclass
+++ b/eclass/multiprocessing.eclass
@@ -67,8 +67,8 @@ makeopts_jobs() {
 	# 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')
+		-e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \
+		-e 's:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:999:p')
 	echo ${jobs:-1}
 }
 
@@ -86,8 +86,8 @@ makeopts_loadavg() {
 	# This assumes the first .* will be more greedy than the second .*
 	# since POSIX doesn't specify a non-greedy match (i.e. ".*?").
 	local lavg=$(echo " $* " | sed -r -n \
-		-e 's:.*[[:space:]](-l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+).*:\3:p' \
-		-e 's:.*[[:space:]](-l|--(load-average|max-load))[[:space:]].*:999:p')
+		-e 's:.*[[:space:]](-[a-z]*l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+).*:\3:p' \
+		-e 's:.*[[:space:]](-[a-z]*l|--(load-average|max-load))[[:space:]].*:999:p')
 	# Default to 999 since the default is to not use a load limit.
 	echo ${lavg:-999}
 }

diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh b/eclass/tests/multiprocessing_makeopts_jobs.sh
index 017d491..a1e43c8 100755
--- a/eclass/tests/multiprocessing_makeopts_jobs.sh
+++ b/eclass/tests/multiprocessing_makeopts_jobs.sh
@@ -31,6 +31,9 @@ tests=(
 	7 "-l3 --jobs 7 -w"
 	4 "-j1 -j 2 --jobs 3 --jobs=4"
 	8 "     -j        			8     "
+	999 "-kj"
+	4 "-kj4"
+	5 "-kj 5"
 )
 for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do
 	test-makeopts_jobs "${tests[i]}" "${tests[i+1]}"

diff --git a/eclass/tests/multiprocessing_makeopts_loadavg.sh b/eclass/tests/multiprocessing_makeopts_loadavg.sh
index 12f9d01..276b7e7 100755
--- a/eclass/tests/multiprocessing_makeopts_loadavg.sh
+++ b/eclass/tests/multiprocessing_makeopts_loadavg.sh
@@ -28,6 +28,9 @@ tests=(
 	4 "-j1 -j 2 --load-average 3 --load-average=4"
 	3 " --max-load=3 -x"
 	8 "     -l        			8     "
+	999 "-kl"
+	4 "-kl4"
+	5 "-kl 5"
 )
 for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do
 	test-makeopts_loadavg "${tests[i]}" "${tests[i+1]}"


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2017-02-09 18:16 Mike Frysinger
  0 siblings, 0 replies; 41+ messages in thread
From: Mike Frysinger @ 2017-02-09 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     9470312c23d126f0055f82c0e656003b3945430b
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Feb  9 18:15:13 2017 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Feb  9 18:16:07 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9470312c

multiprocess.eclass: makeopts_{jobs,loadavg}: fix implicit handling of $MAKEOPTS #608242

We missed quoting on ${MAKEOPTS} to set it as the first arg which meant
we might load invalid values into the second arg which is the "infinite"
scenario.

 eclass/multiprocessing.eclass                    |  4 ++--
 eclass/tests/multiprocessing_makeopts_jobs.sh    | 12 +++++++++---
 eclass/tests/multiprocessing_makeopts_loadavg.sh | 11 ++++++++---
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
index 67f7e2d65b..73d852410b 100644
--- a/eclass/multiprocessing.eclass
+++ b/eclass/multiprocessing.eclass
@@ -96,7 +96,7 @@ get_nproc() {
 # no way to represent infinity, we return ${inf} (defaults to 999) if the user
 # has -j without a number.
 makeopts_jobs() {
-	[[ $# -eq 0 ]] && set -- ${MAKEOPTS}
+	[[ $# -eq 0 ]] && set -- "${MAKEOPTS}"
 	# 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 \
@@ -117,7 +117,7 @@ makeopts_jobs() {
 # If no limit is specified or --load-average is used without a number, ${inf}
 # (defaults to 999) is returned.
 makeopts_loadavg() {
-	[[ $# -eq 0 ]] && set -- ${MAKEOPTS}
+	[[ $# -eq 0 ]] && set -- "${MAKEOPTS}"
 	# This assumes the first .* will be more greedy than the second .*
 	# since POSIX doesn't specify a non-greedy match (i.e. ".*?").
 	local lavg=$(echo " $* " | sed -r -n \

diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh b/eclass/tests/multiprocessing_makeopts_jobs.sh
index ef477277ab..cc4f91b694 100755
--- a/eclass/tests/multiprocessing_makeopts_jobs.sh
+++ b/eclass/tests/multiprocessing_makeopts_jobs.sh
@@ -10,14 +10,20 @@ inherit multiprocessing
 test-makeopts_jobs() {
 	local exp=$1; shift
 	tbegin "makeopts_jobs($1${2+; inf=${2}}) == ${exp}"
-	local act=$(makeopts_jobs "$@")
-	[[ ${act} == "${exp}" ]]
-	tend $? "Got back: ${act}"
+	local indirect=$(MAKEOPTS="$*" makeopts_jobs)
+	local direct=$(makeopts_jobs "$@")
+	if [[ "${direct}" != "${indirect}" ]] ; then
+		tend 1 "Mismatch between MAKEOPTS/cli: '${indirect}' != '${direct}'"
+	else
+		[[ ${direct} == "${exp}" ]]
+		tend $? "Got back: ${act}"
+	fi
 }
 
 tests=(
 	999 "-j"
 	999 "--jobs"
+	999 "-j -l9"
 	1 ""
 	1 "-l9 -w"
 	1 "-l9 -w-j4"

diff --git a/eclass/tests/multiprocessing_makeopts_loadavg.sh b/eclass/tests/multiprocessing_makeopts_loadavg.sh
index 6b976beb1a..ffa679d13e 100755
--- a/eclass/tests/multiprocessing_makeopts_loadavg.sh
+++ b/eclass/tests/multiprocessing_makeopts_loadavg.sh
@@ -10,9 +10,14 @@ inherit multiprocessing
 test-makeopts_loadavg() {
 	local exp=$1; shift
 	tbegin "makeopts_loadavg($1${2+; inf=${2}}) == ${exp}"
-	local act=$(makeopts_loadavg "$@")
-	[[ ${act} == "${exp}" ]]
-	tend $? "Got back: ${act}"
+	local indirect=$(MAKEOPTS="$*" makeopts_loadavg)
+	local direct=$(makeopts_loadavg "$@")
+	if [[ "${direct}" != "${indirect}" ]] ; then
+		tend 1 "Mismatch between MAKEOPTS/cli: '${indirect}' != '${direct}'"
+	else
+		[[ ${direct} == "${exp}" ]]
+		tend $? "Got back: ${act}"
+	fi
 }
 
 tests=(


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2017-03-18  7:33 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2017-03-18  7:33 UTC (permalink / raw
  To: gentoo-commits

commit:     f7a4c94d344b6c73773bf83bd397ba468386e294
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 11 13:25:42 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Mar 18 07:33:16 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f7a4c94d

estack.eclass: Split estack* logic from eutils

Split the estack_* and related functions from eutils into a dedicated
estack.eclass. Those functions have significant complexity and are not
used frequently, therefore they benefit from having a separate file
and an explicit dedicated maintainer.

The new eclass is implicitly inherited by eutils to preserve
compatibility. However, the inherit will be removed in EAPI 7,
and the ebuilds should switch to using estack directly.

Thanks to Ulrich Müller for doing the research on this.

 eclass/estack.eclass                               | 217 +++++++++++++++++++++
 eclass/eutils.eclass                               | 210 +-------------------
 .../tests/{eutils_eshopts.sh => estack_eshopts.sh} |   4 +-
 .../tests/{eutils_estack.sh => estack_estack.sh}   |   4 +-
 eclass/tests/{eutils_evar.sh => estack_evar.sh}    |   4 +-
 5 files changed, 230 insertions(+), 209 deletions(-)

diff --git a/eclass/estack.eclass b/eclass/estack.eclass
new file mode 100644
index 00000000000..19c388f3d8d
--- /dev/null
+++ b/eclass/estack.eclass
@@ -0,0 +1,217 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: estack.eclass
+# @MAINTAINER:
+# base-system@gentoo.org
+# @BLURB: stack-like value storage support
+# @DESCRIPTION:
+# Support for storing values on stack-like variables.
+
+if [[ -z ${_ESTACK_ECLASS} ]]; then
+
+# @FUNCTION: estack_push
+# @USAGE: <stack> [items to push]
+# @DESCRIPTION:
+# Push any number of items onto the specified stack.  Pick a name that
+# is a valid variable (i.e. stick to alphanumerics), and push as many
+# items as you like onto the stack at once.
+#
+# The following code snippet will echo 5, then 4, then 3, then ...
+# @CODE
+#		estack_push mystack 1 2 3 4 5
+#		while estack_pop mystack i ; do
+#			echo "${i}"
+#		done
+# @CODE
+estack_push() {
+	[[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments"
+	local stack_name="_ESTACK_$1_" ; shift
+	eval ${stack_name}+=\( \"\$@\" \)
+}
+
+# @FUNCTION: estack_pop
+# @USAGE: <stack> [variable]
+# @DESCRIPTION:
+# Pop a single item off the specified stack.  If a variable is specified,
+# the popped item is stored there.  If no more items are available, return
+# 1, else return 0.  See estack_push for more info.
+estack_pop() {
+	[[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments"
+
+	# We use the fugly _estack_xxx var names to avoid collision with
+	# passing back the return value.  If we used "local i" and the
+	# caller ran `estack_pop ... i`, we'd end up setting the local
+	# copy of "i" rather than the caller's copy.  The _estack_xxx
+	# garbage is preferable to using $1/$2 everywhere as that is a
+	# bit harder to read.
+	local _estack_name="_ESTACK_$1_" ; shift
+	local _estack_retvar=$1 ; shift
+	eval local _estack_i=\${#${_estack_name}\[@\]}
+	# Don't warn -- let the caller interpret this as a failure
+	# or as normal behavior (akin to `shift`)
+	[[ $(( --_estack_i )) -eq -1 ]] && return 1
+
+	if [[ -n ${_estack_retvar} ]] ; then
+		eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\"
+	fi
+	eval unset \"${_estack_name}\[${_estack_i}\]\"
+}
+
+# @FUNCTION: evar_push
+# @USAGE: <variable to save> [more vars to save]
+# @DESCRIPTION:
+# This let's you temporarily modify a variable and then restore it (including
+# set vs unset semantics).  Arrays are not supported at this time.
+#
+# This is meant for variables where using `local` does not work (such as
+# exported variables, or only temporarily changing things in a func).
+#
+# For example:
+# @CODE
+#		evar_push LC_ALL
+#		export LC_ALL=C
+#		... do some stuff that needs LC_ALL=C set ...
+#		evar_pop
+#
+#		# You can also save/restore more than one var at a time
+#		evar_push BUTTERFLY IN THE SKY
+#		... do stuff with the vars ...
+#		evar_pop     # This restores just one var, SKY
+#		... do more stuff ...
+#		evar_pop 3   # This pops the remaining 3 vars
+# @CODE
+evar_push() {
+	local var val
+	for var ; do
+		[[ ${!var+set} == "set" ]] \
+			&& val=${!var} \
+			|| val="unset_76fc3c462065bb4ca959f939e6793f94"
+		estack_push evar "${var}" "${val}"
+	done
+}
+
+# @FUNCTION: evar_push_set
+# @USAGE: <variable to save> [new value to store]
+# @DESCRIPTION:
+# This is a handy shortcut to save and temporarily set a variable.  If a value
+# is not specified, the var will be unset.
+evar_push_set() {
+	local var=$1
+	evar_push ${var}
+	case $# in
+	1) unset ${var} ;;
+	2) printf -v "${var}" '%s' "$2" ;;
+	*) die "${FUNCNAME}: incorrect # of args: $*" ;;
+	esac
+}
+
+# @FUNCTION: evar_pop
+# @USAGE: [number of vars to restore]
+# @DESCRIPTION:
+# Restore the variables to the state saved with the corresponding
+# evar_push call.  See that function for more details.
+evar_pop() {
+	local cnt=${1:-bad}
+	case $# in
+	0) cnt=1 ;;
+	1) isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*" ;;
+	*) die "${FUNCNAME}: only accepts one arg: $*" ;;
+	esac
+
+	local var val
+	while (( cnt-- )) ; do
+		estack_pop evar val || die "${FUNCNAME}: unbalanced push"
+		estack_pop evar var || die "${FUNCNAME}: unbalanced push"
+		[[ ${val} == "unset_76fc3c462065bb4ca959f939e6793f94" ]] \
+			&& unset ${var} \
+			|| printf -v "${var}" '%s' "${val}"
+	done
+}
+
+# @FUNCTION: eshopts_push
+# @USAGE: [options to `set` or `shopt`]
+# @DESCRIPTION:
+# Often times code will want to enable a shell option to change code behavior.
+# Since changing shell options can easily break other pieces of code (which
+# assume the default state), eshopts_push is used to (1) push the current shell
+# options onto a stack and (2) pass the specified arguments to set.
+#
+# If the first argument is '-s' or '-u', we assume you want to call `shopt`
+# rather than `set` as there are some options only available via that.
+#
+# A common example is to disable shell globbing so that special meaning/care
+# may be used with variables/arguments to custom functions.  That would be:
+# @CODE
+#		eshopts_push -o noglob
+#		for x in ${foo} ; do
+#			if ...some check... ; then
+#				eshopts_pop
+#				return 0
+#			fi
+#		done
+#		eshopts_pop
+# @CODE
+eshopts_push() {
+	if [[ $1 == -[su] ]] ; then
+		estack_push eshopts "$(shopt -p)"
+		[[ $# -eq 0 ]] && return 0
+		shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*"
+	else
+		estack_push eshopts $-
+		[[ $# -eq 0 ]] && return 0
+		set "$@" || die "${FUNCNAME}: bad options to set: $*"
+	fi
+}
+
+# @FUNCTION: eshopts_pop
+# @USAGE:
+# @DESCRIPTION:
+# Restore the shell options to the state saved with the corresponding
+# eshopts_push call.  See that function for more details.
+eshopts_pop() {
+	local s
+	estack_pop eshopts s || die "${FUNCNAME}: unbalanced push"
+	if [[ ${s} == "shopt -"* ]] ; then
+		eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
+	else
+		set +$-     || die "${FUNCNAME}: sanity: invalid shell settings: $-"
+		set -${s}   || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}"
+	fi
+}
+
+# @FUNCTION: eumask_push
+# @USAGE: <new umask>
+# @DESCRIPTION:
+# Set the umask to the new value specified while saving the previous
+# value onto a stack.  Useful for temporarily changing the umask.
+eumask_push() {
+	estack_push eumask "$(umask)"
+	umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
+}
+
+# @FUNCTION: eumask_pop
+# @USAGE:
+# @DESCRIPTION:
+# Restore the previous umask state.
+eumask_pop() {
+	[[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options"
+	local s
+	estack_pop eumask s || die "${FUNCNAME}: unbalanced push"
+	umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
+}
+
+# @FUNCTION: isdigit
+# @USAGE: <number> [more numbers]
+# @DESCRIPTION:
+# Return true if all arguments are numbers.
+isdigit() {
+	local d
+	for d ; do
+		[[ ${d:-bad} == *[!0-9]* ]] && return 1
+	done
+	return 0
+}
+
+_ESTACK_ECLASS=1
+fi #_ESTACK_ECLASS

diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
index ac6a4854d17..79ec00042a3 100644
--- a/eclass/eutils.eclass
+++ b/eclass/eutils.eclass
@@ -19,6 +19,13 @@ _EUTILS_ECLASS=1
 
 inherit multilib toolchain-funcs
 
+# implicitly inherited (now split) eclasses
+case ${EAPI:-0} in
+0|1|2|3|4|5|6)
+	inherit estack
+	;;
+esac
+
 # @FUNCTION: eqawarn
 # @USAGE: [message]
 # @DESCRIPTION:
@@ -63,209 +70,6 @@ egit_clean() {
 	find "$@" -type d -name '.git*' -prune -print0 | xargs -0 rm -rf
 }
 
-# @FUNCTION: estack_push
-# @USAGE: <stack> [items to push]
-# @DESCRIPTION:
-# Push any number of items onto the specified stack.  Pick a name that
-# is a valid variable (i.e. stick to alphanumerics), and push as many
-# items as you like onto the stack at once.
-#
-# The following code snippet will echo 5, then 4, then 3, then ...
-# @CODE
-#		estack_push mystack 1 2 3 4 5
-#		while estack_pop mystack i ; do
-#			echo "${i}"
-#		done
-# @CODE
-estack_push() {
-	[[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments"
-	local stack_name="_ESTACK_$1_" ; shift
-	eval ${stack_name}+=\( \"\$@\" \)
-}
-
-# @FUNCTION: estack_pop
-# @USAGE: <stack> [variable]
-# @DESCRIPTION:
-# Pop a single item off the specified stack.  If a variable is specified,
-# the popped item is stored there.  If no more items are available, return
-# 1, else return 0.  See estack_push for more info.
-estack_pop() {
-	[[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments"
-
-	# We use the fugly _estack_xxx var names to avoid collision with
-	# passing back the return value.  If we used "local i" and the
-	# caller ran `estack_pop ... i`, we'd end up setting the local
-	# copy of "i" rather than the caller's copy.  The _estack_xxx
-	# garbage is preferable to using $1/$2 everywhere as that is a
-	# bit harder to read.
-	local _estack_name="_ESTACK_$1_" ; shift
-	local _estack_retvar=$1 ; shift
-	eval local _estack_i=\${#${_estack_name}\[@\]}
-	# Don't warn -- let the caller interpret this as a failure
-	# or as normal behavior (akin to `shift`)
-	[[ $(( --_estack_i )) -eq -1 ]] && return 1
-
-	if [[ -n ${_estack_retvar} ]] ; then
-		eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\"
-	fi
-	eval unset \"${_estack_name}\[${_estack_i}\]\"
-}
-
-# @FUNCTION: evar_push
-# @USAGE: <variable to save> [more vars to save]
-# @DESCRIPTION:
-# This let's you temporarily modify a variable and then restore it (including
-# set vs unset semantics).  Arrays are not supported at this time.
-#
-# This is meant for variables where using `local` does not work (such as
-# exported variables, or only temporarily changing things in a func).
-#
-# For example:
-# @CODE
-#		evar_push LC_ALL
-#		export LC_ALL=C
-#		... do some stuff that needs LC_ALL=C set ...
-#		evar_pop
-#
-#		# You can also save/restore more than one var at a time
-#		evar_push BUTTERFLY IN THE SKY
-#		... do stuff with the vars ...
-#		evar_pop     # This restores just one var, SKY
-#		... do more stuff ...
-#		evar_pop 3   # This pops the remaining 3 vars
-# @CODE
-evar_push() {
-	local var val
-	for var ; do
-		[[ ${!var+set} == "set" ]] \
-			&& val=${!var} \
-			|| val="unset_76fc3c462065bb4ca959f939e6793f94"
-		estack_push evar "${var}" "${val}"
-	done
-}
-
-# @FUNCTION: evar_push_set
-# @USAGE: <variable to save> [new value to store]
-# @DESCRIPTION:
-# This is a handy shortcut to save and temporarily set a variable.  If a value
-# is not specified, the var will be unset.
-evar_push_set() {
-	local var=$1
-	evar_push ${var}
-	case $# in
-	1) unset ${var} ;;
-	2) printf -v "${var}" '%s' "$2" ;;
-	*) die "${FUNCNAME}: incorrect # of args: $*" ;;
-	esac
-}
-
-# @FUNCTION: evar_pop
-# @USAGE: [number of vars to restore]
-# @DESCRIPTION:
-# Restore the variables to the state saved with the corresponding
-# evar_push call.  See that function for more details.
-evar_pop() {
-	local cnt=${1:-bad}
-	case $# in
-	0) cnt=1 ;;
-	1) isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*" ;;
-	*) die "${FUNCNAME}: only accepts one arg: $*" ;;
-	esac
-
-	local var val
-	while (( cnt-- )) ; do
-		estack_pop evar val || die "${FUNCNAME}: unbalanced push"
-		estack_pop evar var || die "${FUNCNAME}: unbalanced push"
-		[[ ${val} == "unset_76fc3c462065bb4ca959f939e6793f94" ]] \
-			&& unset ${var} \
-			|| printf -v "${var}" '%s' "${val}"
-	done
-}
-
-# @FUNCTION: eshopts_push
-# @USAGE: [options to `set` or `shopt`]
-# @DESCRIPTION:
-# Often times code will want to enable a shell option to change code behavior.
-# Since changing shell options can easily break other pieces of code (which
-# assume the default state), eshopts_push is used to (1) push the current shell
-# options onto a stack and (2) pass the specified arguments to set.
-#
-# If the first argument is '-s' or '-u', we assume you want to call `shopt`
-# rather than `set` as there are some options only available via that.
-#
-# A common example is to disable shell globbing so that special meaning/care
-# may be used with variables/arguments to custom functions.  That would be:
-# @CODE
-#		eshopts_push -o noglob
-#		for x in ${foo} ; do
-#			if ...some check... ; then
-#				eshopts_pop
-#				return 0
-#			fi
-#		done
-#		eshopts_pop
-# @CODE
-eshopts_push() {
-	if [[ $1 == -[su] ]] ; then
-		estack_push eshopts "$(shopt -p)"
-		[[ $# -eq 0 ]] && return 0
-		shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*"
-	else
-		estack_push eshopts $-
-		[[ $# -eq 0 ]] && return 0
-		set "$@" || die "${FUNCNAME}: bad options to set: $*"
-	fi
-}
-
-# @FUNCTION: eshopts_pop
-# @USAGE:
-# @DESCRIPTION:
-# Restore the shell options to the state saved with the corresponding
-# eshopts_push call.  See that function for more details.
-eshopts_pop() {
-	local s
-	estack_pop eshopts s || die "${FUNCNAME}: unbalanced push"
-	if [[ ${s} == "shopt -"* ]] ; then
-		eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
-	else
-		set +$-     || die "${FUNCNAME}: sanity: invalid shell settings: $-"
-		set -${s}   || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}"
-	fi
-}
-
-# @FUNCTION: eumask_push
-# @USAGE: <new umask>
-# @DESCRIPTION:
-# Set the umask to the new value specified while saving the previous
-# value onto a stack.  Useful for temporarily changing the umask.
-eumask_push() {
-	estack_push eumask "$(umask)"
-	umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
-}
-
-# @FUNCTION: eumask_pop
-# @USAGE:
-# @DESCRIPTION:
-# Restore the previous umask state.
-eumask_pop() {
-	[[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options"
-	local s
-	estack_pop eumask s || die "${FUNCNAME}: unbalanced push"
-	umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
-}
-
-# @FUNCTION: isdigit
-# @USAGE: <number> [more numbers]
-# @DESCRIPTION:
-# Return true if all arguments are numbers.
-isdigit() {
-	local d
-	for d ; do
-		[[ ${d:-bad} == *[!0-9]* ]] && return 1
-	done
-	return 0
-}
-
 # @VARIABLE: EPATCH_SOURCE
 # @DESCRIPTION:
 # Default directory to search for patches.

diff --git a/eclass/tests/eutils_eshopts.sh b/eclass/tests/estack_eshopts.sh
similarity index 93%
rename from eclass/tests/eutils_eshopts.sh
rename to eclass/tests/estack_eshopts.sh
index 2e9bbb6d461..606a17cfb05 100755
--- a/eclass/tests/eutils_eshopts.sh
+++ b/eclass/tests/estack_eshopts.sh
@@ -1,10 +1,10 @@
 #!/bin/bash
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source tests-common.sh
 
-inherit eutils
+inherit estack
 
 test-it() {
 	local s0 s1 s2

diff --git a/eclass/tests/eutils_estack.sh b/eclass/tests/estack_estack.sh
similarity index 93%
rename from eclass/tests/eutils_estack.sh
rename to eclass/tests/estack_estack.sh
index c1fecf32313..4845243d3ae 100755
--- a/eclass/tests/eutils_estack.sh
+++ b/eclass/tests/estack_estack.sh
@@ -1,10 +1,10 @@
 #!/bin/bash
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source tests-common.sh
 
-inherit eutils
+inherit estack
 
 tbegin "initial stack state"
 estack_pop teststack

diff --git a/eclass/tests/eutils_evar.sh b/eclass/tests/estack_evar.sh
similarity index 96%
rename from eclass/tests/eutils_evar.sh
rename to eclass/tests/estack_evar.sh
index f8db340f723..29badba0079 100755
--- a/eclass/tests/eutils_evar.sh
+++ b/eclass/tests/estack_evar.sh
@@ -1,10 +1,10 @@
 #!/bin/bash
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 source tests-common.sh
 
-inherit eutils
+inherit estack
 
 tbegin "simple push/pop"
 VAR=1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2017-08-08 19:42 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2017-08-08 19:42 UTC (permalink / raw
  To: gentoo-commits

commit:     0e6d20439e89c82fa99bbaefbe2a728efc77631c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jul  1 16:14:44 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Aug  8 19:42:17 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0e6d2043

flag-o-matic.eclass: Strip LDFLAGS unsupported by the C compiler, #621274

Include LDFLAGS in the variables stripped by strip-unsupported-flags.
The code reuses the current functions for testing CC, and so only remove
LDFLAGS that are rejected by the C compiler and not the linker. This
solves the case of bug #621274 where LDFLAGS contained GCC-specific
-flto flag.

 eclass/flag-o-matic.eclass   | 3 +++
 eclass/tests/flag-o-matic.sh | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index b2f3742b3ec..4ef32c519f2 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -535,6 +535,9 @@ strip-unsupported-flags() {
 	export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS})
 	export FFLAGS=$(test-flags-F77 ${FFLAGS})
 	export FCFLAGS=$(test-flags-FC ${FCFLAGS})
+	# note: this does not verify the linker flags but it is enough
+	# to strip invalid C flags which are much more likely, #621274
+	export LDFLAGS=$(test-flags-CC ${LDFLAGS})
 }
 
 # @FUNCTION: get-flag

diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
index 92c68b82c3c..24f2a4c4af4 100755
--- a/eclass/tests/flag-o-matic.sh
+++ b/eclass/tests/flag-o-matic.sh
@@ -55,7 +55,7 @@ done <<<"
 
 tbegin "strip-unsupported-flags"
 strip-unsupported-flags
-[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]]
+[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]] && [[ ${LDFLAGS} == "" ]]
 ftend
 
 for var in $(all-flag-vars) ; do


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2017-08-11 14:35 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2017-08-11 14:35 UTC (permalink / raw
  To: gentoo-commits

commit:     28dd7e772d7245723a725ea13673b3419139cd43
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 11 14:33:18 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 11 14:35:09 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=28dd7e77

flag-o-matic.eclass: Revert "Strip LDFLAGS unsupported by the C..."

The current logic strips too much, causing build failures. Revert it
until we get it right.

Bug: https://bugs.gentoo.org/627474

 eclass/flag-o-matic.eclass   | 3 ---
 eclass/tests/flag-o-matic.sh | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 4ef32c519f2..b2f3742b3ec 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -535,9 +535,6 @@ strip-unsupported-flags() {
 	export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS})
 	export FFLAGS=$(test-flags-F77 ${FFLAGS})
 	export FCFLAGS=$(test-flags-FC ${FCFLAGS})
-	# note: this does not verify the linker flags but it is enough
-	# to strip invalid C flags which are much more likely, #621274
-	export LDFLAGS=$(test-flags-CC ${LDFLAGS})
 }
 
 # @FUNCTION: get-flag

diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
index 24f2a4c4af4..92c68b82c3c 100755
--- a/eclass/tests/flag-o-matic.sh
+++ b/eclass/tests/flag-o-matic.sh
@@ -55,7 +55,7 @@ done <<<"
 
 tbegin "strip-unsupported-flags"
 strip-unsupported-flags
-[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]] && [[ ${LDFLAGS} == "" ]]
+[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]]
 ftend
 
 for var in $(all-flag-vars) ; do


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2017-08-25 13:53 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2017-08-25 13:53 UTC (permalink / raw
  To: gentoo-commits

commit:     ae9870d9f6b1394ede86176443770b36d7e60ac1
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 11 15:17:45 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Aug 25 13:53:15 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ae9870d9

flag-o-matic.eclass: test-flag-PROG, ignore unused args in clang

By default, clang considers unused arguments as error when -Werror is
used. Since flag tests are performed without linking, this causes all
tests for linker flags to fail inadvertently and all those flags
are stripped as a result.

While the correctness of passing unused flags is doubtful, silently
stripping them in a few random packages is certainly not the solution
to the problem, and also makes the results differ between gcc and clang.
To account for that, use clang's -Qunused-arguments option to silence
unused argument warnings.

To avoid wasting time on testing the compiler, just try passing
-Qunused-arguments every time a flag check fails. If clang is not used,
the additional call will fail just the same as the previous one (either
because of the original flag or because of -Qunused-arguments), so
the result will be the same.

 eclass/flag-o-matic.eclass   | 9 ++++++++-
 eclass/tests/flag-o-matic.sh | 5 +++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 0393a30b74c..79866e04a48 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -441,7 +441,14 @@ test-flag-PROG() {
 		cmdline+=( "${flag}" -c -o /dev/null /dev/null )
 	fi
 
-	"${cmdline[@]}" </dev/null &>/dev/null
+	if ! "${cmdline[@]}" </dev/null &>/dev/null; then
+		# -Werror makes clang bail out on unused arguments as well;
+		# try to add -Qunused-arguments to work-around that
+		# other compilers don't support it but then, it's failure like
+		# any other
+		cmdline+=( -Qunused-arguments )
+		"${cmdline[@]}" </dev/null &>/dev/null
+	fi
 }
 
 # @FUNCTION: test-flag-CC

diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
index 92c68b82c3c..5e7ee354bf3 100755
--- a/eclass/tests/flag-o-matic.sh
+++ b/eclass/tests/flag-o-matic.sh
@@ -143,6 +143,11 @@ tbegin "test-flags-CC (gcc-valid but clang-invalid flags)"
 out=$(CC=clang test-flags-CC -finline-limit=1200)
 [[ $? -ne 0 && -z ${out} ]]
 ftend
+
+tbegin "test-flags-CC (unused flags w/clang)"
+out=$(CC=clang test-flags-CC -Wl,-O1)
+[[ $? -eq 0 && ${out} == "-Wl,-O1" ]]
+ftend
 fi
 
 texit


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2017-09-19 11:08 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2017-09-19 11:08 UTC (permalink / raw
  To: gentoo-commits

commit:     59a1a0dda7300177a263eb1de347da493f09fdee
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Sep  8 11:12:30 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Sep 19 11:08:26 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=59a1a0dd

eapi7-ver.eclass: 'Early adopter' version of EAPI 7 version manip

EAPI 7 is introducing new version manipulation and comparison functions
that aim to replace versionator.eclass. This eclass provides an 'early
adopter' versions of those routines.

It serves two goals:

a. getting wider review and some real-life testing before
the specification is set in stone,

b. making it possible to adapt ebuilds to the new routines early,
reducing the future work of EAPI 7 porting,

c. improving cache generation speed (the rountines are roughly 15-20
times than versionator.eclass).

For more details on the new logic, please see the eclass documentation.
Long story short, we are introducing three functions:

1. ver_cut -- to get substrings of the version string,

2. ver_rs -- to replace version separators via indices,

3. ver_test -- to compare two version numbers.

The third function is not implemented in the eclass. It's meant to reuse
the algorithms from the package manager, and the final implementation
will most likely reuse the code from the package manager (e.g. via IPC).

The code has been initially written by Ulrich Müller.

 eclass/eapi7-ver.eclass             | 190 ++++++++++++++++++++++++++++++++++++
 eclass/tests/eapi7-ver.sh           |  65 ++++++++++++
 eclass/tests/eapi7-ver_benchmark.sh | 113 +++++++++++++++++++++
 3 files changed, 368 insertions(+)

diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
new file mode 100644
index 00000000000..1e8e3c5e55b
--- /dev/null
+++ b/eclass/eapi7-ver.eclass
@@ -0,0 +1,190 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: eapi7-ver.eclass
+# @MAINTAINER:
+# PMS team <pms@gentoo.org>
+# @AUTHOR:
+# Ulrich Müller <ulm@gentoo.org>
+# Michał Górny <mgorny@gentoo.org>
+# @BLURB: Testing implementation of EAPI 7 version manipulators
+# @DESCRIPTION:
+# A stand-alone implementation of the version manipulation functions
+# aimed for EAPI 7.  Intended to be used for wider testing of
+# the proposed functions and to allow ebuilds to switch to the new
+# model early, with minimal change needed for actual EAPI 7.
+#
+# https://bugs.gentoo.org/482170
+#
+# Note: version comparison function is not included currently.
+#
+# @ROFF .SS
+# Version strings
+#
+# The functions support arbitrary version strings consisting of version
+# components interspersed with (possibly empty) version separators.
+#
+# A version component can either consist purely of digits ([0-9]+)
+# or purely of uppercase and lowercase letters ([A-Za-z]+).  A version
+# separator is either a string of any other characters ([^A-Za-z0-9]+),
+# or it occurs at the transition between a sequence of letters
+# and a sequence of digits, or vice versa.  In the latter case,
+# the version separator is an empty string.
+#
+# The version is processed left-to-right, and each successive component
+# is assigned numbers starting with 1.  The components are either split
+# on version separators or on boundaries between digits and letters
+# (in which case the separator between the components is empty).
+# Version separators are assigned numbers starting with 1 for
+# the separator between 1st and 2nd components.  As a special case,
+# if the version string starts with a separator, it is assigned index 0.
+#
+# Examples:
+#
+# @CODE
+#   1.2b-alpha4 -> 1 . 2 '' b - alpha '' 4
+#                  c s c s  c s c     s  c
+#                  1 1 2 2  3 3 4     4  5
+#
+#   .11.        -> . 11 .
+#                  s c  s
+#                  0 1  1
+# @CODE
+#
+# @ROFF .SS
+# Ranges
+#
+# A range can be specified as 'm' for m-th version component, 'm-'
+# for all components starting with m-th or 'm-n' for components starting
+# at m-th and ending at n-th (inclusive).  If the range spans outside
+# the version string, it is truncated silently.
+
+case ${EAPI:-0} in
+	0|1|2|3|4|5)
+		die "${ECLASS}: EAPI=${EAPI:-0} not supported";;
+	6)
+		;;
+	*)
+		die "${ECLASS}: EAPI=${EAPI} unknown";;
+esac
+
+# @FUNCTION: _ver_parse_range
+# @USAGE: <range> <max>
+# @INTERNAL
+# @DESCRIPTION:
+# Parse the range string <range>, setting 'start' and 'end' variables
+# to the appropriate bounds.  <min> and <max> specify the appropriate
+# lower and upper bound for the range; the user-specified value is
+# truncated to this range.
+_ver_parse_range() {
+	local range=${1}
+	local max=${2}
+
+	[[ ${range} == [0-9]* ]] \
+		|| die "${FUNCNAME}: range must start with a number"
+	start=${range%-*}
+	[[ ${range} == *-* ]] && end=${range#*-} || end=${start}
+	if [[ ${end} ]]; then
+		[[ ${start} -le ${end} ]] \
+			|| die "${FUNCNAME}: end of range must be >= start"
+		[[ ${end} -le ${max} ]] || end=${max}
+	else
+		end=${max}
+	fi
+}
+
+# @FUNCTION: _ver_split
+# @USAGE: <version>
+# @INTERNAL
+# @DESCRIPTION:
+# Split the version string <version> into separator-component array.
+# Sets 'comp' to an array of the form: ( s_0 c_1 s_1 c_2 s_2 c_3... )
+# where s_i are separators and c_i are components.
+_ver_split() {
+	local v=${1} LC_ALL=C
+
+	comp=()
+
+	# get separators and components
+	local s c
+	while [[ ${v} ]]; do
+		# cut the separator
+		s=${v%%[a-zA-Z0-9]*}
+		v=${v:${#s}}
+		# cut the next component; it can be either digits or letters
+		[[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*}
+		v=${v:${#c}}
+
+		comp+=( "${s}" "${c}" )
+	done
+}
+
+# @FUNCTION: ver_cut
+# @USAGE: <range> [<version>]
+# @DESCRIPTION:
+# Print the substring of the version string containing components
+# defined by the <range> and the version separators between them.
+# Processes <version> if specified, ${PV} otherwise.
+#
+# For the syntax of versions and ranges, please see the eclass
+# description.
+ver_cut() {
+	local range=${1}
+	local v=${2:-${PV}}
+	local start end
+	local -a comp
+
+	_ver_split "${v}"
+	local max=$((${#comp[@]}/2))
+	_ver_parse_range "${range}" "${max}"
+
+	local IFS=
+	if [[ ${start} -gt 0 ]]; then
+		start=$(( start*2 - 1 ))
+	fi
+	echo "${comp[*]:start:end*2-start}"
+}
+
+# @FUNCTION: ver_rs
+# @USAGE: <range> <repl> [<range> <repl>...] [<version>]
+# @DESCRIPTION:
+# Print the version string after substituting the specified version
+# separators at <range> with <repl> (string).  Multiple '<range> <repl>'
+# pairs can be specified.  Processes <version> if specified,
+# ${PV} otherwise.
+#
+# For the syntax of versions and ranges, please see the eclass
+# description.
+ver_rs() {
+	local v
+	(( ${#} & 1 )) && v=${@: -1} || v=${PV}
+	local start end i
+	local -a comp
+
+	_ver_split "${v}"
+	local max=$((${#comp[@]}/2 - 1))
+
+	while [[ ${#} -ge 2 ]]; do
+		_ver_parse_range "${1}" "${max}"
+		for (( i = start*2; i <= end*2; i+=2 )); do
+			[[ ${i} -eq 0 && -z ${comp[i]} ]] && continue
+			comp[i]=${2}
+		done
+		shift 2
+	done
+
+	local IFS=
+	echo "${comp[*]}"
+}
+
+# @FUNCTION: ver_test
+# @USAGE: [<v1>] <op> <v2>
+# @DESCRIPTION:
+# Check if the relation <v1> <op> <v2> is true.  If <v1> is not specified,
+# default to ${PVR}.  <op> can be -gt, -ge, -eq, -ne, -le, -lt.
+# Both versions must conform to the PMS version syntax (with optional
+# revision parts), and the comparison is performed according to
+# the algorithm specified in the PMS.
+ver_test() {
+	die "${FUNCNAME}: not implemented"
+}

diff --git a/eclass/tests/eapi7-ver.sh b/eclass/tests/eapi7-ver.sh
new file mode 100755
index 00000000000..8a96e4d29b1
--- /dev/null
+++ b/eclass/tests/eapi7-ver.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+source tests-common.sh
+
+inherit eapi7-ver
+
+teq() {
+	local expected=${1}; shift
+
+	tbegin "${*} -> ${expected}"
+	local got=$("${@}")
+	[[ ${got} == ${expected} ]]
+	tend ${?} "returned: ${got}"
+}
+
+txf() {
+	tbegin "XFAIL: ${*}"
+	local got=$("${@}" 2>&1)
+	[[ ${got} == die:* ]]
+	tend ${?} "function did not die"
+}
+
+teq 1 ver_cut 1 1.2.3
+teq 1 ver_cut 1-1 1.2.3
+teq 1.2 ver_cut 1-2 1.2.3
+teq 2.3 ver_cut 2- 1.2.3
+teq 1.2.3 ver_cut 1- 1.2.3
+teq 3b ver_cut 3-4 1.2.3b_alpha4
+teq alpha ver_cut 5 1.2.3b_alpha4
+teq 1.2 ver_cut 1-2 .1.2.3
+teq .1.2 ver_cut 0-2 .1.2.3
+teq 2.3 ver_cut 2-3 1.2.3.
+teq 2.3. ver_cut 2- 1.2.3.
+teq 2.3. ver_cut 2-4 1.2.3.
+
+teq 1-2.3 ver_rs 1 - 1.2.3
+teq 1.2-3 ver_rs 2 - 1.2.3
+teq 1-2-3.4 ver_rs 1-2 - 1.2.3.4
+teq 1.2-3-4 ver_rs 2- - 1.2.3.4
+teq 1.2.3 ver_rs 2 . 1.2-3
+teq 1.2.3.a ver_rs 3 . 1.2.3a
+teq 1.2-alpha-4 ver_rs 2-3 - 1.2_alpha4
+teq 1.23-b_alpha4 ver_rs 3 - 2 "" 1.2.3b_alpha4
+teq a1b_2-c-3-d4e5 ver_rs 3-5 _ 4-6 - a1b2c3d4e5
+teq .1-2.3 ver_rs 1 - .1.2.3
+teq -1.2.3 ver_rs 0 - .1.2.3
+
+# truncating range
+teq 1.2 ver_cut 0-2 1.2.3
+teq 2.3 ver_cut 2-5 1.2.3
+teq "" ver_cut 4 1.2.3
+teq "" ver_cut 0 1.2.3
+teq "" ver_cut 4- 1.2.3
+teq 1.2.3 ver_rs 0 - 1.2.3
+teq 1.2.3 ver_rs 3 . 1.2.3
+teq 1.2.3 ver_rs 3- . 1.2.3
+teq 1.2.3 ver_rs 3-5 . 1.2.3
+
+txf ver_cut foo 1.2.3
+txf ver_rs -3 _ a1b2c3d4e5
+txf ver_rs 5-3 _ a1b2c3d4e5

diff --git a/eclass/tests/eapi7-ver_benchmark.sh b/eclass/tests/eapi7-ver_benchmark.sh
new file mode 100755
index 00000000000..7e3c830fcb7
--- /dev/null
+++ b/eclass/tests/eapi7-ver_benchmark.sh
@@ -0,0 +1,113 @@
+#!/bin/bash
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+source tests-common.sh
+
+inherit eapi7-ver versionator
+
+cutting() {
+	local x
+	for x in {1..1000}; do
+		ver_cut 1 1.2.3
+		ver_cut 1-2 1.2.3
+		ver_cut 2- 1.2.3
+		ver_cut 1- 1.2.3
+		ver_cut 3-4 1.2.3b_alpha4
+		ver_cut 5 1.2.3b_alpha4
+		ver_cut 1-2 .1.2.3
+		ver_cut 0-2 .1.2.3
+		ver_cut 2-3 1.2.3.
+		ver_cut 2- 1.2.3.
+		ver_cut 2-4 1.2.3.
+	done >/dev/null
+}
+
+cutting_versionator() {
+	local x
+	for x in {1..100}; do
+		get_version_component_range 1 1.2.3
+		get_version_component_range 1-2 1.2.3
+		get_version_component_range 2- 1.2.3
+		get_version_component_range 1- 1.2.3
+		get_version_component_range 3-4 1.2.3b_alpha4
+		get_version_component_range 5 1.2.3b_alpha4
+		get_version_component_range 1-2 .1.2.3
+		get_version_component_range 0-2 .1.2.3
+		get_version_component_range 2-3 1.2.3.
+		get_version_component_range 2- 1.2.3.
+		get_version_component_range 2-4 1.2.3.
+	done >/dev/null
+}
+
+replacing() {
+	local x
+	for x in {1..1000}; do
+		ver_rs 1 - 1.2.3
+		ver_rs 2 - 1.2.3
+		ver_rs 1-2 - 1.2.3.4
+		ver_rs 2- - 1.2.3.4
+		ver_rs 2 . 1.2-3
+		ver_rs 3 . 1.2.3a
+		ver_rs 2-3 - 1.2_alpha4
+		#ver_rs 3 - 2 "" 1.2.3b_alpha4
+		#ver_rs 3-5 _ 4-6 - a1b2c3d4e5
+		ver_rs 1 - .1.2.3
+		ver_rs 0 - .1.2.3
+	done >/dev/null
+}
+
+replacing_versionator() {
+	local x
+	for x in {1..100}; do
+		replace_version_separator 1 - 1.2.3
+		replace_version_separator 2 - 1.2.3
+		replace_version_separator 1-2 - 1.2.3.4
+		replace_version_separator 2- - 1.2.3.4
+		replace_version_separator 2 . 1.2-3
+		replace_version_separator 3 . 1.2.3a
+		replace_version_separator 2-3 - 1.2_alpha4
+		#replace_version_separator 3 - 2 "" 1.2.3b_alpha4
+		#replace_version_separator 3-5 _ 4-6 - a1b2c3d4e5
+		replace_version_separator 1 - .1.2.3
+		replace_version_separator 0 - .1.2.3
+	done >/dev/null
+}
+
+get_times() {
+	local factor=${1}; shift
+	echo "${*}"
+	local real=()
+	local user=()
+
+	for x in {1..5}; do
+		while read tt tv; do
+			case ${tt} in
+				real) real+=( $(dc -e "${tv} ${factor} * p") );;
+				user) user+=( $(dc -e "${tv} ${factor} * p") );;
+			esac
+		done < <( ( time -p "${@}" ) 2>&1 )
+	done
+
+	[[ ${#real[@]} == 5 ]] || die "Did not get 5 real times"
+	[[ ${#user[@]} == 5 ]] || die "Did not get 5 user times"
+
+	local sum
+	for v in real user; do
+		vr="${v}[*]"
+		sum=$(dc -e "${!vr} + + + + 3 k 5 / p")
+
+		vr="${v}[@]"
+		printf '%s %4.2f %4.2f %4.2f %4.2f %4.2f %4.2f\n' \
+			"${v}" "${!vr}" "${sum}"
+	done
+}
+
+export LC_ALL=C
+
+get_times 1 cutting
+get_times 10 cutting_versionator
+get_times 1 replacing
+get_times 10 replacing_versionator


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2017-09-26 18:46 Ulrich Müller
  0 siblings, 0 replies; 41+ messages in thread
From: Ulrich Müller @ 2017-09-26 18:46 UTC (permalink / raw
  To: gentoo-commits

commit:     7175c90c8c4bc1332899dffa6b5fa7a7b30ad2a4
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 23 08:58:43 2017 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Tue Sep 26 18:46:27 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7175c90c

eapi7-ver.eclass: Use lexicographic rather than arithmetic comparison.

This removes the 2**63-1 limit for integer components.

 eclass/eapi7-ver.eclass   | 36 ++++++++++++++++++++++++++----------
 eclass/tests/eapi7-ver.sh |  2 +-
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index 5ca8b8143af..7eb070c6817 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -174,6 +174,28 @@ ver_rs() {
 	echo "${comp[*]}"
 }
 
+# @FUNCTION: _ver_compare_int
+# @USAGE: <a> <b>
+# @RETURN: 0 if <a> -eq <b>, 1 if <a> -lt <b>, 3 if <a> -gt <b>
+# @INTERNAL
+# @DESCRIPTION:
+# Compare two non-negative integers <a> and <b>, of arbitrary length.
+# If <a> is equal to, less than, or greater than <b>, return 0, 1, or 3
+# as exit status, respectively.
+_ver_compare_int() {
+	local a=$1 b=$2 d=$(( ${#1}-${#2} ))
+
+	# Zero-pad to equal length if necessary.
+	if [[ ${d} -gt 0 ]]; then
+		printf -v b "%0${d}d%s" 0 "${b}"
+	elif [[ ${d} -lt 0 ]]; then
+		printf -v a "%0$(( -d ))d%s" 0 "${a}"
+	fi
+
+	[[ ${a} > ${b} ]] && return 3
+	[[ ${a} == "${b}" ]]
+}
+
 # @FUNCTION: _ver_compare
 # @USAGE: <va> <vb>
 # @RETURN: 1 if <va> < <vb>, 2 if <va> = <vb>, 3 if <va> > <vb>
@@ -200,10 +222,7 @@ _ver_compare() {
 
 	# Compare numeric components (PMS algorithm 3.2)
 	# First component
-	a=${an%%.*}
-	b=${bn%%.*}
-	[[ 10#${a} -gt 10#${b} ]] && return 3
-	[[ 10#${a} -lt 10#${b} ]] && return 1
+	_ver_compare_int "${an%%.*}" "${bn%%.*}" || return
 
 	while [[ ${an} == *.* && ${bn} == *.* ]]; do
 		# Other components (PMS algorithm 3.3)
@@ -218,8 +237,7 @@ _ver_compare() {
 			[[ ${a} > ${b} ]] && return 3
 			[[ ${a} < ${b} ]] && return 1
 		else
-			[[ ${a} -gt ${b} ]] && return 3
-			[[ ${a} -lt ${b} ]] && return 1
+			_ver_compare_int "${a}" "${b}" || return
 		fi
 	done
 	[[ ${an} == *.* ]] && return 3
@@ -237,8 +255,7 @@ _ver_compare() {
 		a=${as%%_*}
 		b=${bs%%_*}
 		if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
-			[[ 10#${a##*[a-z]} -gt 10#${b##*[a-z]} ]] && return 3
-			[[ 10#${a##*[a-z]} -lt 10#${b##*[a-z]} ]] && return 1
+			_ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return
 		else
 			# Check for p first
 			[[ ${a%%[0-9]*} == p ]] && return 3
@@ -256,8 +273,7 @@ _ver_compare() {
 	fi
 
 	# Compare revision components (PMS algorithm 3.7)
-	[[ 10#${ar#-r} -gt 10#${br#-r} ]] && return 3
-	[[ 10#${ar#-r} -lt 10#${br#-r} ]] && return 1
+	_ver_compare_int "${ar#-r}" "${br#-r}" || return
 
 	return 2
 }

diff --git a/eclass/tests/eapi7-ver.sh b/eclass/tests/eapi7-ver.sh
index fd085a415b6..d4aa4fdbd28 100755
--- a/eclass/tests/eapi7-ver.sh
+++ b/eclass/tests/eapi7-ver.sh
@@ -150,7 +150,7 @@ teqr 0 ver_test 1.010 -eq 1.01
 teqr 0 ver_test 1.01 -lt 1.1
 teqr 0 ver_test 1.2_pre08-r09 -eq 1.2_pre8-r9
 teqr 0 ver_test 0 -lt 576460752303423488 # 2**59
-#teqr 0 ver_test 0 -lt 9223372036854775808 # 2**63 fails, integer rollover
+teqr 0 ver_test 0 -lt 9223372036854775808 # 2**63
 
 # Bad number or ordering of arguments
 txf ver_test 1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2018-01-04 21:56 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2018-01-04 21:56 UTC (permalink / raw
  To: gentoo-commits

commit:     0e50583c165feedf24152dae1973af88e0005191
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 31 10:29:42 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jan  4 21:56:14 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0e50583c

multiprocessing.eclass: Remove multijob_* functions

Remove the multijob functions that were used to run bash code
in parallel. The code was very complex, fragile and unmaintained. It has
been used scarcely, and pretty much by a single developer. It gave very
little gain, usually at the cost of losing readability and violating
PMS.

Closes: https://bugs.gentoo.org/613322

 eclass/multiprocessing.eclass   | 178 +++-------------------------------------
 eclass/tests/multiprocessing.sh |  42 ----------
 2 files changed, 10 insertions(+), 210 deletions(-)

diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
index b6e92976f73..cfe22303043 100644
--- a/eclass/multiprocessing.eclass
+++ b/eclass/multiprocessing.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: multiprocessing.eclass
@@ -7,29 +7,20 @@
 # @AUTHOR:
 # Brian Harring <ferringb@gentoo.org>
 # Mike Frysinger <vapier@gentoo.org>
-# @BLURB: parallelization with bash (wtf?)
+# @BLURB: multiprocessing helper functions
 # @DESCRIPTION:
-# The multiprocessing eclass contains a suite of functions that allow ebuilds
-# to quickly run things in parallel using shell code.
+# The multiprocessing eclass contains a suite of utility functions
+# that could be helpful to controlling parallel multiple job execution.
+# The most common use is processing MAKEOPTS in order to obtain job
+# count.
 #
-# It has two modes: pre-fork and post-fork.  If you don't want to dive into any
-# more nuts & bolts, just use the pre-fork mode.  For main threads that mostly
-# spawn children and then wait for them to finish, use the pre-fork mode.  For
-# main threads that do a bit of processing themselves, use the post-fork mode.
-# You may mix & match them for longer computation loops.
 # @EXAMPLE:
 #
 # @CODE
-# # First initialize things:
-# multijob_init
-#
-# # Then hash a bunch of files in parallel:
-# for n in {0..20} ; do
-# 	multijob_child_init md5sum data.${n} > data.${n}
-# done
-#
-# # Then wait for all the children to finish:
-# multijob_finish
+# src_compile() {
+#   # custom build system that does not support most of MAKEOPTS
+#   ./mybs -j$(makeopts_jobs)
+# }
 # @CODE
 
 if [[ -z ${_MULTIPROCESSING_ECLASS} ]]; then
@@ -126,155 +117,6 @@ makeopts_loadavg() {
 	echo ${lavg:-${2:-999}}
 }
 
-# @FUNCTION: multijob_init
-# @USAGE: [${MAKEOPTS}]
-# @DESCRIPTION:
-# Setup the environment for executing code in parallel.
-# You must call this before any other multijob function.
-multijob_init() {
-	# When something goes wrong, try to wait for all the children so we
-	# don't leave any zombies around.
-	has wait ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" wait "
-
-	# Setup a pipe for children to write their pids to when they finish.
-	# We have to allocate two fd's because POSIX has undefined behavior
-	# when using one single fd for both read and write. #487056
-	# However, opening an fd for read or write only will block until the
-	# opposite end is opened as well. Thus we open the first fd for both
-	# read and write to not block ourselve, but use it for reading only.
-	# The second fd really is opened for write only, as Cygwin supports
-	# just one single read fd per FIFO. #583962
-	local pipe="${T}/multijob.pipe"
-	mkfifo -m 600 "${pipe}"
-	redirect_alloc_fd mj_read_fd "${pipe}"
-	redirect_alloc_fd mj_write_fd "${pipe}" '>'
-	rm -f "${pipe}"
-
-	# See how many children we can fork based on the user's settings.
-	mj_max_jobs=$(makeopts_jobs "$@")
-	mj_num_jobs=0
-}
-
-# @FUNCTION: multijob_child_init
-# @USAGE: [--pre|--post] [command to run in background]
-# @DESCRIPTION:
-# This function has two forms.  You can use it to execute a simple command
-# in the background (and it takes care of everything else), or you must
-# call this first thing in your forked child process.
-#
-# The --pre/--post options allow you to select the child generation mode.
-#
-# @CODE
-# # 1st form: pass the command line as arguments:
-# multijob_child_init ls /dev
-# # Or if you want to use pre/post fork modes:
-# multijob_child_init --pre ls /dev
-# multijob_child_init --post ls /dev
-#
-# # 2nd form: execute multiple stuff in the background (post fork):
-# (
-# multijob_child_init
-# out=`ls`
-# if echo "${out}" | grep foo ; then
-# 	echo "YEAH"
-# fi
-# ) &
-# multijob_post_fork
-#
-# # 2nd form: execute multiple stuff in the background (pre fork):
-# multijob_pre_fork
-# (
-# multijob_child_init
-# out=`ls`
-# if echo "${out}" | grep foo ; then
-# 	echo "YEAH"
-# fi
-# ) &
-# @CODE
-multijob_child_init() {
-	local mode="pre"
-	case $1 in
-	--pre)  mode="pre" ; shift ;;
-	--post) mode="post"; shift ;;
-	esac
-
-	if [[ $# -eq 0 ]] ; then
-		trap 'echo ${BASHPID:-$(bashpid)} $? >&'${mj_write_fd} EXIT
-		trap 'exit 1' INT TERM
-	else
-		local ret
-		[[ ${mode} == "pre" ]] && { multijob_pre_fork; ret=$?; }
-		( multijob_child_init ; "$@" ) &
-		[[ ${mode} == "post" ]] && { multijob_post_fork; ret=$?; }
-		return ${ret}
-	fi
-}
-
-# @FUNCTION: _multijob_fork
-# @INTERNAL
-# @DESCRIPTION:
-# Do the actual book keeping.
-_multijob_fork() {
-	[[ $# -eq 1 ]] || die "incorrect number of arguments"
-
-	local ret=0
-	[[ $1 == "post" ]] && : $(( ++mj_num_jobs ))
-	if [[ ${mj_num_jobs} -ge ${mj_max_jobs} ]] ; then
-		multijob_finish_one
-		ret=$?
-	fi
-	[[ $1 == "pre" ]] && : $(( ++mj_num_jobs ))
-	return ${ret}
-}
-
-# @FUNCTION: multijob_pre_fork
-# @DESCRIPTION:
-# You must call this in the parent process before forking a child process.
-# If the parallel limit has been hit, it will wait for one child to finish
-# and return its exit status.
-multijob_pre_fork() { _multijob_fork pre "$@" ; }
-
-# @FUNCTION: multijob_post_fork
-# @DESCRIPTION:
-# You must call this in the parent process after forking a child process.
-# If the parallel limit has been hit, it will wait for one child to finish
-# and return its exit status.
-multijob_post_fork() { _multijob_fork post "$@" ; }
-
-# @FUNCTION: multijob_finish_one
-# @DESCRIPTION:
-# Wait for a single process to exit and return its exit code.
-multijob_finish_one() {
-	[[ $# -eq 0 ]] || die "${FUNCNAME} takes no arguments"
-
-	local pid ret
-	read -r -u ${mj_read_fd} pid ret || die
-	: $(( --mj_num_jobs ))
-	return ${ret}
-}
-
-# @FUNCTION: multijob_finish
-# @DESCRIPTION:
-# Wait for all pending processes to exit and return the bitwise or
-# of all their exit codes.
-multijob_finish() {
-	local ret=0
-	while [[ ${mj_num_jobs} -gt 0 ]] ; do
-		multijob_finish_one
-		: $(( ret |= $? ))
-	done
-	# Let bash clean up its internal child tracking state.
-	wait
-
-	# Do this after reaping all the children.
-	[[ $# -eq 0 ]] || die "${FUNCNAME} takes no arguments"
-
-	# No need to hook anymore.
-	EBUILD_DEATH_HOOKS=${EBUILD_DEATH_HOOKS/ wait / }
-
-	return ${ret}
-}
-
 # @FUNCTION: redirect_alloc_fd
 # @USAGE: <var> <file> [redirection]
 # @DESCRIPTION:

diff --git a/eclass/tests/multiprocessing.sh b/eclass/tests/multiprocessing.sh
deleted file mode 100755
index 1ceb7f7fa7b..00000000000
--- a/eclass/tests/multiprocessing.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-source tests-common.sh
-
-inherit multiprocessing
-
-tbegin "simple"
-MAKEOPTS="-j1" multijob_init
-multijob_child_init ls -d / >/dev/null || die "fail!"
-multijob_finish
-tend $?
-
-tbegin "less simple"
-multijob_init -j3
-multijob_child_init true  || die "fail!"
-multijob_child_init false || die "fail!"
-multijob_child_init true  || die "fail!"
-multijob_finish
-tend $(( $? == 1 ? 0 : 1 ))
-
-tbegin "less less simple"
-multijob_init -j1
-multijob_child_init true  || die "fail!"
-multijob_child_init false || die "fail!"
-multijob_child_init true  && die "fail!"
-multijob_finish
-tend $?
-
-tbegin "less less less simple"
-multijob_init -j10
-multijob_child_init true  || die "fail!"
-multijob_finish_one       || die "fail!"
-multijob_child_init false || die "fail!"
-multijob_finish_one       && die "fail!"
-multijob_child_init true  || die "fail!"
-multijob_finish_one       || die "fail!"
-multijob_finish
-tend $?
-
-texit


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2018-04-18 18:13 Mike Gilbert
  0 siblings, 0 replies; 41+ messages in thread
From: Mike Gilbert @ 2018-04-18 18:13 UTC (permalink / raw
  To: gentoo-commits

commit:     1e64d3ebf9edf0f02cc271faa9c3eaedeb6d280d
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 13 16:04:53 2018 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Wed Apr 18 18:13:10 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1e64d3eb

flag-o-matic.eclass: treat "--param x" as a unit when testing flags

For clang and gcc, --param consumes the next argument. Testing --param
and its value separately is nonsensical.

Acked-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 eclass/flag-o-matic.eclass   | 33 +++++++++++++++++++++++----------
 eclass/tests/flag-o-matic.sh |  4 ++--
 2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 14b84fbdbeb..5ab14b08d6e 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -421,9 +421,9 @@ strip-flags() {
 test-flag-PROG() {
 	local comp=$1
 	local lang=$2
-	local flag=$3
+	shift 2
 
-	[[ -z ${comp} || -z ${flag} ]] && return 1
+	[[ -z ${comp} || -z $1 ]] && return 1
 
 	local cmdline=(
 		$(tc-get${comp})
@@ -434,11 +434,11 @@ test-flag-PROG() {
 		-c -o /dev/null
 	)
 	if "${cmdline[@]}" -x${lang} - </dev/null &>/dev/null ; then
-		cmdline+=( "${flag}" -x${lang} - )
+		cmdline+=( "$@" -x${lang} - )
 	else
 		# XXX: what's the purpose of this? does it even work with
 		# any compiler?
-		cmdline+=( "${flag}" -c -o /dev/null /dev/null )
+		cmdline+=( "$@" -c -o /dev/null /dev/null )
 	fi
 
 	if ! "${cmdline[@]}" </dev/null &>/dev/null; then
@@ -455,25 +455,25 @@ test-flag-PROG() {
 # @USAGE: <flag>
 # @DESCRIPTION:
 # Returns shell true if <flag> is supported by the C compiler, else returns shell false.
-test-flag-CC() { test-flag-PROG "CC" c "$1"; }
+test-flag-CC() { test-flag-PROG "CC" c "$@"; }
 
 # @FUNCTION: test-flag-CXX
 # @USAGE: <flag>
 # @DESCRIPTION:
 # Returns shell true if <flag> is supported by the C++ compiler, else returns shell false.
-test-flag-CXX() { test-flag-PROG "CXX" c++ "$1"; }
+test-flag-CXX() { test-flag-PROG "CXX" c++ "$@"; }
 
 # @FUNCTION: test-flag-F77
 # @USAGE: <flag>
 # @DESCRIPTION:
 # Returns shell true if <flag> is supported by the Fortran 77 compiler, else returns shell false.
-test-flag-F77() { test-flag-PROG "F77" f77 "$1"; }
+test-flag-F77() { test-flag-PROG "F77" f77 "$@"; }
 
 # @FUNCTION: test-flag-FC
 # @USAGE: <flag>
 # @DESCRIPTION:
 # Returns shell true if <flag> is supported by the Fortran 90 compiler, else returns shell false.
-test-flag-FC() { test-flag-PROG "FC" f95 "$1"; }
+test-flag-FC() { test-flag-PROG "FC" f95 "$@"; }
 
 test-flags-PROG() {
 	local comp=$1
@@ -484,8 +484,21 @@ test-flags-PROG() {
 
 	[[ -z ${comp} ]] && return 1
 
-	for x ; do
-		test-flag-${comp} "${x}" && flags+=( "${x}" )
+	while (( $# )); do
+		case "$1" in
+			--param)
+				if test-flag-${comp} "$1" "$2"; then
+					flags+=( "$1" "$2" )
+				fi
+				shift 2
+				;;
+			*)
+				if test-flag-${comp} "$1"; then
+					flags+=( "$1" )
+				fi
+				shift 1
+				;;
+		esac
 	done
 
 	echo "${flags[*]}"

diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
index 53af9f862c4..97cd71d710a 100755
--- a/eclass/tests/flag-o-matic.sh
+++ b/eclass/tests/flag-o-matic.sh
@@ -6,7 +6,7 @@ source tests-common.sh
 
 inherit flag-o-matic
 
-CFLAGS="-a -b -c=1"
+CFLAGS="-a -b -c=1 --param l1-cache-size=32"
 CXXFLAGS="-x -y -z=2"
 LDFLAGS="-l -m -n=3"
 ftend() {
@@ -55,7 +55,7 @@ done <<<"
 
 tbegin "strip-unsupported-flags"
 strip-unsupported-flags
-[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]] && [[ ${LDFLAGS} == "" ]]
+[[ ${CFLAGS} == "--param l1-cache-size=32" ]] && [[ ${CXXFLAGS} == "-z=2" ]] && [[ ${LDFLAGS} == "" ]]
 ftend
 
 for var in $(all-flag-vars) ; do


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2019-12-24 11:01 Sergei Trofimovich
  0 siblings, 0 replies; 41+ messages in thread
From: Sergei Trofimovich @ 2019-12-24 11:01 UTC (permalink / raw
  To: gentoo-commits

commit:     28d6437fc7009002f98f28e8900e994109927726
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 23 11:41:20 2019 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Tue Dec 24 11:01:01 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=28d6437f

flag-o-matic.eclass: add LDFLAGS testing against linker

Before the change we tested only compiler driver (gcc flag parser)
for LDFLAGS.

This does not cover cases when we would really like to filter out
unsupported linker flags like -Wl,--hash-style=gnu passed to non-ELF
targets.

The change adds test-flag-CCLD() helper to perform all of assembly,
compilation and linking steps. Helper is used to filter LDFLAGS variable
in strip-unsupported-flags().

Closes: https://bugs.gentoo.org/333763
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 eclass/flag-o-matic.eclass   | 72 +++++++++++++++++++++++++++++++++++---------
 eclass/tests/flag-o-matic.sh |  2 +-
 2 files changed, 59 insertions(+), 15 deletions(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index f882b09d621..0aec22c83f2 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -441,29 +441,63 @@ test-flag-PROG() {
 	# 'type' needs a binary name
 	type -p ${comp[0]} >/dev/null || return 1
 
+	# Set up test file.
+	local in_src in_ext cmdline_extra=()
+	case "${lang}" in
+		# compiler/assembler only
+		c)
+			in_ext='.c'
+			in_src='int main(void) { return 0; }'
+			cmdline_extra+=(-xc -c)
+			;;
+		c++)
+			in_ext='.cc'
+			in_src='int main(void) { return 0; }'
+			cmdline_extra+=(-xc++ -c)
+			;;
+		f77)
+			in_ext='.f'
+			# fixed source form
+			in_src='      end'
+			cmdline_extra+=(-xf77 -c)
+			;;
+		f95)
+			in_ext='.f90'
+			in_src='end'
+			cmdline_extra+=(-xf95 -c)
+			;;
+
+		# C compiler/assembler/linker
+		c+ld)
+			in_ext='.c'
+			in_src='int main(void) { return 0; }'
+			cmdline_extra+=(-xc)
+			;;
+	esac
+	local test_in=${T}/test-flag-${comp}.${lang}
+	local test_out=${T}/test-flag-${comp}.exe
+
+	printf "%s\n" "${in_src}" > "${test_in}" || return 1
+
 	local cmdline=(
 		"${comp[@]}"
 		# Clang will warn about unknown gcc flags but exit 0.
 		# Need -Werror to force it to exit non-zero.
 		-Werror
-		# Use -c so we can test the assembler as well.
-		-c -o /dev/null
+		"$@"
+		# -x<lang> options need to go before first source file
+		"${cmdline_extra[@]}"
+
+		"${test_in}" -o "${test_out}"
 	)
-	if "${cmdline[@]}" -x${lang} - </dev/null &>/dev/null ; then
-		cmdline+=( "$@" -x${lang} - )
-	else
-		# XXX: what's the purpose of this? does it even work with
-		# any compiler?
-		cmdline+=( "$@" -c -o /dev/null /dev/null )
-	fi
 
-	if ! "${cmdline[@]}" </dev/null &>/dev/null; then
+	if ! "${cmdline[@]}" &>/dev/null; then
 		# -Werror makes clang bail out on unused arguments as well;
 		# try to add -Qunused-arguments to work-around that
 		# other compilers don't support it but then, it's failure like
 		# any other
 		cmdline+=( -Qunused-arguments )
-		"${cmdline[@]}" </dev/null &>/dev/null
+		"${cmdline[@]}" &>/dev/null
 	fi
 }
 
@@ -491,6 +525,12 @@ test-flag-F77() { test-flag-PROG "F77" f77 "$@"; }
 # Returns shell true if <flag> is supported by the Fortran 90 compiler, else returns shell false.
 test-flag-FC() { test-flag-PROG "FC" f95 "$@"; }
 
+# @FUNCTION: test-flag-CCLD
+# @USAGE: <flag>
+# @DESCRIPTION:
+# Returns shell true if <flag> is supported by the C compiler and linker, else returns shell false.
+test-flag-CCLD() { test-flag-PROG "CC" c+ld "$@"; }
+
 test-flags-PROG() {
 	local comp=$1
 	local flags=()
@@ -548,6 +588,12 @@ test-flags-F77() { test-flags-PROG "F77" "$@"; }
 # Returns shell true if <flags> are supported by the Fortran 90 compiler, else returns shell false.
 test-flags-FC() { test-flags-PROG "FC" "$@"; }
 
+# @FUNCTION: test-flags-CCLD
+# @USAGE: <flags>
+# @DESCRIPTION:
+# Returns shell true if <flags> are supported by the C compiler and default linker, else returns shell false.
+test-flags-CCLD() { test-flags-PROG "CCLD" "$@"; }
+
 # @FUNCTION: test-flags
 # @USAGE: <flags>
 # @DESCRIPTION:
@@ -576,9 +622,7 @@ strip-unsupported-flags() {
 	export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS})
 	export FFLAGS=$(test-flags-F77 ${FFLAGS})
 	export FCFLAGS=$(test-flags-FC ${FCFLAGS})
-	# note: this does not verify the linker flags but it is enough
-	# to strip invalid C flags which are much more likely, #621274
-	export LDFLAGS=$(test-flags-CC ${LDFLAGS})
+	export LDFLAGS=$(test-flags-CCLD ${LDFLAGS})
 }
 
 # @FUNCTION: get-flag

diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
index 7c078499d70..90eaf3a6ffb 100755
--- a/eclass/tests/flag-o-matic.sh
+++ b/eclass/tests/flag-o-matic.sh
@@ -8,7 +8,7 @@ inherit flag-o-matic
 
 CFLAGS="-a -b -c=1 --param l1-cache-size=32"
 CXXFLAGS="-x -y -z=2"
-LDFLAGS="-l -m -n=3"
+LDFLAGS="-l -m -n=3 -Wl,--remove-me"
 ftend() {
 	local ret=$?
 	local msg="Failed; flags are:"


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2019-12-30 12:59 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2019-12-30 12:59 UTC (permalink / raw
  To: gentoo-commits

commit:     8844b4c200dc82d7d09547b3d913f011f05cf592
Author:     David Seifert <soap <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 30 00:48:32 2019 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec 30 12:58:51 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8844b4c2

python-utils-r1.eclass: Remove PYTHON_TARGETS="pypy"

* With the EOL of CPython 2, we also want to
  remove support for PyPy (i.e. PyPy for Python 2).
  This change does not affect PyPy3, i.e. Pypy for
  Python 3.

Signed-off-by: David Seifert <soap <AT> gentoo.org>
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/python-utils-r1.eclass   | 6 +++---
 eclass/tests/python-utils-r1.sh | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 370898bcea0..09b501a4ad2 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -40,7 +40,7 @@ inherit toolchain-funcs
 # All supported Python implementations, most preferred last.
 _PYTHON_ALL_IMPLS=(
 	jython2_7
-	pypy pypy3
+	pypy3
 	python2_7
 	python3_6 python3_7 python3_8
 )
@@ -78,10 +78,10 @@ _python_impl_supported() {
 	# keep in sync with _PYTHON_ALL_IMPLS!
 	# (not using that list because inline patterns shall be faster)
 	case "${impl}" in
-		python2_7|python3_[678]|jython2_7|pypy|pypy3)
+		python2_7|python3_[678]|jython2_7|pypy3)
 			return 0
 			;;
-		pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])
+		pypy|pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])
 			return 1
 			;;
 		*)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index df77a3fcf6e..f8d4858da7c 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -188,7 +188,7 @@ test_is "_python_impl_supported python3_8" 0
 test_is "_python_impl_supported pypy1_8" 1
 test_is "_python_impl_supported pypy1_9" 1
 test_is "_python_impl_supported pypy2_0" 1
-test_is "_python_impl_supported pypy" 0
+test_is "_python_impl_supported pypy" 1
 test_is "_python_impl_supported pypy3" 0
 test_is "_python_impl_supported jython2_7" 0
 


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2019-12-30 12:59 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2019-12-30 12:59 UTC (permalink / raw
  To: gentoo-commits

commit:     f0f388d6e7b7990006384bd024ec5bf2d7f66737
Author:     David Seifert <soap <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 30 00:48:32 2019 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec 30 12:58:50 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f0f388d6

python-utils-r1.eclass: Remove PYTHON_TARGETS="python3_5"

* Python 3.5 will go EOL on 2020-09-13 and in order to reduce testing
  and maintenance burden, we want to keep the number of active Py3
  impls below four.

  https://devguide.python.org/#status-of-python-branches

Signed-off-by: David Seifert <soap <AT> gentoo.org>
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/python-utils-r1.eclass   | 6 +++---
 eclass/tests/python-utils-r1.sh | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index e0711a35e3a..370898bcea0 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -42,7 +42,7 @@ _PYTHON_ALL_IMPLS=(
 	jython2_7
 	pypy pypy3
 	python2_7
-	python3_5 python3_6 python3_7 python3_8
+	python3_6 python3_7 python3_8
 )
 readonly _PYTHON_ALL_IMPLS
 
@@ -78,10 +78,10 @@ _python_impl_supported() {
 	# keep in sync with _PYTHON_ALL_IMPLS!
 	# (not using that list because inline patterns shall be faster)
 	case "${impl}" in
-		python2_7|python3_[5678]|jython2_7|pypy|pypy3)
+		python2_7|python3_[678]|jython2_7|pypy|pypy3)
 			return 0
 			;;
-		pypy1_[89]|pypy2_0|python2_[56]|python3_[1234])
+		pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])
 			return 1
 			;;
 		*)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index e883da38cea..df77a3fcf6e 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -181,7 +181,7 @@ test_is "_python_impl_supported python3_1" 1
 test_is "_python_impl_supported python3_2" 1
 test_is "_python_impl_supported python3_3" 1
 test_is "_python_impl_supported python3_4" 1
-test_is "_python_impl_supported python3_5" 0
+test_is "_python_impl_supported python3_5" 1
 test_is "_python_impl_supported python3_6" 0
 test_is "_python_impl_supported python3_7" 0
 test_is "_python_impl_supported python3_8" 0


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2020-01-11 23:53 Sergei Trofimovich
  0 siblings, 0 replies; 41+ messages in thread
From: Sergei Trofimovich @ 2020-01-11 23:53 UTC (permalink / raw
  To: gentoo-commits

commit:     12bfa1e4f9595dbbcbe0a442c6a63bc3ef890cc2
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 11 23:11:13 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sat Jan 11 23:53:08 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=12bfa1e4

toolchain.eclass: fix arch downgrade for gcc-10

The bug is in lexical comparison instead of version compare.

Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 eclass/tests/toolchain.sh | 12 +++++++++++-
 eclass/toolchain.eclass   | 17 +++++++++--------
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/eclass/tests/toolchain.sh b/eclass/tests/toolchain.sh
index 56609aa180e..1d05f6c126b 100755
--- a/eclass/tests/toolchain.sh
+++ b/eclass/tests/toolchain.sh
@@ -12,6 +12,12 @@ source tests-common.sh
 
 inherit toolchain
 
+# Ignore actually running version of gcc and fake new version
+# to force downgrade test on all conditions below.
+gcc-version() {
+	echo "99.99"
+}
+
 test_downgrade_arch_flags() {
 	local exp msg ret=0 ver
 
@@ -26,13 +32,14 @@ test_downgrade_arch_flags() {
 	downgrade_arch_flags ${ver}
 
 	if [[ ${CFLAGS} != ${exp} ]]; then
-		msg="Failure - Expected: \"${exp}\" Got: \"${CFLAGS}\""
+		msg="Failure - Expected: \"${exp}\" Got: \"${CFLAGS}\" Ver: ${ver}"
 		ret=1
 	fi
 	tend ${ret} ${msg}
 }
 
 #                         ver  expected            given
+test_downgrade_arch_flags 10  "-march=haswell"    "-march=haswell"
 test_downgrade_arch_flags 4.9 "-march=haswell"    "-march=haswell"
 test_downgrade_arch_flags 4.8 "-march=core-avx2"  "-march=haswell"
 test_downgrade_arch_flags 4.7 "-march=core-avx2"  "-march=haswell"
@@ -64,6 +71,7 @@ test_downgrade_arch_flags 3.3 "-march=c3"         "-march=c3-2"
 
 test_downgrade_arch_flags 4.5 "-march=garbage"    "-march=garbage"
 
+test_downgrade_arch_flags 10  "-mtune=intel"      "-mtune=intel"
 test_downgrade_arch_flags 4.9 "-mtune=intel"      "-mtune=intel"
 test_downgrade_arch_flags 4.8 "-mtune=generic"    "-mtune=intel"
 test_downgrade_arch_flags 3.4 ""                  "-mtune=generic"
@@ -74,9 +82,11 @@ test_downgrade_arch_flags 4.5 "-march=amdfam10 -mtune=generic" "-march=btver2 -m
 test_downgrade_arch_flags 3.3 "-march=k6-2"       "-march=geode -mtune=barcelona"
 test_downgrade_arch_flags 3.4 "-march=k8"         "-march=btver2 -mtune=generic"
 
+test_downgrade_arch_flags 10  "-march=native"     "-march=native"
 test_downgrade_arch_flags 4.2 "-march=native"     "-march=native"
 test_downgrade_arch_flags 4.1 "-march=nocona"     "-march=native"
 
+test_downgrade_arch_flags 10  "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
 test_downgrade_arch_flags 4.9 "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
 test_downgrade_arch_flags 4.8 "-march=foo -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
 test_downgrade_arch_flags 4.7 "-march=foo -mno-avx2 -mno-avx -mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 5f9bd7750dd..bd3d024f989 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1406,7 +1406,8 @@ downgrade_arch_flags() {
 	local arch bver i isa myarch mytune rep ver
 
 	bver=${1:-${GCC_BRANCH_VER}}
-	[[ $(gcc-version) < ${bver} ]] && return 0
+	# Don't perform downgrade if running gcc is older than ebuild's.
+	tc_version_is_at_least ${bver} $(gcc-version) || return 0
 	[[ $(tc-arch) != amd64 && $(tc-arch) != x86 ]] && return 0
 
 	myarch=$(get-flag march)
@@ -1414,7 +1415,7 @@ downgrade_arch_flags() {
 
 	# If -march=native isn't supported we have to tease out the actual arch
 	if [[ ${myarch} == native || ${mytune} == native ]] ; then
-		if [[ ${bver} < 4.2 ]] ; then
+		if ! tc_version_is_at_least 4.2 ${bver}; then
 			arch=$($(tc-getCC) -march=native -v -E -P - </dev/null 2>&1 \
 				| sed -rn "/cc1.*-march/s:.*-march=([^ ']*).*:\1:p")
 			replace-cpu-flags native ${arch}
@@ -1422,10 +1423,10 @@ downgrade_arch_flags() {
 	fi
 
 	# Handle special -mtune flags
-	[[ ${mytune} == intel && ${bver} < 4.9 ]] && replace-cpu-flags intel generic
-	[[ ${mytune} == generic && ${bver} < 4.2 ]] && filter-flags '-mtune=*'
+	[[ ${mytune} == intel ]] && ! tc_version_is_at_least 4.9 ${bver} && replace-cpu-flags intel generic
+	[[ ${mytune} == generic ]] && ! tc_version_is_at_least 4.2 ${bver} && filter-flags '-mtune=*'
 	[[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*'
-	[[ ${bver} < 3.4 ]] && filter-flags '-mtune=*'
+	tc_version_is_at_least 3.4 ${bver} || filter-flags '-mtune=*'
 
 	# "added" "arch" "replacement"
 	local archlist=(
@@ -1475,8 +1476,8 @@ downgrade_arch_flags() {
 
 		[[ ${myarch} != ${arch} && ${mytune} != ${arch} ]] && continue
 
-		if [[ ${ver} > ${bver} ]] ; then
-			einfo "Replacing ${myarch} (added in gcc ${ver}) with ${rep}..."
+		if ! tc_version_is_at_least ${ver} ${bver}; then
+			einfo "Downgrading '${myarch}' (added in gcc ${ver}) with '${rep}'..."
 			[[ ${myarch} == ${arch} ]] && replace-cpu-flags ${myarch} ${rep}
 			[[ ${mytune} == ${arch} ]] && replace-cpu-flags ${mytune} ${rep}
 			continue
@@ -1524,7 +1525,7 @@ downgrade_arch_flags() {
 	for ((i = 0; i < ${#isalist[@]}; i += 2)) ; do
 		ver=${isalist[i]}
 		isa=${isalist[i + 1]}
-		[[ ${ver} > ${bver} ]] && filter-flags ${isa} ${isa/-m/-mno-}
+		tc_version_is_at_least ${ver} ${bver} || filter-flags ${isa} ${isa/-m/-mno-}
 	done
 }
 


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2020-03-26  7:51 Sergei Trofimovich
  0 siblings, 0 replies; 41+ messages in thread
From: Sergei Trofimovich @ 2020-03-26  7:51 UTC (permalink / raw
  To: gentoo-commits

commit:     a5003d48705fa9b501022d4e6326c8f516a2eec0
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 26 07:49:07 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Thu Mar 26 07:50:41 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a5003d48

flag-o-matic.eclass: revert "don't use -Werror in test-flag-PROG(), bug #712488"

This reverts commit ab8fe14ae2e9110faa85ca1c4528b470c0be1535.
Triggers build failures on sys-libs/compiler-rt-sanitizers.

Reported-by: Craig Andrews
Bug: https://bugs.gentoo.org/714742
Bug: https://bugs.gentoo.org/712488
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 eclass/flag-o-matic.eclass   | 19 +++++++++++--------
 eclass/tests/flag-o-matic.sh | 10 ++++------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index d8111fb9e38..9ef9ac3685e 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -487,15 +487,11 @@ test-flag-PROG() {
 
 	printf "%s\n" "${in_src}" > "${test_in}" || die "Failed to create '${test_in}'"
 
-	# Don't set -Werror as there are cases when benign
-	# always-on warnings filter out all flags like bug #712488.
-	# We'll have to live with potential '-Wunused-command-line-argument'.
-	# flags.
-	#
-	# We can add more selective detection of no-op flags via
-	# '-Werror=ignored-optimization-argument' and similar error options.
 	local cmdline=(
 		"${comp[@]}"
+		# Clang will warn about unknown gcc flags but exit 0.
+		# Need -Werror to force it to exit non-zero.
+		-Werror
 		"$@"
 		# -x<lang> options need to go before first source file
 		"${cmdline_extra[@]}"
@@ -503,7 +499,14 @@ test-flag-PROG() {
 		"${test_in}" -o "${test_out}"
 	)
 
-	"${cmdline[@]}" &>/dev/null
+	if ! "${cmdline[@]}" &>/dev/null; then
+		# -Werror makes clang bail out on unused arguments as well;
+		# try to add -Qunused-arguments to work-around that
+		# other compilers don't support it but then, it's failure like
+		# any other
+		cmdline+=( -Qunused-arguments )
+		"${cmdline[@]}" &>/dev/null
+	fi
 }
 
 # @FUNCTION: test-flag-CC

diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
index 6dfacb04c07..229dff52af9 100755
--- a/eclass/tests/flag-o-matic.sh
+++ b/eclass/tests/flag-o-matic.sh
@@ -161,12 +161,10 @@ out=$(CC=clang test-flags-CC -finvalid-flag)
 [[ $? -ne 0 && -z ${out} ]]
 ftend
 
-### '-finline-limit=1200' is 'ignored' flag, not invalid.
-### We don't filter out ignored flags currently, bug #712488
-#tbegin "test-flags-CC (gcc-valid but clang-invalid flags)"
-#out=$(CC=clang test-flags-CC -finline-limit=1200)
-#[[ $? -ne 0 && -z ${out} ]]
-#ftend
+tbegin "test-flags-CC (gcc-valid but clang-invalid flags)"
+out=$(CC=clang test-flags-CC -finline-limit=1200)
+[[ $? -ne 0 && -z ${out} ]]
+ftend
 
 tbegin "test-flags-CC (unused flags w/clang)"
 out=$(CC=clang test-flags-CC -Wl,-O1)


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2020-03-28 19:54 Sergei Trofimovich
  0 siblings, 0 replies; 41+ messages in thread
From: Sergei Trofimovich @ 2020-03-28 19:54 UTC (permalink / raw
  To: gentoo-commits

commit:     1a687fd280c3d33cbf7ef99cd6f96fda95039c75
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 28 19:53:49 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sat Mar 28 19:54:47 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1a687fd2

eclass/multilib.eclass: update copyright and fix typos

Reported-by: Mike Gilbert
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 eclass/multilib.eclass   | 2 +-
 eclass/tests/multilib.sh | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass
index 8b4a7dacaa3..bbaab709b4f 100644
--- a/eclass/multilib.eclass
+++ b/eclass/multilib.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: multilib.eclass

diff --git a/eclass/tests/multilib.sh b/eclass/tests/multilib.sh
index 68c0dd6e142..a483d4bef36 100755
--- a/eclass/tests/multilib.sh
+++ b/eclass/tests/multilib.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2020 Gentoo Foundation
+# Copyright 2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 source tests-common.sh
@@ -46,7 +46,7 @@ test-multilib_env() {
 	fi
 }
 
-# Pick a few interesting gargets from:
+# Pick a few interesting targets from:
 # $ grep -h -o -R 'CHOST=.*' ../../profiles/ | sort -u
 
 test-multilib_env \


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2020-05-25  6:12 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2020-05-25  6:12 UTC (permalink / raw
  To: gentoo-commits

commit:     e563ed3af0dad1d3eaa165f5eb89b6f7ed0a1c9c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon May 25 06:04:34 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon May 25 06:07:18 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e563ed3a

python-utils-r1.eclass: Enable python3_9

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/python-utils-r1.eclass   |  4 ++--
 eclass/tests/python-utils-r1.sh | 16 +++++++++++++++-
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 4af710da363..1067d2367ab 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -41,7 +41,7 @@ inherit toolchain-funcs
 _PYTHON_ALL_IMPLS=(
 	pypy3
 	python2_7
-	python3_6 python3_7 python3_8
+	python3_6 python3_7 python3_8 python3_9
 )
 readonly _PYTHON_ALL_IMPLS
 
@@ -77,7 +77,7 @@ _python_impl_supported() {
 	# keep in sync with _PYTHON_ALL_IMPLS!
 	# (not using that list because inline patterns shall be faster)
 	case "${impl}" in
-		python2_7|python3_[678]|pypy3)
+		python2_7|python3_[6789]|pypy3)
 			return 0
 			;;
 		jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 192c1183e80..86b87ec173d 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -115,6 +115,20 @@ fi
 test_var PYTHON_PKG_DEP python3_8 '*dev-lang/python*:3.8'
 test_var PYTHON_SCRIPTDIR python3_8 /usr/lib/python-exec/python3.8
 
+test_var EPYTHON python3_9 python3.9
+test_var PYTHON python3_9 /usr/bin/python3.9
+if [[ -x /usr/bin/python3.9 ]]; then
+	abiflags=$(/usr/bin/python3.9 -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS"))')
+	test_var PYTHON_SITEDIR python3_9 "/usr/lib/python3.9/site-packages"
+	test_var PYTHON_INCLUDEDIR python3_9 "/usr/include/python3.9${abiflags}"
+	test_var PYTHON_LIBPATH python3_9 "/usr/lib*/libpython3.9${abiflags}$(get_libname)"
+	test_var PYTHON_CONFIG python3_9 "/usr/bin/python3.9${abiflags}-config"
+	test_var PYTHON_CFLAGS python3_9 "*-I/usr/include/python3.9*"
+	test_var PYTHON_LIBS python3_9 "*-lpython3.9*"
+fi
+test_var PYTHON_PKG_DEP python3_9 '*dev-lang/python*:3.9'
+test_var PYTHON_SCRIPTDIR python3_9 /usr/lib/python-exec/python3.9
+
 test_var EPYTHON pypy3 pypy3
 test_var PYTHON pypy3 /usr/bin/pypy3
 if [[ -x /usr/bin/pypy3 ]]; then


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2021-01-05 23:01 Sergei Trofimovich
  0 siblings, 0 replies; 41+ messages in thread
From: Sergei Trofimovich @ 2021-01-05 23:01 UTC (permalink / raw
  To: gentoo-commits

commit:     f8ed334c4a1f2a9802f898663b3facac5ec15e01
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  5 22:40:59 2021 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Tue Jan  5 23:01:37 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f8ed334c

toolchain-funcs.eclass: fix or1k* tuple detection

Before the change the only recognised CHOST was 'or1k'.
After the change CHOSTs like 'or1k-linux-musl' are
also recognised as 'openrisc'.

Reported-by: adam <AT> pimentel.space
Bug: https://bugs.gentoo.org/763606
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 eclass/tests/toolchain-funcs.sh | 3 ++-
 eclass/toolchain-funcs.eclass   | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh
index a0a56fd9e5d..23ac568c4a5 100755
--- a/eclass/tests/toolchain-funcs.sh
+++ b/eclass/tests/toolchain-funcs.sh
@@ -27,7 +27,8 @@ test-tc-arch-kernel() {
 tbegin "tc-arch-kernel() (KV=2.6.30)"
 test-tc-arch-kernel 2.6.30 \
 	i{3..6}86:x86 x86_64:x86 \
-	powerpc{,64}:powerpc i{3..6}86-gentoo-freebsd:i386
+	powerpc{,64}:powerpc i{3..6}86-gentoo-freebsd:i386 \
+	or1k:openrisc or1k-linux-musl:openrisc
 tend $?
 
 #

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index ec7b920bcfa..4a4bb27fc08 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -665,7 +665,7 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
 		mips*)		echo mips;;
 		nios2*)		echo nios2;;
 		nios*)		echo nios;;
-		or1k|or32*)	echo openrisc;;
+		or1k*|or32*)	echo openrisc;;
 		powerpc*)
 			# Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees
 			# have been unified into simply 'powerpc', but until 2.6.16,


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2021-01-15 17:05 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2021-01-15 17:05 UTC (permalink / raw
  To: gentoo-commits

commit:     10da6fd3ccd3ba547cb855371b670db909cb165c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 31 11:18:04 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jan 15 17:05:53 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=10da6fd3

python-utils-r1.eclass: Inline _python_impl_supported()

The _python_impl_supported() function is not used anymore in its
original function.  It is called only once, in order to die on incorrect
targets in PYTHON_COMPAT.  Let's inline the corresponding logic
in _python_set_impls() and remove the function.

While at it, add an extra check for outdated patterns.  This also
renders the relevant tests obsolete.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/python-utils-r1.eclass   | 56 +++++++++++++++--------------------------
 eclass/tests/python-utils-r1.sh | 18 -------------
 2 files changed, 20 insertions(+), 54 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 9c8b6a14d2a..2aa953213b6 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -69,38 +69,6 @@ readonly _PYTHON_HISTORICAL_IMPLS
 # which can involve revisions of this eclass that support a different
 # set of Python implementations.
 
-# @FUNCTION: _python_impl_supported
-# @USAGE: <impl>
-# @INTERNAL
-# @DESCRIPTION:
-# Check whether the implementation <impl> (PYTHON_COMPAT-form)
-# is still supported.
-#
-# Returns 0 if the implementation is valid and supported. If it is
-# unsupported, returns 1 -- and the caller should ignore the entry.
-# If it is invalid, dies with an appopriate error messages.
-_python_impl_supported() {
-	debug-print-function ${FUNCNAME} "${@}"
-
-	[[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl)."
-
-	local impl=${1}
-
-	# keep in sync with _PYTHON_ALL_IMPLS!
-	# (not using that list because inline patterns shall be faster)
-	case "${impl}" in
-		python2_7|python3_[6789]|pypy3)
-			return 0
-			;;
-		jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])
-			return 1
-			;;
-		*)
-			[[ ${PYTHON_COMPAT_NO_STRICT} ]] && return 1
-			die "Invalid implementation in PYTHON_COMPAT: ${impl}"
-	esac
-}
-
 # @FUNCTION: _python_verify_patterns
 # @USAGE: <pattern>...
 # @INTERNAL
@@ -149,10 +117,26 @@ _python_set_impls() {
 	if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
 		die 'PYTHON_COMPAT must be an array.'
 	fi
-	for i in "${PYTHON_COMPAT[@]}"; do
-		# trigger validity checks
-		_python_impl_supported "${i}"
-	done
+	if [[ ! ${PYTHON_COMPAT_NO_STRICT} ]]; then
+		for i in "${PYTHON_COMPAT[@]}"; do
+			# check for incorrect implementations
+			# we're using pattern matching as an optimization
+			# please keep them in sync with _PYTHON_ALL_IMPLS
+			# and _PYTHON_HISTORICAL_IMPLS
+			case ${i} in
+				jython2_7|pypy|pypy1_[89]|pypy2_0|pypy3|python2_[5-7]|python3_[1-9])
+					;;
+				*)
+					if has "${i}" "${_PYTHON_ALL_IMPLS[@]}" \
+						"${_PYTHON_HISTORICAL_IMPLS[@]}"
+					then
+						die "Mis-synced patterns in _python_set_impls: missing ${i}"
+					else
+						die "Invalid implementation in PYTHON_COMPAT: ${i}"
+					fi
+			esac
+		done
+	fi
 
 	local supp=() unsupp=()
 

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 86b87ec173d..eb8223ec6ac 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -183,24 +183,6 @@ test_fix_shebang '#!/usr/bin/foo' python2.7 FAIL
 # regression test for bug #522080
 test_fix_shebang '#!/usr/bin/python ' python2.7 '#!/usr/bin/python2.7 '
 
-# make sure we don't break pattern matching
-test_is "_python_impl_supported python2_5" 1
-test_is "_python_impl_supported python2_6" 1
-test_is "_python_impl_supported python2_7" 0
-test_is "_python_impl_supported python3_1" 1
-test_is "_python_impl_supported python3_2" 1
-test_is "_python_impl_supported python3_3" 1
-test_is "_python_impl_supported python3_4" 1
-test_is "_python_impl_supported python3_5" 1
-test_is "_python_impl_supported python3_6" 0
-test_is "_python_impl_supported python3_7" 0
-test_is "_python_impl_supported python3_8" 0
-test_is "_python_impl_supported pypy1_8" 1
-test_is "_python_impl_supported pypy1_9" 1
-test_is "_python_impl_supported pypy2_0" 1
-test_is "_python_impl_supported pypy" 1
-test_is "_python_impl_supported pypy3" 0
-
 # check _python_impl_matches behavior
 test_is "_python_impl_matches python2_7 -2" 0
 test_is "_python_impl_matches python3_6 -2" 1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2021-06-23 21:44 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2021-06-23 21:44 UTC (permalink / raw
  To: gentoo-commits

commit:     a0eb5847674c9d295fbc80e2b7c53855cfca5a66
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 20 07:14:32 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 23 21:44:08 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a0eb5847

python-utils-r1.eclass: Deprecated and EAPI8-ban python_is_python3

There is no use for python_is_python3 anymore, as Python 2 is no longer
supported at runtime and the remaining any-r1 uses are pure-2.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/python-utils-r1.eclass   | 3 +++
 eclass/tests/python-utils-r1.sh | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 1a20a3cae99..b435ebaa7ad 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1010,6 +1010,9 @@ _python_wrapper_setup() {
 #
 # Returns 0 (true) if it is, 1 (false) otherwise.
 python_is_python3() {
+	eqawarn "${FUNCNAME} is deprecated, as Python 2 is not supported anymore"
+	[[ ${EAPI} == [67] ]] || die "${FUNCNAME} banned in EAPI ${EAPI}"
+
 	local impl=${1:-${EPYTHON}}
 	[[ ${impl} ]] || die "python_is_python3: no impl nor EPYTHON"
 

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 85a6a53654d..63a94c90b71 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -5,6 +5,10 @@
 EAPI=7
 source tests-common.sh
 
+eqawarn() {
+	: # stub
+}
+
 test_var() {
 	local var=${1}
 	local impl=${2}


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2022-01-09  8:09 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2022-01-09  8:09 UTC (permalink / raw
  To: gentoo-commits

commit:     61d3e4f58783d613521c9cd9d2877c932212e460
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 31 08:59:17 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jan  9 08:09:06 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=61d3e4f5

python-utils-r1.eclass: Bump minimal Python versions

Bump minimal Python package versions to ensure that the python-exec deps
are inside.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/python-utils-r1.eclass       | 10 ++++++++--
 eclass/tests/distutils-r1.sh        |  2 +-
 eclass/tests/distutils-r1_single.sh |  2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 22e00c56815d..ff5b350cd469 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: python-utils-r1.eclass
@@ -416,12 +416,18 @@ _python_export() {
 				case ${impl} in
 					python2.7)
 						PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7';;
+					python3.8)
+						PYTHON_PKG_DEP=">=dev-lang/python-3.8.12_p1-r1:3.8";;
+					python3.9)
+						PYTHON_PKG_DEP=">=dev-lang/python-3.9.9-r1:3.9";;
+					python3.10)
+						PYTHON_PKG_DEP=">=dev-lang/python-3.10.0_p1-r1:3.10";;
 					python*)
 						PYTHON_PKG_DEP="dev-lang/python:${impl#python}";;
 					pypy)
 						PYTHON_PKG_DEP='>=dev-python/pypy-7.3.0:0=';;
 					pypy3)
-						PYTHON_PKG_DEP='>=dev-python/pypy3-7.3.7:0=';;
+						PYTHON_PKG_DEP='>=dev-python/pypy3-7.3.7-r1:0=';;
 					*)
 						die "Invalid implementation: ${impl}"
 				esac

diff --git a/eclass/tests/distutils-r1.sh b/eclass/tests/distutils-r1.sh
index 1ccb1dfbc523..a582bd9bbee7 100755
--- a/eclass/tests/distutils-r1.sh
+++ b/eclass/tests/distutils-r1.sh
@@ -97,7 +97,7 @@ tend
 einfo distutils_enable_tests
 eindent
 BASE_IUSE="python_targets_python3_8"
-BASE_DEPS="python_targets_python3_8? ( dev-lang/python:3.8 ) >=dev-lang/python-exec-2:=[python_targets_python3_8(-)?]"
+BASE_DEPS="python_targets_python3_8? ( >=dev-lang/python-3.8.12_p1-r1:3.8 ) >=dev-lang/python-exec-2:=[python_targets_python3_8(-)?]"
 TEST_RESTRICT="!test? ( test )"
 
 einfo "empty RDEPEND"

diff --git a/eclass/tests/distutils-r1_single.sh b/eclass/tests/distutils-r1_single.sh
index 56b62ca0e90f..8d07eebb133f 100755
--- a/eclass/tests/distutils-r1_single.sh
+++ b/eclass/tests/distutils-r1_single.sh
@@ -77,7 +77,7 @@ inherit distutils-r1
 einfo distutils_enable_tests
 eindent
 BASE_IUSE="+python_single_target_python3_8"
-BASE_DEPS="python_single_target_python3_8? ( dev-lang/python:3.8 >=dev-lang/python-exec-2:=[python_targets_python3_8] )"
+BASE_DEPS="python_single_target_python3_8? ( >=dev-lang/python-3.8.12_p1-r1:3.8 >=dev-lang/python-exec-2:=[python_targets_python3_8] )"
 TEST_RESTRICT="!test? ( test )"
 
 einfo "empty RDEPEND"


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2022-02-09  9:39 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2022-02-09  9:39 UTC (permalink / raw
  To: gentoo-commits

commit:     beda1fe93abc87691239919653283ab0c299e00b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Feb  4 18:47:20 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Feb  9 08:43:51 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=beda1fe9

python-utils-r1.eclass: Remove python_is_python3

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/distutils-r1.eclass      |  8 +++-----
 eclass/python-utils-r1.eclass   | 17 -----------------
 eclass/tests/python-utils-r1.sh |  5 -----
 3 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 0507551897b9..b4bbb7d67e04 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -333,11 +333,9 @@ unset -f _distutils_set_globals
 # (allowing any implementation). If multiple values are specified,
 # implementations matching any of the patterns will be accepted.
 #
-# The patterns can be either fnmatch-style patterns (matched via bash
-# == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
-# appropriately all enabled Python 2/3 implementations (alike
-# python_is_python3). Remember to escape or quote the fnmatch patterns
-# to prevent accidental shell filename expansion.
+# The patterns are fnmatch-style patterns (matched via bash == operator
+# against PYTHON_COMPAT values). Remember to escape or quote the fnmatch
+# patterns to prevent accidental shell filename expansion.
 #
 # If the restriction needs to apply conditionally to a USE flag,
 # the variable should be set conditionally as well (e.g. in an early

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 395e3e6420f4..29ff04d2892c 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -945,23 +945,6 @@ _python_wrapper_setup() {
 	export PATH PKG_CONFIG_PATH
 }
 
-# @FUNCTION: python_is_python3
-# @USAGE: [<impl>]
-# @DESCRIPTION:
-# Check whether <impl> (or ${EPYTHON}) is a Python3k variant
-# (i.e. uses syntax and stdlib of Python 3.*).
-#
-# Returns 0 (true) if it is, 1 (false) otherwise.
-python_is_python3() {
-	eqawarn "${FUNCNAME} is deprecated, as Python 2 is not supported anymore"
-	[[ ${EAPI} == [67] ]] || die "${FUNCNAME} banned in EAPI ${EAPI}"
-
-	local impl=${1:-${EPYTHON}}
-	[[ ${impl} ]] || die "python_is_python3: no impl nor EPYTHON"
-
-	[[ ${impl} == python3* || ${impl} == pypy3 ]]
-}
-
 # @FUNCTION: python_fix_shebang
 # @USAGE: [-f|--force] [-q|--quiet] <path>...
 # @DESCRIPTION:

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 7ba4a864ff10..0244ce26ad0f 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -156,11 +156,6 @@ fi
 test_var PYTHON_PKG_DEP pypy3 '*dev-python/pypy3*:0='
 test_var PYTHON_SCRIPTDIR pypy3 /usr/lib/python-exec/pypy3
 
-test_is "python_is_python3 python2.7" 1
-test_is "python_is_python3 python3.2" 0
-test_is "python_is_python3 pypy" 1
-test_is "python_is_python3 pypy3" 0
-
 # generic shebangs
 test_fix_shebang '#!/usr/bin/python' python3.6 '#!/usr/bin/python3.6'
 test_fix_shebang '#!/usr/bin/python' pypy3 '#!/usr/bin/pypy3'


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2022-05-01  7:30 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2022-05-01  7:30 UTC (permalink / raw
  To: gentoo-commits

commit:     a00223eb88742885325b8863ba080e7d94202d8f
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 28 10:44:02 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun May  1 07:30:36 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a00223eb

multiprocessing.eclass: Default makeopts_jobs to inf=nproc+1

Change the default value for 'inf' argument to makeopts_jobs from 999
to $(get_nproc) + 1.  This means that if MAKEOPTS specifies a `-j`
argument without a specific value, nproc will be used rather than
infinity-ish number of jobs.

The old default made sense for ebuilds using both makeopts_jobs
and makeopts_loadavg.  However, these are very rare — only 4 packages
and 3 eclass at this time.  For the remaining ebuilds, they meant
uncontrollably using up to 999 jobs.

The new default is both safer and more correct for the vast majority
of Gentoo packages, removing the necessity of repeating:

    $(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")

The ebuilds and eclasses using makeopts_loadavg have been updated
to pass the old default.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/multiprocessing.eclass                 | 11 +++++------
 eclass/tests/multiprocessing_makeopts_jobs.sh | 15 ++++++++++-----
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
index c32bfaac2e6b..e55be636a02c 100644
--- a/eclass/multiprocessing.eclass
+++ b/eclass/multiprocessing.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: multiprocessing.eclass
@@ -65,22 +65,21 @@ get_nproc() {
 }
 
 # @FUNCTION: makeopts_jobs
-# @USAGE: [${MAKEOPTS}] [${inf:-999}]
+# @USAGE: [${MAKEOPTS}] [${inf:-$(( $(get_nproc) + 1 ))}]
 # @DESCRIPTION:
 # Searches the arguments (defaults to ${MAKEOPTS}) and extracts the jobs number
 # specified therein.  Useful for running non-make tools in parallel too.
 # i.e. if the user has MAKEOPTS=-j9, this will echo "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.  Since there's
-# no way to represent infinity, we return ${inf} (defaults to 999) if the user
-# has -j without a number.
+# -j flag, then "1" is shown as that is the default `make` uses.  If the flags
+# specify -j without a number, ${inf} is returned (defaults to nproc).
 makeopts_jobs() {
 	[[ $# -eq 0 ]] && set -- "${MAKEOPTS}"
 	# 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:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \
-		-e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-999}:p")
+		-e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-$(( $(get_nproc) + 1 ))}:p")
 	echo ${jobs:-1}
 }
 

diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh b/eclass/tests/multiprocessing_makeopts_jobs.sh
index 70a6085d5362..37d5a7257775 100755
--- a/eclass/tests/multiprocessing_makeopts_jobs.sh
+++ b/eclass/tests/multiprocessing_makeopts_jobs.sh
@@ -16,14 +16,19 @@ test-makeopts_jobs() {
 		tend 1 "Mismatch between MAKEOPTS/cli: '${indirect}' != '${direct}'"
 	else
 		[[ ${direct} == "${exp}" ]]
-		tend $? "Got back: ${act}"
+		tend $? "Got back: ${direct}"
 	fi
 }
 
+# override to avoid relying on a specific value
+get_nproc() {
+	echo 41
+}
+
 tests=(
-	999 "-j"
-	999 "--jobs"
-	999 "-j -l9"
+	42 "-j"
+	42 "--jobs"
+	42 "-j -l9"
 	1 ""
 	1 "-l9 -w"
 	1 "-l9 -w-j4"
@@ -37,7 +42,7 @@ tests=(
 	7 "-l3 --jobs 7 -w"
 	4 "-j1 -j 2 --jobs 3 --jobs=4"
 	8 "     -j        			8     "
-	999 "-kj"
+	42 "-kj"
 	4 "-kj4"
 	5 "-kj 5"
 )


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2022-09-28 20:55 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2022-09-28 20:55 UTC (permalink / raw
  To: gentoo-commits

commit:     725aa5a066e69f5611e40c3cc84660eee07f940c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 28 20:44:47 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Sep 28 20:55:24 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=725aa5a0

unpacker.eclass: Workaround zstd refusing to process symlinks

Closes: https://bugs.gentoo.org/873352
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/tests/unpacker.sh | 7 ++++++-
 eclass/unpacker.eclass   | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/eclass/tests/unpacker.sh b/eclass/tests/unpacker.sh
index b15953966f65..105f28fd4858 100755
--- a/eclass/tests/unpacker.sh
+++ b/eclass/tests/unpacker.sh
@@ -42,9 +42,14 @@ test_unpack() {
 	eval "${packcmd}"
 	assert "packing ${archive} failed"
 	cd testdir || die
+
+	# create a symlink to flush out compressor issues and resemble distdir more
+	# https://bugs.gentoo.org/873352
+	ln -s "../${archive}" "${archive}" || die
+
 	local out
 	out=$(
-		_unpacker "../${archive}" 2>&1
+		_unpacker "${archive}" 2>&1
 	)
 	ret=$?
 	if [[ ${ret} -eq 0 ]]; then

diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
index 3d23151b636e..6c9bcbdd7a7b 100644
--- a/eclass/unpacker.eclass
+++ b/eclass/unpacker.eclass
@@ -523,11 +523,11 @@ _unpacker() {
 	if [[ -z ${arch} ]] ; then
 		# Need to decompress the file into $PWD #408801
 		local _a=${a%.*}
-		${comp} "${a}" > "${_a##*/}"
+		${comp} < "${a}" > "${_a##*/}"
 	elif [[ -z ${comp} ]] ; then
 		${arch} "${a}"
 	else
-		${comp} "${a}" | ${arch} -
+		${comp} < "${a}" | ${arch} -
 	fi
 
 	assert "unpacking ${a} failed (comp=${comp} arch=${arch})"


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2022-10-10 20:52 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2022-10-10 20:52 UTC (permalink / raw
  To: gentoo-commits

commit:     96ddadb40ddba1bfdba68ff8f2fd889cfd004f03
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Oct  7 15:22:01 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Oct 10 20:52:35 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=96ddadb4

toolchain-funcs.eclass: Add tc-get-c-rtlib() to get CC runtime

Add a new tc-get-c-rtlib() that attempts to get the runtime used
by the current C compiler.  Currently it supports compiler-rt
and libgcc.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/tests/toolchain-funcs.sh | 10 ++++++++++
 eclass/toolchain-funcs.eclass   | 28 ++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh
index 5a35a44ce018..d8a357fb24fe 100755
--- a/eclass/tests/toolchain-funcs.sh
+++ b/eclass/tests/toolchain-funcs.sh
@@ -202,6 +202,10 @@ if type -P gcc &>/dev/null; then
 	tbegin "tc-get-cxx-stdlib (gcc)"
 	[[ $(CXX=g++ tc-get-cxx-stdlib) == libstdc++ ]]
 	tend $?
+
+	tbegin "tc-get-c-rtlib (gcc)"
+	[[ $(CC=gcc tc-get-c-rtlib) == libgcc ]]
+	tend $?
 fi
 
 if type -P clang &>/dev/null; then
@@ -218,6 +222,12 @@ if type -P clang &>/dev/null; then
 	tbegin "tc-get-cxx-stdlib (clang, invalid)"
 	! CXX=clang++ CXXFLAGS="-stdlib=invalid" tc-get-cxx-stdlib
 	tend $?
+
+	for rtlib in compiler-rt libgcc; do
+		tbegin "tc-get-c-rtlib (clang, ${rtlib})"
+		[[ $(CC=clang CFLAGS="--rtlib=${rtlib}" tc-get-c-rtlib) == ${rtlib} ]]
+		tend $?
+	done
 fi
 
 texit

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 92494158201e..32e446cb2368 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -1209,4 +1209,32 @@ tc-get-cxx-stdlib() {
 	return 0
 }
 
+# @FUNCTION: tc-get-c-rtlib
+# @DESCRIPTION:
+# Attempt to identify the runtime used by the C/C++ compiler.
+# If the runtime is identifed, the function returns 0 and prints one
+# of the following:
+#
+# - ``compiler-rt`` for ``sys-libs/compiler-rt``
+# - ``libgcc`` for ``sys-devel/gcc``'s libgcc
+#
+# If the runtime is not recognized, the function returns 1.
+tc-get-c-rtlib() {
+	local res=$(
+		$(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} \
+			-print-libgcc-file-name 2>/dev/null
+	)
+
+	case ${res} in
+		*libclang_rt*)
+			echo compiler-rt;;
+		*libgcc*)
+			echo libgcc;;
+		*)
+			return 1;;
+	esac
+
+	return 0
+}
+
 fi


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2022-11-15 16:34 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2022-11-15 16:34 UTC (permalink / raw
  To: gentoo-commits

commit:     95a6dff78a57dde2133dba050d16cae2c5113b23
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 28 09:59:52 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Nov 15 16:34:06 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=95a6dff7

scons-utils.eclass: Reuse makeopts_jobs

Closes: https://github.com/gentoo/gentoo/pull/27999
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/scons-utils.eclass   | 102 ++------------------------------------------
 eclass/tests/scons-utils.sh |  64 ---------------------------
 2 files changed, 4 insertions(+), 162 deletions(-)

diff --git a/eclass/scons-utils.eclass b/eclass/scons-utils.eclass
index cbe92f6fc385..acb51300f348 100644
--- a/eclass/scons-utils.eclass
+++ b/eclass/scons-utils.eclass
@@ -71,8 +71,8 @@
 # @DEFAULT_UNSET
 # @DESCRIPTION:
 # The default set of options to pass to scons. Similar to MAKEOPTS,
-# supposed to be set in make.conf. If unset, escons() will use cleaned
-# up MAKEOPTS instead.
+# supposed to be set in make.conf. If unset, escons() will set -j
+# based on MAKEOPTS.
 
 # @ECLASS_VARIABLE: EXTRA_ESCONS
 # @USER_VARIABLE
@@ -148,11 +148,8 @@ escons() {
 		die "EPYTHON unset in escons"
 	fi
 
-	# if SCONSOPTS are _unset_, use cleaned MAKEOPTS
-	if [[ ! ${SCONSOPTS+set} ]]; then
-		local SCONSOPTS
-		_scons_clean_makeopts
-	fi
+	# if SCONSOPTS are unset, grab -j from MAKEOPTS
+	: "${SCONSOPTS:=-j$(makeopts_jobs)}"
 
 	# pass ebuild environment variables through!
 	local -x GENTOO_SCONS_ENV_PASSTHROUGH=1
@@ -161,94 +158,3 @@ escons() {
 	echo "${@}" >&2
 	"${@}" || die -n "escons failed."
 }
-
-# @FUNCTION: _scons_clean_makeopts
-# @USAGE: [makeflags] [...]
-# @INTERNAL
-# @DESCRIPTION:
-# Strip the supplied makeflags (or ${MAKEOPTS} if called without
-# an argument) of options not supported by SCons and make sure --jobs
-# gets an argument. Output the resulting flag list (suitable
-# for an assignment to SCONSOPTS).
-_scons_clean_makeopts() {
-	local new_makeopts=()
-
-	debug-print-function ${FUNCNAME} "${@}"
-
-	if [[ ${#} -eq 0 ]]; then
-		debug-print "Using MAKEOPTS: [${MAKEOPTS}]"
-		set -- ${MAKEOPTS}
-	else
-		# unquote if necessary
-		set -- ${*}
-	fi
-
-	# empty MAKEOPTS give out empty SCONSOPTS
-	# thus, we do need to worry about the initial setup
-	if [[ ${*} = ${_SCONS_CACHE_MAKEOPTS} ]]; then
-		SCONSOPTS=${_SCONS_CACHE_SCONSOPTS}
-		debug-print "Cache hit: [${SCONSOPTS}]"
-		return
-	fi
-	_SCONS_CACHE_MAKEOPTS=${*}
-
-	while [[ ${#} -gt 0 ]]; do
-		case ${1} in
-			# clean, simple to check -- we like that
-			--jobs=*|--keep-going)
-				new_makeopts+=( ${1} )
-				;;
-			# need to take a look at the next arg and guess
-			--jobs)
-				if [[ ${#} -gt 1 && ${2} =~ ^[0-9]+$ ]]; then
-					new_makeopts+=( ${1} ${2} )
-					shift
-				else
-					# no value means no limit, let's pass a default instead
-					new_makeopts+=( ${1}=$(( $(get_nproc) + 1 )) )
-				fi
-				;;
-			# strip other long options
-			--*)
-				;;
-			# short option hell
-			-*)
-				local str new_optstr
-				new_optstr=
-				str=${1#-}
-
-				while [[ -n ${str} ]]; do
-					case ${str} in
-						k*)
-							new_optstr+=k
-							;;
-						# -j needs to come last
-						j)
-							if [[ ${#} -gt 1 && ${2} =~ ^[0-9]+$ ]]; then
-								new_optstr+="j ${2}"
-								shift
-							else
-								new_optstr+="j $(( $(get_nproc) + 1 ))"
-							fi
-							;;
-						# otherwise, everything after -j is treated as an arg
-						j*)
-							new_optstr+=${str}
-							break
-							;;
-					esac
-					str=${str#?}
-				done
-
-				if [[ -n ${new_optstr} ]]; then
-					new_makeopts+=( -${new_optstr} )
-				fi
-				;;
-		esac
-		shift
-	done
-
-	SCONSOPTS=${new_makeopts[*]}
-	_SCONS_CACHE_SCONSOPTS=${SCONSOPTS}
-	debug-print "New SCONSOPTS: [${SCONSOPTS}]"
-}

diff --git a/eclass/tests/scons-utils.sh b/eclass/tests/scons-utils.sh
deleted file mode 100755
index 5f1cd2036047..000000000000
--- a/eclass/tests/scons-utils.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/bash
-# Copyright 1999-2021 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-_PYTHON_R1=1
-source tests-common.sh || exit
-
-inherit scons-utils
-
-test-scons_clean_makeopts() {
-	tbegin "scons_clean_makeopts() for ${1}"
-
-	local SCONSOPTS ret=0
-	_scons_clean_makeopts ${1}
-
-	if [[ ${SCONSOPTS} != ${2-${1}} ]]; then
-		eerror "Self-test failed:"
-		eindent
-		eerror "MAKEOPTS: ${1}"
-		eerror "Expected: ${2-${1}}"
-		eerror "Actual: ${SCONSOPTS}"
-		eoutdent
-		ret=1
-	fi
-
-	tend ${ret}
-	return ${ret}
-}
-
-# jobcount expected for non-specified state
-jc=$(( $(get_nproc) + 1 ))
-# failed test counter
-failed=0
-
-# sane MAKEOPTS
-test-scons_clean_makeopts '--jobs=14 -k'
-test-scons_clean_makeopts '--jobs=14 -k'
-test-scons_clean_makeopts '--jobs 15 -k'
-test-scons_clean_makeopts '--jobs=16 --keep-going'
-test-scons_clean_makeopts '-j17 --keep-going'
-test-scons_clean_makeopts '-j 18 --keep-going'
-
-# needing cleaning
-test-scons_clean_makeopts '--jobs -k' "--jobs=${jc} -k"
-test-scons_clean_makeopts '--jobs --keep-going' "--jobs=${jc} --keep-going"
-test-scons_clean_makeopts '-kj' "-kj ${jc}"
-
-# broken by definition (but passed as it breaks make as well)
-test-scons_clean_makeopts '-jk'
-test-scons_clean_makeopts '--jobs=randum'
-test-scons_clean_makeopts '-kjrandum'
-
-# needing stripping
-test-scons_clean_makeopts '--load-average=25 -kj16' '-kj16'
-test-scons_clean_makeopts '--load-average 25 -k -j17' '-k -j17'
-test-scons_clean_makeopts '-j2 HOME=/tmp' '-j2'
-test-scons_clean_makeopts '--jobs funnystuff -k' "--jobs=${jc} -k"
-
-# bug #388961
-test-scons_clean_makeopts '--jobs -l3' "--jobs=${jc}"
-test-scons_clean_makeopts '-j -l3' "-j ${jc}"
-
-texit


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2023-06-07  9:03 Ulrich Müller
  0 siblings, 0 replies; 41+ messages in thread
From: Ulrich Müller @ 2023-06-07  9:03 UTC (permalink / raw
  To: gentoo-commits

commit:     610b01ff117232fde9068a9e97e7355d6e53f2e4
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  7 08:42:07 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Wed Jun  7 08:56:25 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=610b01ff

eapi8-dosym.eclass: Fix another corner case of strange input

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 eclass/eapi8-dosym.eclass   | 4 ++--
 eclass/tests/eapi8-dosym.sh | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/eclass/eapi8-dosym.eclass b/eclass/eapi8-dosym.eclass
index e139b74cfea0..866c98c78d91 100644
--- a/eclass/eapi8-dosym.eclass
+++ b/eclass/eapi8-dosym.eclass
@@ -31,7 +31,7 @@ esac
 _dosym8_canonicalize() {
 	local path slash i prev out IFS=/
 
-	read -r -d '' -a path < <(echo -n "$1")
+	read -r -d '' -a path < <(printf '%s\0' "$1")
 	[[ $1 == /* ]] && slash=/
 
 	while true; do
@@ -56,7 +56,7 @@ _dosym8_canonicalize() {
 	done
 
 	out="${slash}${path[*]}"
-	echo "${out:-.}"
+	printf "%s\n" "${out:-.}"
 }
 
 # @FUNCTION: dosym8

diff --git a/eclass/tests/eapi8-dosym.sh b/eclass/tests/eapi8-dosym.sh
index cae66e3bb2ee..a0f8961d4d96 100755
--- a/eclass/tests/eapi8-dosym.sh
+++ b/eclass/tests/eapi8-dosym.sh
@@ -54,6 +54,7 @@ teq foo _dosym8_canonicalize foo/.
 teq ../foo _dosym8_canonicalize ../foo
 teq ../baz _dosym8_canonicalize foo/bar/../../../baz
 teq '*' _dosym8_canonicalize '*'
+teq '-e' _dosym8_canonicalize '-e'
 
 for f in ref_dosym_r "dosym8 -r"; do
 	teq ../../bin/foo ${f} /bin/foo /usr/bin/foo


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2023-06-18 14:57 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2023-06-18 14:57 UTC (permalink / raw
  To: gentoo-commits

commit:     59dbfb80f748a0fc5741a8f3028f7552af28eecf
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 15 15:20:43 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jun 18 14:57:44 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=59dbfb80

cargo.eclass: Add variable alternative to $(cargo_crate_uris)

Add a helper function that sets ${CARGO_CRATE_URIS} variable to make
it possible to set SRC_URI without subshells.  This gives a slight
speedup (~20%):

```
real  300 it/s
user  324 it/s
```

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/cargo.eclass         | 48 +++++++++++++++++++++++++++++++--------------
 eclass/tests/cargo-bench.sh |  4 +++-
 2 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 991e808d453f..4e0cd1e4de70 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -68,7 +68,7 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
 # "
 # inherit cargo
 # ...
-# SRC_URI="$(cargo_crate_uris)"
+# SRC_URI="${CARGO_CRATE_URIS}"
 # @CODE
 
 # @ECLASS_VARIABLE: GIT_CRATES
@@ -162,31 +162,31 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
 # group, and then switch over to building with FEATURES=userpriv.
 # Or vice-versa.
 
-# @FUNCTION: cargo_crate_uris
+# @ECLASS_VARIABLE: CARGO_CRATE_URIS
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# List of URIs to put in SRC_URI created from CRATES variable.
+
+# @FUNCTION: _cargo_set_crate_uris
+# @USAGE: <crates>
 # @DESCRIPTION:
 # Generates the URIs to put in SRC_URI to help fetch dependencies.
 # Constructs a list of crates from its arguments.
 # If no arguments are provided, it uses the CRATES variable.
-cargo_crate_uris() {
+# The value is set as CARGO_CRATE_URIS.
+_cargo_set_crate_uris() {
 	local -r regex='^([a-zA-Z0-9_\-]+)-([0-9]+\.[0-9]+\.[0-9]+.*)$'
-	local crate crates
-
-	if [[ -n ${@} ]]; then
-		crates="$@"
-	elif [[ -n ${CRATES} ]]; then
-		crates="${CRATES}"
-	else
-		eerror "CRATES variable is not defined and nothing passed as argument"
-		die "Can't generate SRC_URI from empty input"
-	fi
+	local crates=${1}
+	local crate
 
+	CARGO_CRATE_URIS=
 	for crate in ${crates}; do
 		local name version url
 		[[ $crate =~ $regex ]] || die "Could not parse name and version from crate: $crate"
 		name="${BASH_REMATCH[1]}"
 		version="${BASH_REMATCH[2]}"
 		url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${crate}.crate"
-		echo "${url}"
+		CARGO_CRATE_URIS+="${url} "
 	done
 
 	local git_crates_type
@@ -214,12 +214,30 @@ cargo_crate_uris() {
 				;;
 			esac
 
-			printf -- '%s -> %s\n' "${crate_uri//%commit%/${commit}}" "${repo_name}-${commit}${repo_ext}.tar.gz"
+			CARGO_CRATE_URIS+="${crate_uri//%commit%/${commit}} -> ${repo_name}-${commit}${repo_ext}.tar.gz "
 		done
 	elif [[ -n ${git_crates_type} ]]; then
 		die "GIT_CRATE must be declared as an associative array"
 	fi
 }
+_cargo_set_crate_uris "${CRATES}"
+
+# @FUNCTION: cargo_crate_uris
+# @USAGE: [<crates>...]
+# @DESCRIPTION:
+# Generates the URIs to put in SRC_URI to help fetch dependencies.
+# Constructs a list of crates from its arguments.
+# If no arguments are provided, it uses the CRATES variable.
+cargo_crate_uris() {
+	local crates=${*-${CRATES}}
+	if [[ -z ${crates} ]]; then
+		eerror "CRATES variable is not defined and nothing passed as argument"
+		die "Can't generate SRC_URI from empty input"
+	fi
+
+	_cargo_set_crate_uris "${crates}"
+	echo "${CARGO_CRATE_URIS}"
+}
 
 # @FUNCTION: cargo_gen_config
 # @DESCRIPTION:

diff --git a/eclass/tests/cargo-bench.sh b/eclass/tests/cargo-bench.sh
index cdc5e4431c14..11b740f8dfcd 100755
--- a/eclass/tests/cargo-bench.sh
+++ b/eclass/tests/cargo-bench.sh
@@ -12,8 +12,9 @@ RUNS=3
 
 doit() {
 	for (( i = 0; i < ITERATIONS; i++ )); do
+		_cargo_set_crate_uris "${CRATES}"
 		SRC_URI="
-			$(cargo_crate_uris)
+			${CARGO_CRATE_URIS}
 		"
 	done
 }
@@ -102,6 +103,7 @@ CRATES="
 "
 
 inherit cargo
+
 timeit
 
 texit


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2023-06-18 14:57 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2023-06-18 14:57 UTC (permalink / raw
  To: gentoo-commits

commit:     ac817be5fd5756bcd017e41321cf5731cd291c54
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 15 15:31:16 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jun 18 14:57:46 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ac817be5

cargo.eclass: Support separating crate names/versions via `@`

Support specifying crate names and versions separated by `@` character
rather than `-`.  Since `@` are not valid in crate names, this
makes splitting the tokens trivial and free of regular expressions.
Effectively, the `@` variant is roughly 180% faster:

```
 * CRATES with '@' separator
real  952 it/s
user  952 it/s
 * CRATES with '-' separator
real  339 it/s
user  339 it/s
```

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/cargo.eclass         |  24 +++++++---
 eclass/tests/cargo-bench.sh | 111 +++++++++++++++++++++++---------------------
 2 files changed, 75 insertions(+), 60 deletions(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index d97bb0df9348..8618c90bd986 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -59,12 +59,16 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
 # Bash string containing all crates that are to be downloaded.
 # It is used by cargo_crate_uris.
 #
+# Ideally, crate names and versions should be separated by a `@`
+# character.  A legacy syntax using hyphen is also supported but it is
+# much slower.
+#
 # Example:
 # @CODE
 # CRATES="
-# metal-1.2.3
-# bar-4.5.6
-# iron_oxide-0.0.1
+# metal@1.2.3
+# bar@4.5.6
+# iron_oxide@0.0.1
 # "
 # inherit cargo
 # ...
@@ -182,10 +186,16 @@ _cargo_set_crate_uris() {
 	CARGO_CRATE_URIS=
 	for crate in ${crates}; do
 		local name version url
-		[[ $crate =~ $regex ]] || die "Could not parse name and version from crate: $crate"
-		name="${BASH_REMATCH[1]}"
-		version="${BASH_REMATCH[2]}"
-		url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${crate}.crate"
+		if [[ ${crate} == *@* ]]; then
+			name=${crate%@*}
+			version=${crate##*@}
+		else
+			[[ ${crate} =~ ${regex} ]] ||
+				die "Could not parse name and version from crate: ${crate}"
+			name="${BASH_REMATCH[1]}"
+			version="${BASH_REMATCH[2]}"
+		fi
+		url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${name}-${version}.crate"
 		CARGO_CRATE_URIS+="${url} "
 	done
 

diff --git a/eclass/tests/cargo-bench.sh b/eclass/tests/cargo-bench.sh
index 11b740f8dfcd..d30b04569905 100755
--- a/eclass/tests/cargo-bench.sh
+++ b/eclass/tests/cargo-bench.sh
@@ -47,63 +47,68 @@ timeit() {
 
 # taken from cryptograpy-41.0.1
 CRATES="
-	Inflector-0.11.4
-	aliasable-0.1.3
-	asn1-0.15.2
-	asn1_derive-0.15.2
-	autocfg-1.1.0
-	base64-0.13.1
-	bitflags-1.3.2
-	cc-1.0.79
-	cfg-if-1.0.0
-	foreign-types-0.3.2
-	foreign-types-shared-0.1.1
-	indoc-1.0.9
-	libc-0.2.144
-	lock_api-0.4.9
-	memoffset-0.8.0
-	once_cell-1.17.2
-	openssl-0.10.54
-	openssl-macros-0.1.1
-	openssl-sys-0.9.88
-	ouroboros-0.15.6
-	ouroboros_macro-0.15.6
-	parking_lot-0.12.1
-	parking_lot_core-0.9.7
-	pem-1.1.1
-	pkg-config-0.3.27
-	proc-macro-error-1.0.4
-	proc-macro-error-attr-1.0.4
-	proc-macro2-1.0.59
-	pyo3-0.18.3
-	pyo3-build-config-0.18.3
-	pyo3-ffi-0.18.3
-	pyo3-macros-0.18.3
-	pyo3-macros-backend-0.18.3
-	quote-1.0.28
-	redox_syscall-0.2.16
-	scopeguard-1.1.0
-	smallvec-1.10.0
-	syn-1.0.109
-	syn-2.0.18
-	target-lexicon-0.12.7
-	unicode-ident-1.0.9
-	unindent-0.1.11
-	vcpkg-0.2.15
-	version_check-0.9.4
-	windows-sys-0.45.0
-	windows-targets-0.42.2
-	windows_aarch64_gnullvm-0.42.2
-	windows_aarch64_msvc-0.42.2
-	windows_i686_gnu-0.42.2
-	windows_i686_msvc-0.42.2
-	windows_x86_64_gnu-0.42.2
-	windows_x86_64_gnullvm-0.42.2
-	windows_x86_64_msvc-0.42.2
+	Inflector@0.11.4
+	aliasable@0.1.3
+	asn1@0.15.2
+	asn1_derive@0.15.2
+	autocfg@1.1.0
+	base64@0.13.1
+	bitflags@1.3.2
+	cc@1.0.79
+	cfg-if@1.0.0
+	foreign-types@0.3.2
+	foreign-types-shared@0.1.1
+	indoc@1.0.9
+	libc@0.2.144
+	lock_api@0.4.9
+	memoffset@0.8.0
+	once_cell@1.17.2
+	openssl@0.10.54
+	openssl-macros@0.1.1
+	openssl-sys@0.9.88
+	ouroboros@0.15.6
+	ouroboros_macro@0.15.6
+	parking_lot@0.12.1
+	parking_lot_core@0.9.7
+	pem@1.1.1
+	pkg-config@0.3.27
+	proc-macro-error@1.0.4
+	proc-macro-error-attr@1.0.4
+	proc-macro2@1.0.59
+	pyo3@0.18.3
+	pyo3-build-config@0.18.3
+	pyo3-ffi@0.18.3
+	pyo3-macros@0.18.3
+	pyo3-macros-backend@0.18.3
+	quote@1.0.28
+	redox_syscall@0.2.16
+	scopeguard@1.1.0
+	smallvec@1.10.0
+	syn@1.0.109
+	syn@2.0.18
+	target-lexicon@0.12.7
+	unicode-ident@1.0.9
+	unindent@0.1.11
+	vcpkg@0.2.15
+	version_check@0.9.4
+	windows-sys@0.45.0
+	windows-targets@0.42.2
+	windows_aarch64_gnullvm@0.42.2
+	windows_aarch64_msvc@0.42.2
+	windows_i686_gnu@0.42.2
+	windows_i686_msvc@0.42.2
+	windows_x86_64_gnu@0.42.2
+	windows_x86_64_gnullvm@0.42.2
+	windows_x86_64_msvc@0.42.2
 "
 
 inherit cargo
 
+einfo "CRATES with '@' separator"
+timeit
+
+einfo "CRATES with '-' separator"
+CRATES=${CRATES//@/-}
 timeit
 
 texit


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2023-07-02 15:21 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2023-07-02 15:21 UTC (permalink / raw
  To: gentoo-commits

commit:     6d9ca31b20ed4a4d7130602e67aa61385f8511e0
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 23 06:10:46 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jul  2 15:06:27 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6d9ca31b

python-utils-r1.eclass: make pypy3 match Python 3.10 now

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/python-utils-r1.eclass   | 6 +++---
 eclass/tests/python-utils-r1.sh | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 7a1be381f596..d2bbe90da049 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -238,12 +238,12 @@ _python_impl_matches() {
 				fi
 				return 0
 				;;
-			3.9)
-				# the only unmasked pypy3 version is pypy3.9 atm
+			3.9|3.10)
+				# <pypy3-7.3.12 is 3.9, >=7.3.12 is 3.10
 				[[ ${impl} == python${pattern/./_} || ${impl} == pypy3 ]] &&
 					return 0
 				;;
-			3.8|3.1[0-2])
+			3.8|3.1[1-2])
 				[[ ${impl} == python${pattern/./_} ]] && return 0
 				;;
 			*)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 635d49decbdd..81c459765f0f 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -208,7 +208,7 @@ test_is "_python_impl_matches python3_11 3.12" 1
 test_is "_python_impl_matches python3_12 3.10" 1
 test_is "_python_impl_matches python3_12 3.11" 1
 test_is "_python_impl_matches python3_12 3.12" 0
-test_is "_python_impl_matches pypy3 3.10" 1
+test_is "_python_impl_matches pypy3 3.10" 0
 test_is "_python_impl_matches pypy3 3.11" 1
 test_is "_python_impl_matches pypy3 3.12" 1
 eoutdent


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2023-09-14  5:30 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2023-09-14  5:30 UTC (permalink / raw
  To: gentoo-commits

commit:     e111329e222787152b6d99ce4b551c8758349aac
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Sep  3 13:21:57 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Sep 14 05:30:10 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e111329e

verify-sig.eclass: Support `openssl dgst` format checksums

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/tests/verify-sig.sh | 18 ++++++++++++++++
 eclass/verify-sig.eclass   | 54 ++++++++++++++++++++++++++++++----------------
 2 files changed, 54 insertions(+), 18 deletions(-)

diff --git a/eclass/tests/verify-sig.sh b/eclass/tests/verify-sig.sh
index fcd2ee7480a2..fb7f2cdb2a5d 100755
--- a/eclass/tests/verify-sig.sh
+++ b/eclass/tests/verify-sig.sh
@@ -62,4 +62,22 @@ EOF
 test_verify_unsigned_checksums sha256
 eoutdent
 
+einfo "Testing openssl-dgst format."
+eindent
+
+> "annoying ( filename )= yes ).txt" || die
+
+cat > checksums.txt <<-EOF || die
+	junk text that ought to be ignored
+
+	SHA256(empty)=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+	SHA256(text)= b47cc0f104b62d4c7c30bcd68fd8e67613e287dc4ad8c310ef10cbadea9c4380
+	SHA256(fail)=b47cc0f104b62d4c7c30bcd68fd8e67613e287dc4ad8c310ef10cbadea9c4380
+
+	SHA256(annoying ( filename )= yes )= e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+EOF
+
+test_verify_unsigned_checksums openssl-dgst
+eoutdent
+
 texit

diff --git a/eclass/verify-sig.eclass b/eclass/verify-sig.eclass
index d99dc3461858..815299b419ed 100644
--- a/eclass/verify-sig.eclass
+++ b/eclass/verify-sig.eclass
@@ -214,12 +214,15 @@ verify-sig_verify_message() {
 }
 
 # @FUNCTION: verify-sig_verify_unsigned_checksums
-# @USAGE: <checksum-file> <algo> <files>
+# @USAGE: <checksum-file> <format> <files>
 # @DESCRIPTION:
 # Verify the checksums for all files listed in the space-separated list
-# <files> (akin to ${A}) using a <checksum-file>.  <algo> specifies
-# the checksum algorithm (e.g. sha256).  <checksum-file> can be "-"
-# for stdin.
+# <files> (akin to ${A}) using a <checksum-file>.  <format> specifies
+# the checksum file format.  <checksum-file> can be "-" for stdin.
+#
+# The following formats are supported:
+#  - sha256 -- sha256sum (<hash> <filename>)
+#  - openssl-dgst -- openssl dgst (<algo>(<filename>)=<hash>)
 #
 # The function dies if one of the files does not match checksums or
 # is missing from the checksum file.
@@ -231,35 +234,50 @@ verify-sig_verify_message() {
 # verify-sig_verify_signed_checksums instead.
 verify-sig_verify_unsigned_checksums() {
 	local checksum_file=${1}
-	local algo=${2}
+	local format=${2}
 	local files=()
 	read -r -d '' -a files <<<"${3}"
-	local chksum_prog chksum_len
+	local chksum_prog chksum_len algo=${format}
 
-	case ${algo} in
+	case ${format} in
 		sha256)
-			chksum_prog=sha256sum
 			chksum_len=64
 			;;
+		openssl-dgst)
+			;;
 		*)
-			die "${FUNCNAME}: unknown checksum algo ${algo}"
+			die "${FUNCNAME}: unknown checksum format ${format}"
 			;;
 	esac
 
 	[[ ${checksum_file} == - ]] && checksum_file=/dev/stdin
-	local checksum filename junk ret=0 count=0
-	while read -r checksum filename junk; do
-		if [[ ${checksum} == "-----BEGIN" ]]; then
+	local line checksum filename junk ret=0 count=0
+	while read -r line; do
+		if [[ ${line} == "-----BEGIN"* ]]; then
 			die "${FUNCNAME}: PGP armor found, use verify-sig_verify_signed_checksums instead"
 		fi
 
-		[[ ${#checksum} -eq ${chksum_len} ]] || continue
-		[[ -z ${checksum//[0-9a-f]} ]] || continue
-		has "${filename}" "${files[@]}" || continue
-		[[ -z ${junk} ]] || continue
+		case ${format} in
+			sha256)
+				read -r checksum filename junk <<<"${line}"
+				[[ ${#checksum} -ne ${chksum_len} ]] && continue
+				[[ -n ${checksum//[0-9a-f]} ]] && continue
+				[[ -n ${junk} ]] && continue
+				;;
+			openssl-dgst)
+				[[ ${line} != *"("*")="* ]] && continue
+				checksum=${line##*)=}
+				algo=${line%%(*}
+				filename=${line#*(}
+				filename=${filename%)=*}
+				;;
+		esac
+
+		if ! has "${filename}" "${files[@]}"; then
+			continue
+		fi
 
-		"${chksum_prog}" -c --strict - <<<"${checksum} ${filename}"
-		if [[ ${?} -eq 0 ]]; then
+		if "${algo,,}sum" -c --strict - <<<"${checksum} ${filename}"; then
 			(( count++ ))
 		else
 			ret=1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2024-02-10 10:47 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2024-02-10 10:47 UTC (permalink / raw
  To: gentoo-commits

commit:     511ce42e90eccd89a8d0d2ccbc239578d6af11ea
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Feb  7 16:34:34 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb 10 10:47:20 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=511ce42e

llvm-utils.eclass: Introduce an eclass for common helpers

Move some reusable functions from llvm.eclass to llvm-utils.eclass.
This is with minimal modifications so far (only argument checks were
cleaned up).

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/llvm-utils.eclass   | 115 +++++++++++++++++++++++++++++++++++++++++++++
 eclass/llvm.eclass         |  92 ++----------------------------------
 eclass/tests/llvm-utils.sh |  82 ++++++++++++++++++++++++++++++++
 3 files changed, 200 insertions(+), 89 deletions(-)

diff --git a/eclass/llvm-utils.eclass b/eclass/llvm-utils.eclass
new file mode 100644
index 000000000000..43988f6f88c7
--- /dev/null
+++ b/eclass/llvm-utils.eclass
@@ -0,0 +1,115 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: llvm-utils.eclass
+# @MAINTAINER:
+# Michał Górny <mgorny@gentoo.org>
+# @AUTHOR:
+# Michał Górny <mgorny@gentoo.org>
+# @SUPPORTED_EAPIS: 7 8
+# @BLURB: Common utility functions for building against installed LLVM
+# @DESCRIPTION:
+# The utility eclass providing shared functions reused between
+# llvm.eclass and llvm-r1.eclass.  It may also be used directly
+# in ebuilds.
+
+case ${EAPI} in
+	7|8) ;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! ${_LLVM_UTILS_ECLASS} ]]; then
+_LLVM_UTILS_ECLASS=1
+
+# @FUNCTION: llvm_tuple_to_target
+# @USAGE: [<tuple>]
+# @DESCRIPTION:
+# Translate a tuple into a target suitable for LLVM_TARGETS.
+# Defaults to ${CHOST} if not specified.
+llvm_tuple_to_target() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	[[ ${#} -gt 1 ]] && die "Usage: ${FUNCNAME} [<tuple>]"
+
+	case ${1:-${CHOST}} in
+		aarch64*) echo "AArch64";;
+		amdgcn*) echo "AMDGPU";;
+		arc*) echo "ARC";;
+		arm*) echo "ARM";;
+		avr*) echo "AVR";;
+		bpf*) echo "BPF";;
+		csky*) echo "CSKY";;
+		loong*) echo "LoongArch";;
+		m68k*) echo "M68k";;
+		mips*) echo "Mips";;
+		msp430*) echo "MSP430";;
+		nvptx*) echo "NVPTX";;
+		powerpc*) echo "PowerPC";;
+		riscv*) echo "RISCV";;
+		sparc*) echo "Sparc";;
+		s390*) echo "SystemZ";;
+		x86_64*|i?86*) echo "X86";;
+		xtensa*) echo "Xtensa";;
+		*) die "Unknown LLVM target for tuple ${1:-${CHOST}}"
+	esac
+}
+
+# @FUNCTION: llvm_fix_clang_version
+# @USAGE: <variable-name>...
+# @DESCRIPTION:
+# Fix the clang compiler name in specified variables to include
+# the major version, to prevent PATH alterations from forcing an older
+# clang version being used.
+llvm_fix_clang_version() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local shopt_save=$(shopt -p -o noglob)
+	set -f
+	local var
+	for var; do
+		local split=( ${!var} )
+		case ${split[0]} in
+			*clang|*clang++|*clang-cpp)
+				local version=()
+				read -r -a version < <("${split[0]}" --version)
+				local major=${version[-1]%%.*}
+				if [[ -n ${major//[0-9]} ]]; then
+					die "${var}=${!var} produced invalid --version: ${version[*]}"
+				fi
+
+				split[0]+=-${major}
+				if ! type -P "${split[0]}" &>/dev/null; then
+					die "${split[0]} does not seem to exist"
+				fi
+				declare -g "${var}=${split[*]}"
+				;;
+		esac
+	done
+	${shopt_save}
+}
+
+# @FUNCTION: llvm_fix_tool_path
+# @USAGE: <variable-name>...
+# @DESCRIPTION:
+# Fix the LLVM tools referenced in the specified variables to their
+# current location, to prevent PATH alterations from forcing older
+# versions being used.
+llvm_fix_tool_path() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local shopt_save=$(shopt -p -o noglob)
+	set -f
+	local var
+	for var; do
+		local split=( ${!var} )
+		local path=$(type -P ${split[0]} 2>/dev/null)
+		# if it resides in one of the LLVM prefixes, it's an LLVM tool!
+		if [[ ${path} == "${BROOT}/usr/lib/llvm"* ]]; then
+			split[0]=${path}
+			declare -g "${var}=${split[*]}"
+		fi
+	done
+	${shopt_save}
+}
+
+fi

diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass
index 91cc68d966fe..05ffcfd7cc6d 100644
--- a/eclass/llvm.eclass
+++ b/eclass/llvm.eclass
@@ -7,6 +7,7 @@
 # @AUTHOR:
 # Michał Górny <mgorny@gentoo.org>
 # @SUPPORTED_EAPIS: 7 8
+# @PROVIDES: llvm-utils
 # @BLURB: Utility functions to build against slotted LLVM
 # @DESCRIPTION:
 # The llvm.eclass provides utility functions that can be used to build
@@ -64,6 +65,8 @@ esac
 if [[ ! ${_LLVM_ECLASS} ]]; then
 _LLVM_ECLASS=1
 
+inherit llvm-utils
+
 # make sure that the versions installing straight into /usr/bin
 # are uninstalled
 DEPEND="!!sys-devel/llvm:0"
@@ -174,95 +177,6 @@ get_llvm_prefix() {
 	echo "${prefix}/usr/lib/llvm/$(get_llvm_slot "${@}")"
 }
 
-# @FUNCTION: llvm_tuple_to_target
-# @USAGE: [<tuple>]
-# @DESCRIPTION:
-# Translate a tuple into a target suitable for LLVM_TARGETS.
-# Defaults to ${CHOST} if not specified.
-llvm_tuple_to_target() {
-	debug-print-function ${FUNCNAME} "${@}"
-
-	case ${1:-${CHOST}} in
-		aarch64*) echo "AArch64";;
-		amdgcn*) echo "AMDGPU";;
-		arc*) echo "ARC";;
-		arm*) echo "ARM";;
-		avr*) echo "AVR";;
-		bpf*) echo "BPF";;
-		csky*) echo "CSKY";;
-		loong*) echo "LoongArch";;
-		m68k*) echo "M68k";;
-		mips*) echo "Mips";;
-		msp430*) echo "MSP430";;
-		nvptx*) echo "NVPTX";;
-		powerpc*) echo "PowerPC";;
-		riscv*) echo "RISCV";;
-		sparc*) echo "Sparc";;
-		s390*) echo "SystemZ";;
-		x86_64*|i?86*) echo "X86";;
-		xtensa*) echo "Xtensa";;
-		*) die "Unknown LLVM target for tuple ${1:-${CHOST}}"
-	esac
-}
-
-# @FUNCTION: llvm_fix_clang_version
-# @USAGE: <variable-name>...
-# @DESCRIPTION:
-# Fix the clang compiler name in specified variables to include
-# the major version, to prevent PATH alterations from forcing an older
-# clang version being used.
-llvm_fix_clang_version() {
-	debug-print-function ${FUNCNAME} "${@}"
-
-	local shopt_save=$(shopt -p -o noglob)
-	set -f
-	local var
-	for var; do
-		local split=( ${!var} )
-		case ${split[0]} in
-			*clang|*clang++|*clang-cpp)
-				local version=()
-				read -r -a version < <("${split[0]}" --version)
-				local major=${version[-1]%%.*}
-				if [[ -n ${major//[0-9]} ]]; then
-					die "${var}=${!var} produced invalid --version: ${version[*]}"
-				fi
-
-				split[0]+=-${major}
-				if ! type -P "${split[0]}" &>/dev/null; then
-					die "${split[0]} does not seem to exist"
-				fi
-				declare -g "${var}=${split[*]}"
-				;;
-		esac
-	done
-	${shopt_save}
-}
-
-# @FUNCTION: llvm_fix_tool_path
-# @USAGE: <variable-name>...
-# @DESCRIPTION:
-# Fix the LLVM tools referenced in the specified variables to their
-# current location, to prevent PATH alterations from forcing older
-# versions being used.
-llvm_fix_tool_path() {
-	debug-print-function ${FUNCNAME} "${@}"
-
-	local shopt_save=$(shopt -p -o noglob)
-	set -f
-	local var
-	for var; do
-		local split=( ${!var} )
-		local path=$(type -P ${split[0]} 2>/dev/null)
-		# if it resides in one of the LLVM prefixes, it's an LLVM tool!
-		if [[ ${path} == "${BROOT}/usr/lib/llvm"* ]]; then
-			split[0]=${path}
-			declare -g "${var}=${split[*]}"
-		fi
-	done
-	${shopt_save}
-}
-
 # @FUNCTION: llvm_pkg_setup
 # @DESCRIPTION:
 # Prepend the appropriate executable directory for the newest

diff --git a/eclass/tests/llvm-utils.sh b/eclass/tests/llvm-utils.sh
new file mode 100755
index 000000000000..44ad1b4adc84
--- /dev/null
+++ b/eclass/tests/llvm-utils.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+source tests-common.sh || exit
+
+EAPI=8
+
+inherit llvm-utils
+
+test_fix_clang_version() {
+	local var=${1}
+	local tool=${2}
+	local version=${3}
+	local expected=${4}
+
+	eval "${tool}() {
+		cat <<-EOF
+			clang version ${version}
+			Target: x86_64-pc-linux-gnu
+			Thread model: posix
+			InstalledDir: /usr/lib/llvm/17/bin
+			Configuration file: /etc/clang/x86_64-pc-linux-gnu-clang.cfg
+		EOF
+	}"
+
+	declare -g ${var}=${tool}
+	tbegin "llvm_fix_clang_version ${var}=${tool} for ${version}"
+	llvm_fix_clang_version "${var}"
+	if [[ ${!var} != ${expected} ]]; then
+		eerror "llvm_fix_clang_version ${var}"
+		eerror "    gave: ${!var}"
+		eerror "expected: ${expected}"
+	fi
+	tend ${?}
+}
+
+test_fix_tool_path() {
+	local var=${1}
+	local tool=${2}
+	local expected_subst=${3}
+	local expected=${tool}
+
+	tbegin "llvm_fix_tool_path ${1}=${2} (from llvm? ${expected_subst})"
+
+	local matches=( "${BROOT}"/usr/lib/llvm/*/bin/"${tool}" )
+	if [[ ${expected_subst} == 1 ]]; then
+		if [[ ! -x ${matches[0]} ]]; then
+			ewarn "- skipping, test requires ${tool}"
+			return
+		fi
+
+		expected=${matches[0]}
+		local -x PATH=${matches[0]%/*}
+	else
+		local -x PATH=
+	fi
+
+	declare -g ${var}=${tool}
+	llvm_fix_tool_path "${var}"
+	if [[ ${!var} != ${expected} ]]; then
+		eerror "llvm_fix_tool_path ${var}"
+		eerror "    gave: ${!var}"
+		eerror "expected: ${expected}"
+	fi
+	tend ${?}
+}
+
+test_fix_clang_version CC clang 19.0.0git78b4e7c5 clang-19
+test_fix_clang_version CC clang 17.0.6 clang-17
+test_fix_clang_version CXX clang++ 17.0.6 clang++-17
+test_fix_clang_version CC x86_64-pc-linux-gnu-clang 17.0.6 \
+	x86_64-pc-linux-gnu-clang-17
+test_fix_clang_version CC clang-17 n/a clang-17
+test_fix_clang_version CC gcc n/a gcc
+
+test_fix_tool_path AR llvm-ar 1
+test_fix_tool_path RANLIB llvm-ranlib 1
+test_fix_tool_path AR ar 1
+test_fix_tool_path AR ar 0
+
+texit


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2024-02-10 10:47 Michał Górny
  0 siblings, 0 replies; 41+ messages in thread
From: Michał Górny @ 2024-02-10 10:47 UTC (permalink / raw
  To: gentoo-commits

commit:     5618de75aec49009489efb560a89e014fd060524
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Feb  5 19:29:36 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb 10 10:47:23 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5618de75

llvm-r1.eclass: Initial version

Bug: https://bugs.gentoo.org/923228
Bug: https://bugs.gentoo.org/880671
Closes: https://bugs.gentoo.org/821955
Closes: https://bugs.gentoo.org/919150
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/llvm-r1.eclass   | 250 ++++++++++++++++++++++++++++++++++++++++++++++++
 eclass/tests/llvm-r1.sh | 151 +++++++++++++++++++++++++++++
 2 files changed, 401 insertions(+)

diff --git a/eclass/llvm-r1.eclass b/eclass/llvm-r1.eclass
new file mode 100644
index 000000000000..658946a1ecbd
--- /dev/null
+++ b/eclass/llvm-r1.eclass
@@ -0,0 +1,250 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: llvm-r1.eclass
+# @MAINTAINER:
+# Michał Górny <mgorny@gentoo.org>
+# @AUTHOR:
+# Michał Górny <mgorny@gentoo.org>
+# @SUPPORTED_EAPIS: 8
+# @PROVIDES: llvm-utils
+# @BLURB: Provide LLVM_SLOT to build against slotted LLVM
+# @DESCRIPTION:
+# An eclass to reliably depend on a set of LLVM-related packages
+# in a matching slot.  To use the eclass:
+#
+# 1. Set LLVM_COMPAT to the list of supported LLVM slots.
+# 2. Use llvm_gen_dep and/or LLVM_USEDEP to add appropriate
+#    dependencies.
+# 3. Use llvm-r1_pkg_setup, get_llvm_prefix or LLVM_SLOT.
+#
+# The eclass sets IUSE and REQUIRED_USE.  The flag corresponding
+# to the newest supported stable LLVM slot (or the newest testing,
+# if no stable slots are supported) is enabled by default.
+#
+# Example:
+# @CODE
+# LLVM_COMPAT=( {16..18} )
+#
+# inherit llvm-r1
+#
+# DEPEND="
+#   dev-libs/libfoo[${LLVM_USEDEP}]
+#   $(llvm_gen_dep '
+#     sys-devel/clang:${LLVM_SLOT}
+#     sys-devel/llvm:${LLVM_SLOT}
+#   ')
+# "
+# @CODE
+
+case ${EAPI} in
+	8) ;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! ${_LLVM_R1_ECLASS} ]]; then
+_LLVM_R1_ECLASS=1
+
+inherit llvm-utils
+
+# == internal control knobs ==
+
+# @ECLASS_VARIABLE: _LLVM_OLDEST_SLOT
+# @INTERNAL
+# @DESCRIPTION:
+# Oldest supported LLVM slot.  This is used to automatically filter out
+# unsupported LLVM_COMPAT values.
+_LLVM_OLDEST_SLOT=15
+
+# @ECLASS_VARIABLE: _LLVM_NEWEST_STABLE
+# @INTERNAL
+# @DESCRIPTION:
+# The newest stable LLVM version.  Versions newer than that won't
+# be automatically enabled via USE defaults.
+_LLVM_NEWEST_STABLE=17
+
+# == control variables ==
+
+# @ECLASS_VARIABLE: LLVM_COMPAT
+# @PRE_INHERIT
+# @REQUIRED
+# @DESCRIPTION:
+# A list of LLVM slots supported by the package, oldest to newest.
+#
+# Example:
+# @CODE
+# LLVM_COMPAT=( {15..17} )
+# @CODE
+
+# @ECLASS_VARIABLE: LLVM_OPTIONAL
+# @PRE_INHERIT
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-empty value, disables setting REQUIRED_USE
+# and exporting pkg_setup.  You have to add LLVM_REQUIRED_USE and call
+# pkg_setup manually, with appropriate USE conditions.
+
+# == global metadata ==
+
+# @ECLASS_VARIABLE: LLVM_REQUIRED_USE
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# An eclass-generated REQUIRED_USE string that enforces selecting
+# exactly one slot.  It LLVM_OPTIONAL is set, it needs to be copied
+# into REQUIRED_USE, under appropriate USE conditions.  Otherwise,
+# it is added automatically.
+
+# @ECLASS_VARIABLE: LLVM_USEDEP
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# An eclass-generated USE dependency string that can be applied to other
+# packages using the same eclass, to enforce a LLVM slot match.
+
+_llvm_set_globals() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	if [[ ${LLVM_COMPAT@a} != *a* ]]; then
+		die "LLVM_COMPAT must be set to an array before inheriting ${ECLASS}"
+	fi
+
+	local stable=() unstable=()
+	local x
+	for x in "${LLVM_COMPAT[@]}"; do
+		if [[ ${x} -gt ${_LLVM_NEWEST_STABLE} ]]; then
+			unstable+=( "${x}" )
+		elif [[ ${x} -ge ${_LLVM_OLDEST_SLOT} ]]; then
+			stable+=( "${x}" )
+		fi
+	done
+
+	_LLVM_SLOTS=( "${stable[@]}" "${unstable[@]}" )
+	if [[ ! ${_LLVM_SLOTS[@]} ]]; then
+		die "LLVM_COMPAT does not contain any valid versions (all older than ${_LLVM_OLDEST_SLOT}?)"
+	fi
+
+	if [[ ${stable[@]} ]]; then
+		IUSE="+llvm_slot_${stable[-1]}"
+		unset 'stable[-1]'
+	else
+		IUSE="+llvm_slot_${unstable[-1]}"
+		unset 'unstable[-1]'
+	fi
+	local nondefault=( "${stable[@]}" "${unstable[@]}" )
+	IUSE+=" ${nondefault[*]/#/llvm_slot_}"
+
+	local flags=( "${_LLVM_SLOTS[@]/#/llvm_slot_}" )
+	LLVM_REQUIRED_USE="^^ ( ${flags[*]} )"
+	local usedep_flags=${flags[*]/%/(-)?}
+	LLVM_USEDEP=${usedep_flags// /,}
+	readonly LLVM_REQUIRED_USE LLVM_USEDEP
+
+	if [[ ! ${LLVM_OPTIONAL} ]]; then
+		REQUIRED_USE=${LLVM_REQUIRED_USE}
+	fi
+}
+_llvm_set_globals
+unset -f _llvm_set_globals
+
+# == metadata helpers ==
+
+# @FUNCTION: llvm_gen_dep
+# @USAGE: <dependency>
+# @DESCRIPTION:
+# Output a dependency block, repeating "<dependency>" conditionally
+# to all llvm_slot_* USE flags.  Any occurences of '${LLVM_SLOT}'
+# within the block will be substituted for the respective slot.
+#
+# Example:
+# @CODE
+# DEPEND="
+#   $(llvm_gen_dep '
+#     sys-devel/clang:${LLVM_SLOT}
+#     sys-devel/llvm:${LLVM_SLOT}
+#   ')
+# "
+# @CODE
+llvm_gen_dep() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	[[ ${#} -ne 1 ]] && die "Usage: ${FUNCNAME} <dependency>"
+
+	local dep=${1}
+
+	local slot
+	for slot in "${_LLVM_SLOTS[@]}"; do
+		echo "llvm_slot_${slot}? ( ${dep//\$\{LLVM_SLOT\}/${slot}} )"
+	done
+}
+
+# == ebuild helpers ==
+
+# @FUNCTION: get_llvm_prefix
+# @USAGE: [-b|-d]
+# @DESCRIPTION:
+# Output the path to the selected LLVM slot.
+#
+# With no option or "-d", the path is prefixed by ESYSROOT.  LLVM
+# dependencies should be in DEPEND then.
+#
+# With "-b" option, the path is prefixed by BROOT. LLVM dependencies
+# should be in BDEPEND then.
+get_llvm_prefix() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	[[ ${#} -gt 1 ]] && die "Usage: ${FUNCNAME} [-b|-d]"
+
+	local prefix
+	case ${1--d} in
+		-d)
+			prefix=${ESYSROOT}
+			;;
+		-b)
+			prefix=${BROOT}
+			;;
+		*)
+			die "${FUNCNAME}: invalid option: ${1}"
+			;;
+	esac
+
+	echo "${prefix}/usr/lib/llvm/${LLVM_SLOT}"
+}
+
+# @FUNCTION: llvm-r1_pkg_setup
+# @DESCRIPTION:
+# Prepend the appropriate executable directory for the selected LLVM
+# slot to PATH.
+#
+# The PATH manipulation is only done for source builds. The function
+# is a no-op when installing a binary package.
+#
+# If any other behavior is desired, the contents of the function
+# should be inlined into the ebuild and modified as necessary.
+#
+# Note that this function is not exported if LLVM_OPTIONAL is set.
+# In that case, it needs to be called manually.
+llvm-r1_pkg_setup() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	if [[ ${MERGE_TYPE} != binary ]]; then
+		[[ -z ${LLVM_SLOT} ]] && die "LLVM_SLOT unset (broken USE_EXPAND?)"
+
+		llvm_fix_clang_version CC CPP CXX
+		# keep in sync with profiles/features/llvm/make.defaults!
+		llvm_fix_tool_path ADDR2LINE AR AS LD NM OBJCOPY OBJDUMP RANLIB
+		llvm_fix_tool_path READELF STRINGS STRIP
+
+		# Set LLVM_CONFIG to help Meson (bug #907965) but only do it
+		# for empty ESYSROOT (as a proxy for "are we cross-compiling?").
+		if [[ -z ${ESYSROOT} ]] ; then
+			llvm_fix_tool_path LLVM_CONFIG
+		fi
+
+		llvm_prepend_path "${LLVM_SLOT}"
+	fi
+}
+
+fi
+
+if [[ ! ${LLVM_OPTIONAL} ]]; then
+	EXPORT_FUNCTIONS pkg_setup
+fi

diff --git a/eclass/tests/llvm-r1.sh b/eclass/tests/llvm-r1.sh
new file mode 100755
index 000000000000..9958f5bba420
--- /dev/null
+++ b/eclass/tests/llvm-r1.sh
@@ -0,0 +1,151 @@
+#!/bin/bash
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+source tests-common.sh || exit
+
+EAPI=8
+
+test_globals() {
+	local compat=${1}
+	local expected_iuse=${2}
+	local expected_required_use=${3}
+	local expected_usedep=${4}
+	local x
+
+	tbegin "LLVM_COMPAT=( ${compat} )"
+
+	(
+		local fail=0
+		local LLVM_COMPAT=( ${compat} )
+
+		inherit llvm-r1
+
+		if [[ ${IUSE%% } != ${expected_iuse} ]]; then
+			eerror "          IUSE: ${IUSE%% }"
+			eerror "does not match: ${expected_iuse}"
+			fail=1
+		fi
+
+		if [[ ${REQUIRED_USE} != ${expected_required_use} ]]; then
+			eerror "  REQUIRED_USE: ${REQUIRED_USE}"
+			eerror "does not match: ${expected_required_use}"
+			fail=1
+		fi
+
+		if [[ ${LLVM_USEDEP} != ${expected_usedep} ]]; then
+			eerror "   LLVM_USEDEP: ${LLVM_USEDEP}"
+			eerror "does not match: ${expected_usedep}"
+			fail=1
+		fi
+
+		exit "${fail}"
+	)
+
+	tend "${?}"
+}
+
+test_gen_dep() {
+	local arg=${1}
+	local expected
+	read -r -d '' expected
+
+	tbegin "llvm_gen_dep ${arg}"
+	local value=$(llvm_gen_dep "${arg}")
+
+	if [[ ${value} != ${expected} ]]; then
+		eerror "python_get_usedep ${arg}"
+		eerror "gave:"
+		eerror "  ${value}"
+		eerror "expected:"
+		eerror "  ${expected}"
+	fi
+	tend ${?}
+}
+
+test_fix_clang_version() {
+	local var=${1}
+	local tool=${2}
+	local version=${3}
+	local expected=${4}
+
+	eval "${tool}() {
+		cat <<-EOF
+			clang version ${version}
+			Target: x86_64-pc-linux-gnu
+			Thread model: posix
+			InstalledDir: /usr/lib/llvm/17/bin
+			Configuration file: /etc/clang/x86_64-pc-linux-gnu-clang.cfg
+		EOF
+	}"
+
+	declare -g ${var}=${tool}
+	tbegin "llvm_fix_clang_version ${var}=${tool} for ${version}"
+	llvm_fix_clang_version "${var}"
+	if [[ ${!var} != ${expected} ]]; then
+		eerror "llvm_fix_clang_version ${var}"
+		eerror "    gave: ${!var}"
+		eerror "expected: ${expected}"
+	fi
+	tend ${?}
+}
+
+test_fix_tool_path() {
+	local var=${1}
+	local tool=${2}
+	local expected_subst=${3}
+	local expected=${tool}
+
+	tbegin "llvm_fix_tool_path ${1}=${2} (from llvm? ${expected_subst})"
+
+	local matches=( "${BROOT}"/usr/lib/llvm/*/bin/"${tool}" )
+	if [[ ${expected_subst} == 1 ]]; then
+		if [[ ! -x ${matches[0]} ]]; then
+			ewarn "- skipping, test requires ${tool}"
+			return
+		fi
+
+		expected=${matches[0]}
+		local -x PATH=${matches[0]%/*}
+	else
+		local -x PATH=
+	fi
+
+	declare -g ${var}=${tool}
+	llvm_fix_tool_path "${var}"
+	if [[ ${!var} != ${expected} ]]; then
+		eerror "llvm_fix_tool_path ${var}"
+		eerror "    gave: ${!var}"
+		eerror "expected: ${expected}"
+	fi
+	tend ${?}
+}
+
+test_globals '14 15 16 17 18' \
+	"+llvm_slot_17 llvm_slot_15 llvm_slot_16 llvm_slot_18" \
+	"^^ ( llvm_slot_15 llvm_slot_16 llvm_slot_17 llvm_slot_18 )" \
+	"llvm_slot_15(-)?,llvm_slot_16(-)?,llvm_slot_17(-)?,llvm_slot_18(-)?"
+test_globals '14 15 16' \
+	"+llvm_slot_16 llvm_slot_15" \
+	"^^ ( llvm_slot_15 llvm_slot_16 )" \
+	"llvm_slot_15(-)?,llvm_slot_16(-)?"
+test_globals '15 18' \
+	"+llvm_slot_15 llvm_slot_18" \
+	"^^ ( llvm_slot_15 llvm_slot_18 )" \
+	"llvm_slot_15(-)?,llvm_slot_18(-)?"
+test_globals '18' \
+	"+llvm_slot_18" \
+	"^^ ( llvm_slot_18 )" \
+	"llvm_slot_18(-)?"
+
+LLVM_COMPAT=( {14..18} )
+inherit llvm-r1
+
+test_gen_dep 'sys-devel/llvm:${LLVM_SLOT} sys-devel/clang:${LLVM_SLOT}' <<-EOF
+	llvm_slot_15? ( sys-devel/llvm:15 sys-devel/clang:15 )
+	llvm_slot_16? ( sys-devel/llvm:16 sys-devel/clang:16 )
+	llvm_slot_17? ( sys-devel/llvm:17 sys-devel/clang:17 )
+	llvm_slot_18? ( sys-devel/llvm:18 sys-devel/clang:18 )
+EOF
+
+texit


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
@ 2024-10-08 15:29 Ulrich Müller
  0 siblings, 0 replies; 41+ messages in thread
From: Ulrich Müller @ 2024-10-08 15:29 UTC (permalink / raw
  To: gentoo-commits

commit:     6e088d1b7647178279d58973de2c4906513b3a3e
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 20 18:02:38 2024 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Tue Oct  8 15:22:35 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6e088d1b

versionator.eclass: Remove dead eclass

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 eclass/tests/versionator_version_compare.sh | 199 -----------
 eclass/versionator.eclass                   | 519 ----------------------------
 2 files changed, 718 deletions(-)

diff --git a/eclass/tests/versionator_version_compare.sh b/eclass/tests/versionator_version_compare.sh
deleted file mode 100755
index 2875c0f693da..000000000000
--- a/eclass/tests/versionator_version_compare.sh
+++ /dev/null
@@ -1,199 +0,0 @@
-#!/bin/bash
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-source tests-common.sh || exit
-
-inherit versionator
-
-eshopts_push -s extglob
-ver=( "" "lt" "eq" "gt" )
-lt=1 eq=2 gt=3
-
-test_version_compare() {
-	tbegin "version_compare ${1} -${ver[${2}]} ${3}"
-	version_compare "${1}" "${3}"
-	local r=$?
-	[[ ${r} -eq ${2} ]]
-	tend $? "FAIL: ${@} (got ${r} exp ${2})"
-}
-
-echo "
-	0             $lt 1
-	1             $lt 2
-	2             $gt 1
-	2             $eq 2
-	0             $eq 0
-	10            $lt 20
-	68            $eq 068
-	068           $gt 67
-	068           $lt 69
-
-	1.0           $lt 2.0
-	2.0           $eq 2.0
-	2.0           $gt 1.0
-
-	1.0           $gt 0.0
-	0.0           $eq 0.0
-	0.0           $lt 1.0
-
-	0.1           $lt 0.2
-	0.2           $eq 0.2
-	0.3           $gt 0.2
-
-	1.2           $lt 2.1
-	2.1           $gt 1.2
-
-	1.2.3         $lt 1.2.4
-	1.2.4         $gt 1.2.3
-
-	1.2.0         $gt 1.2
-	1.2.1         $gt 1.2
-	1.2           $lt 1.2.1
-
-	1.2b          $eq 1.2b
-	1.2b          $lt 1.2c
-	1.2b          $gt 1.2a
-	1.2b          $gt 1.2
-	1.2           $lt 1.2a
-
-	1.3           $gt 1.2a
-	1.3           $lt 1.3a
-
-	1.0_alpha7    $lt 1.0_beta7
-	1.0_beta      $lt 1.0_pre
-	1.0_pre5      $lt 1.0_rc2
-	1.0_rc2       $lt 1.0
-
-	1.0_p1        $gt 1.0
-	1.0_p1-r1     $gt 1.0_p1
-
-	1.0_alpha6-r1 $gt 1.0_alpha6
-	1.0_beta6-r1  $gt 1.0_alpha6-r2
-
-	1.0_pre1      $lt 1.0_p1
-
-	1.0p          $gt 1.0_p1
-	1.0r          $gt 1.0-r1
-	1.6.15        $gt 1.6.10-r2
-	1.6.10-r2     $lt 1.6.15
-
-" | while read a b c ; do
-	[[ -z "${a}${b}${c}" ]] && continue
-	test_version_compare "${a}" "${b}" "${c}"
-done
-
-
-for q in "alpha beta pre rc=${lt};${gt}" "p=${gt};${lt}" ; do
-	for p in ${q%%=*} ; do
-		c=${q##*=}
-		alt=${c%%;*} agt=${c##*;}
-		test_version_compare "1.0" $agt "1.0_${p}"
-		test_version_compare "1.0" $agt "1.0_${p}1"
-		test_version_compare "1.0" $agt "1.0_${p}068"
-
-		test_version_compare "2.0_${p}"    $alt "2.0"
-		test_version_compare "2.0_${p}1"   $alt "2.0"
-		test_version_compare "2.0_${p}068" $alt "2.0"
-
-		test_version_compare "1.0_${p}"  $eq "1.0_${p}"
-		test_version_compare "0.0_${p}"  $lt "0.0_${p}1"
-		test_version_compare "666_${p}3" $gt "666_${p}"
-
-		test_version_compare "1_${p}7"  $lt "1_${p}8"
-		test_version_compare "1_${p}7"  $eq "1_${p}7"
-		test_version_compare "1_${p}7"  $gt "1_${p}6"
-		test_version_compare "1_${p}09" $eq "1_${p}9"
-
-		test_version_compare "1_${p}7-r0"  $eq "1_${p}7"
-		test_version_compare "1_${p}7-r0"  $lt "1_${p}7-r1"
-		test_version_compare "1_${p}7-r0"  $lt "1_${p}7-r01"
-		test_version_compare "1_${p}7-r01" $eq "1_${p}7-r1"
-		test_version_compare "1_${p}8-r1"  $gt "1_${p}7-r100"
-
-		test_version_compare "1_${p}_alpha" $lt "1_${p}_beta"
-	done
-done
-
-for p in "-r" "_p" ; do
-	test_version_compare "7.2${p}1" $lt "7.2${p}2"
-	test_version_compare "7.2${p}2" $gt "7.2${p}1"
-	test_version_compare "7.2${p}3" $gt "7.2${p}2"
-	test_version_compare "7.2${p}2" $lt "7.2${p}3"
-done
-
-# The following tests all come from portage's test cases:
-test_version_compare "6.0" $gt "5.0"
-test_version_compare "5.0" $gt "5"
-test_version_compare "1.0-r1" $gt "1.0-r0"
-test_version_compare "1.0-r1" $gt "1.0"
-test_version_compare "999999999999999999999999999999" $gt "999999999999999999999999999998"
-test_version_compare "1.0.0" $gt "1.0"
-test_version_compare "1.0.0" $gt "1.0b"
-test_version_compare "1b" $gt "1"
-test_version_compare "1b_p1" $gt "1_p1"
-test_version_compare "1.1b" $gt "1.1"
-test_version_compare "12.2.5" $gt "12.2b"
-
-test_version_compare "4.0" $lt "5.0"
-test_version_compare "5" $lt "5.0"
-test_version_compare "1.0_pre2" $lt "1.0_p2"
-test_version_compare "1.0_alpha2" $lt "1.0_p2"
-test_version_compare "1.0_alpha1" $lt "1.0_beta1"
-test_version_compare "1.0_beta3" $lt "1.0_rc3"
-test_version_compare "1.001000000000000000001" $lt "1.001000000000000000002"
-test_version_compare "1.00100000000" $lt "1.0010000000000000001"
-test_version_compare "999999999999999999999999999998" $lt "999999999999999999999999999999"
-test_version_compare "1.01" $lt "1.1"
-test_version_compare "1.0-r0" $lt "1.0-r1"
-test_version_compare "1.0" $lt "1.0-r1"
-test_version_compare "1.0" $lt "1.0.0"
-test_version_compare "1.0b" $lt "1.0.0"
-test_version_compare "1_p1" $lt "1b_p1"
-test_version_compare "1" $lt "1b"
-test_version_compare "1.1" $lt "1.1b"
-test_version_compare "12.2b" $lt "12.2.5"
-
-test_version_compare "4.0" $eq "4.0"
-test_version_compare "1.0" $eq "1.0"
-test_version_compare "1.0-r0" $eq "1.0"
-test_version_compare "1.0" $eq "1.0-r0"
-test_version_compare "1.0-r0" $eq "1.0-r0"
-test_version_compare "1.0-r1" $eq "1.0-r1"
-
-# The following were just tests for != in portage, we need something a bit
-# more precise
-test_version_compare "1" $lt "2"
-test_version_compare "1.0_alpha" $lt "1.0_pre"
-test_version_compare "1.0_beta" $gt "1.0_alpha"
-test_version_compare "0" $lt "0.0"
-test_version_compare "1.0-r0" $lt "1.0-r1"
-test_version_compare "1.0-r1" $gt "1.0-r0"
-test_version_compare "1.0" $lt "1.0-r1"
-test_version_compare "1.0-r1" $gt "1.0"
-test_version_compare "1_p1" $lt "1b_p1"
-test_version_compare "1b" $gt "1"
-test_version_compare "1.1b" $gt "1.1"
-test_version_compare "12.2b" $gt "12.2"
-
-# The following tests all come from paludis's test cases:
-test_version_compare "1.0" $gt "1"
-test_version_compare "1" $lt "1.0"
-test_version_compare "1.0_alpha" $gt "1_alpha"
-test_version_compare "1.0_alpha" $gt "1"
-test_version_compare "1.0_alpha" $lt "1.0"
-test_version_compare "1.2.0.0_alpha7-r4" $gt "1.2_alpha7-r4"
-
-test_version_compare "0001" $eq "1"
-test_version_compare "01" $eq "001"
-test_version_compare "0001.1" $eq "1.1"
-test_version_compare "01.01" $eq "1.01"
-test_version_compare "1.010" $eq "1.01"
-test_version_compare "1.00" $eq "1.0"
-test_version_compare "1.0100" $eq "1.010"
-test_version_compare "1" $eq "1-r0"
-test_version_compare "1-r00" $eq "1-r0"
-
-eshopts_pop
-
-texit

diff --git a/eclass/versionator.eclass b/eclass/versionator.eclass
deleted file mode 100644
index 1e491860b6ca..000000000000
--- a/eclass/versionator.eclass
+++ /dev/null
@@ -1,519 +0,0 @@
-# Copyright 1999-2020 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-# @DEAD
-# @ECLASS: versionator.eclass
-# @MAINTAINER:
-# Jonathan Callen <jcallen@gentoo.org>
-# base-system@gentoo.org
-# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6
-# @BLURB: functions which simplify manipulation of ${PV} and similar version strings
-# @DEPRECATED: ver_* functions from EAPI 7
-# @DESCRIPTION:
-# This eclass provides functions which simplify manipulating $PV and similar
-# variables. Most functions default to working with $PV, although other
-# values can be used.
-# @EXAMPLE:
-# Simple Example 1: $PV is 1.2.3b, we want 1_2.3b:
-#     MY_PV=$(replace_version_separator 1 '_' )
-#
-# Simple Example 2: $PV is 1.4.5, we want 1:
-#     MY_MAJORV=$(get_major_version )
-#
-# Rather than being a number, the index parameter can be a separator character
-# such as '-', '.' or '_'. In this case, the first separator of this kind is
-# selected.
-#
-# There's also:
-#     version_is_at_least             want      have
-#  which may be buggy, so use with caution.
-
-if [[ -z ${_VERSIONATOR_ECLASS} ]]; then
-_VERSIONATOR_ECLASS=1
-
-case ${EAPI:-0} in
-	0|1|2|3|4|5|6)
-		;;
-	*)
-		die "${ECLASS}: banned in EAPI=${EAPI}; use ver_* instead";;
-esac
-
-inherit estack
-
-# @FUNCTION: get_all_version_components
-# @USAGE: [version]
-# @DESCRIPTION:
-# Split up a version string into its component parts. If no parameter is
-# supplied, defaults to $PV.
-#     0.8.3       ->  0 . 8 . 3
-#     7c          ->  7 c
-#     3.0_p2      ->  3 . 0 _ p2
-#     20040905    ->  20040905
-#     3.0c-r1     ->  3 . 0 c - r1
-get_all_version_components() {
-	eshopts_push -s extglob
-	local ver_str=${1:-${PV}} result
-	result=()
-
-	# sneaky cache trick cache to avoid having to parse the same thing several
-	# times.
-	if [[ ${VERSIONATOR_CACHE_VER_STR} == ${ver_str} ]] ; then
-		echo ${VERSIONATOR_CACHE_RESULT}
-		eshopts_pop
-		return
-	fi
-	export VERSIONATOR_CACHE_VER_STR=${ver_str}
-
-	while [[ -n $ver_str ]] ; do
-		case "${ver_str::1}" in
-			# number: parse whilst we have a number
-			[[:digit:]])
-				result+=("${ver_str%%[^[:digit:]]*}")
-				ver_str=${ver_str##+([[:digit:]])}
-				;;
-
-			# separator: single character
-			[-_.])
-				result+=("${ver_str::1}")
-				ver_str=${ver_str:1}
-				;;
-
-			# letter: grab the letters plus any following numbers
-			[[:alpha:]])
-				local not_match=${ver_str##+([[:alpha:]])*([[:digit:]])}
-				# Can't say "${ver_str::-${#not_match}}" in Bash 3.2
-				result+=("${ver_str::${#ver_str} - ${#not_match}}")
-				ver_str=${not_match}
-				;;
-
-			# huh?
-			*)
-				result+=("${ver_str::1}")
-				ver_str=${ver_str:1}
-				;;
-		esac
-	done
-
-	export VERSIONATOR_CACHE_RESULT=${result[*]}
-	echo ${result[@]}
-	eshopts_pop
-}
-
-# @FUNCTION: get_version_components
-# @USAGE: [version]
-# @DESCRIPTION:
-# Get the important version components, excluding '.', '-' and '_'. Defaults to
-# $PV if no parameter is supplied.
-#     0.8.3       ->  0 8 3
-#     7c          ->  7 c
-#     3.0_p2      ->  3 0 p2
-#     20040905    ->  20040905
-#     3.0c-r1     ->  3 0 c r1
-get_version_components() {
-	local c=$(get_all_version_components "${1:-${PV}}")
-	echo ${c//[-._]/ }
-}
-
-# @FUNCTION: get_major_version
-# @USAGE: [version]
-# @DESCRIPTION:
-# Get the major version of a value. Defaults to $PV if no parameter is supplied.
-#     0.8.3       ->  0
-#     7c          ->  7
-#     3.0_p2      ->  3
-#     20040905    ->  20040905
-#     3.0c-r1     ->  3
-get_major_version() {
-	local c=($(get_all_version_components "${1:-${PV}}"))
-	echo ${c[0]}
-}
-
-# @FUNCTION: get_version_component_range
-# @USAGE: <range> [version]
-# @DESCRIPTION:
-# Get a particular component or range of components from the version. If no
-# version parameter is supplied, defaults to $PV.
-#    1      1.2.3       -> 1
-#    1-2    1.2.3       -> 1.2
-#    2-     1.2.3       -> 2.3
-get_version_component_range() {
-	eshopts_push -s extglob
-	local c v="${2:-${PV}}" range="${1}" range_start range_end
-	local -i i=-1 j=0
-	c=($(get_all_version_components "${v}"))
-	range_start=${range%-*}; range_start=${range_start:-1}
-	range_end=${range#*-}  ; range_end=${range_end:-${#c[@]}}
-
-	while ((j < range_start)); do
-		i+=1
-		((i > ${#c[@]})) && eshopts_pop && return
-		[[ -n "${c[i]//[-._]}" ]] && j+=1
-	done
-
-	while ((j <= range_end)); do
-		echo -n ${c[i]}
-		((i > ${#c[@]})) && eshopts_pop && return
-		[[ -n "${c[i]//[-._]}" ]] && j+=1
-		i+=1
-	done
-	eshopts_pop
-}
-
-# @FUNCTION: get_after_major_version
-# @USAGE: [version]
-# @DESCRIPTION:
-# Get everything after the major version and its separator (if present) of a
-# value. Defaults to $PV if no parameter is supplied.
-#     0.8.3       ->  8.3
-#     7c          ->  c
-#     3.0_p2      ->  0_p2
-#     20040905    ->  (empty string)
-#     3.0c-r1     ->  0c-r1
-get_after_major_version() {
-	echo $(get_version_component_range 2- "${1:-${PV}}")
-}
-
-# @FUNCTION: replace_version_separator
-# @USAGE: <search> <replacement> [subject]
-# @DESCRIPTION:
-# Replace the $1th separator with $2 in $3 (defaults to $PV if $3 is not
-# supplied). If there are fewer than $1 separators, don't change anything.
-#     1 '_' 1.2.3       -> 1_2.3
-#     2 '_' 1.2.3       -> 1.2_3
-#     1 '_' 1b-2.3      -> 1b_2.3
-# Rather than being a number, $1 can be a separator character such as '-', '.'
-# or '_'. In this case, the first separator of this kind is selected.
-replace_version_separator() {
-	eshopts_push -s extglob
-	local w c v="${3:-${PV}}"
-	declare -i i found=0
-	w=${1:-1}
-	c=($(get_all_version_components ${v}))
-	if [[ ${w} != *[[:digit:]]* ]] ; then
-		# it's a character, not an index
-		for ((i = 0; i < ${#c[@]}; i++)); do
-			if [[ ${c[i]} == ${w} ]]; then
-				c[i]=${2}
-				break
-			fi
-		done
-	else
-		for ((i = 0; i < ${#c[@]}; i++)); do
-			if [[ -n "${c[i]//[^-._]}" ]]; then
-				found+=1
-				if ((found == w)); then
-					c[i]=${2}
-					break
-				fi
-			fi
-		done
-	fi
-	c=${c[*]}
-	echo ${c// }
-	eshopts_pop
-}
-
-# @FUNCTION: replace_all_version_separators
-# @USAGE: <replacement> [subject]
-# @DESCRIPTION:
-# Replace all version separators in $2 (defaults to $PV) with $1.
-#     '_' 1b.2.3        -> 1b_2_3
-replace_all_version_separators() {
-	local c=($(get_all_version_components "${2:-${PV}}"))
-	c=${c[@]//[-._]/$1}
-	echo ${c// }
-}
-
-# @FUNCTION: delete_version_separator
-# @USAGE: <search> [subject]
-# @DESCRIPTION:
-# Delete the $1th separator in $2 (defaults to $PV if $2 is not supplied). If
-# there are fewer than $1 separators, don't change anything.
-#     1 1.2.3       -> 12.3
-#     2 1.2.3       -> 1.23
-#     1 1b-2.3      -> 1b2.3
-# Rather than being a number, $1 can be a separator character such as '-', '.'
-# or '_'. In this case, the first separator of this kind is deleted.
-delete_version_separator() {
-	replace_version_separator "${1}" "" "${2}"
-}
-
-# @FUNCTION: delete_all_version_separators
-# @USAGE: [subject]
-# @DESCRIPTION:
-# Delete all version separators in $1 (defaults to $PV).
-#     1b.2.3        -> 1b23
-delete_all_version_separators() {
-	replace_all_version_separators "" "${1}"
-}
-
-# @FUNCTION: get_version_component_count
-# @USAGE: [version]
-# @DESCRIPTION:
-# How many version components are there in $1 (defaults to $PV)?
-#     1.0.1       ->  3
-#     3.0c-r1     ->  4
-get_version_component_count() {
-	local a=($(get_version_components "${1:-${PV}}"))
-	echo ${#a[@]}
-}
-
-# @FUNCTION: get_last_version_component_index
-# @USAGE: [version]
-# @DESCRIPTION:
-# What is the index of the last version component in $1 (defaults to $PV)?
-# Equivalent to get_version_component_count - 1.
-#     1.0.1       ->  2
-#     3.0c-r1     ->  3
-get_last_version_component_index() {
-	echo $(($(get_version_component_count "${1:-${PV}}" ) - 1))
-}
-
-# @FUNCTION: version_is_at_least
-# @USAGE: <want> [have]
-# @DESCRIPTION:
-# Is $2 (defaults to $PVR) at least version $1? Intended for use in eclasses
-# only. May not be reliable, be sure to do very careful testing before actually
-# using this.
-version_is_at_least() {
-	local want_s="$1" have_s="${2:-${PVR}}" r
-	version_compare "${want_s}" "${have_s}"
-	r=$?
-	case $r in
-		1|2)
-			return 0
-			;;
-		3)
-			return 1
-			;;
-		*)
-			die "versionator compare bug [atleast, ${want_s}, ${have_s}, ${r}]"
-			;;
-	esac
-}
-
-# @FUNCTION: version_compare
-# @USAGE: <A> <B>
-# @DESCRIPTION:
-# Takes two parameters (A, B) which are versions. If A is an earlier version
-# than B, returns 1. If A is identical to B, return 2. If A is later than B,
-# return 3. You probably want version_is_at_least rather than this function.
-# May not be very reliable. Test carefully before using this.
-version_compare() {
-	eshopts_push -s extglob
-	local ver_a=${1} ver_b=${2} parts_a parts_b
-	local cur_tok_a cur_tok_b num_part_a num_part_b
-	local -i cur_idx_a=0 cur_idx_b=0 prev_idx_a prev_idx_b
-	parts_a=( $(get_all_version_components "${ver_a}" ) )
-	parts_b=( $(get_all_version_components "${ver_b}" ) )
-
-	### compare number parts.
-	local -i inf_loop=0
-	while true; do
-		inf_loop+=1
-		((inf_loop > 20)) && \
-			die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]"
-
-		# Store the current index to test later
-		prev_idx_a=cur_idx_a
-		prev_idx_b=cur_idx_b
-
-		# grab the current number components
-		cur_tok_a=${parts_a[cur_idx_a]}
-		cur_tok_b=${parts_b[cur_idx_b]}
-
-		# number?
-		if [[ -n ${cur_tok_a} ]] && [[ -z ${cur_tok_a//[[:digit:]]} ]] ; then
-			cur_idx_a+=1
-			[[ ${parts_a[cur_idx_a]} == . ]] \
-				&& cur_idx_a+=1
-		else
-			cur_tok_a=
-		fi
-
-		if [[ -n ${cur_tok_b} ]] && [[ -z ${cur_tok_b//[[:digit:]]} ]] ; then
-			cur_idx_b+=1
-			[[ ${parts_b[cur_idx_b]} == . ]] \
-				&& cur_idx_b+=1
-		else
-			cur_tok_b=
-		fi
-
-		# done with number components?
-		[[ -z ${cur_tok_a} && -z ${cur_tok_b} ]] && break
-
-		# if a component is blank, then it is the lesser value
-		[[ -z ${cur_tok_a} ]] && eshopts_pop && return 1
-		[[ -z ${cur_tok_b} ]] && eshopts_pop && return 3
-
-		# According to PMS, if we are *not* in the first number part, and either
-		# token begins with "0", then we use a different algorithm (that
-		# effectively does floating point comparison)
-		if (( prev_idx_a != 0 && prev_idx_b != 0 )) \
-			&& [[ ${cur_tok_a} == 0* || ${cur_tok_b} == 0* ]] ; then
-
-			# strip trailing zeros
-			cur_tok_a=${cur_tok_a%%+(0)}
-			cur_tok_b=${cur_tok_b%%+(0)}
-
-			# do a *string* comparison of the resulting values: 2 > 11
-			[[ ${cur_tok_a} < ${cur_tok_b} ]] && eshopts_pop && return 1
-			[[ ${cur_tok_a} > ${cur_tok_b} ]] && eshopts_pop && return 3
-		else
-			# to avoid going into octal mode, strip any leading zeros. otherwise
-			# bash will throw a hissy fit on versions like 6.3.068.
-			cur_tok_a=${cur_tok_a##+(0)}
-			cur_tok_b=${cur_tok_b##+(0)}
-
-			# now if a component is blank, it was originally 0 -- make it so
-			: ${cur_tok_a:=0}
-			: ${cur_tok_b:=0}
-
-			# compare
-			((cur_tok_a < cur_tok_b)) && eshopts_pop && return 1
-			((cur_tok_a > cur_tok_b)) && eshopts_pop && return 3
-		fi
-	done
-
-	### number parts equal. compare letter parts.
-	local letter_a=
-	letter_a=${parts_a[cur_idx_a]}
-	if [[ ${#letter_a} -eq 1 && -z ${letter_a/[a-z]} ]] ; then
-		cur_idx_a+=1
-	else
-		letter_a=@
-	fi
-
-	local letter_b=
-	letter_b=${parts_b[cur_idx_b]}
-	if [[ ${#letter_b} -eq 1 && -z ${letter_b/[a-z]} ]] ; then
-		cur_idx_b+=1
-	else
-		letter_b=@
-	fi
-
-	# compare
-	[[ ${letter_a} < ${letter_b} ]] && eshopts_pop && return 1
-	[[ ${letter_a} > ${letter_b} ]] && eshopts_pop && return 3
-
-	### letter parts equal. compare suffixes in order.
-	inf_loop=0
-	while true ; do
-		inf_loop+=1
-		((inf_loop > 20)) && \
-			die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]"
-		[[ ${parts_a[cur_idx_a]} == _ ]] && ((cur_idx_a++))
-		[[ ${parts_b[cur_idx_b]} == _ ]] && ((cur_idx_b++))
-
-		cur_tok_a=${parts_a[cur_idx_a]}
-		cur_tok_b=${parts_b[cur_idx_b]}
-		num_part_a=0
-		num_part_b=0
-
-		if has ${cur_tok_a%%+([0-9])} "alpha" "beta" "pre" "rc" "p"; then
-			cur_idx_a+=1
-			num_part_a=${cur_tok_a##+([a-z])}
-			# I don't like octal
-			num_part_a=${num_part_a##+(0)}
-			: ${num_part_a:=0}
-			cur_tok_a=${cur_tok_a%%+([0-9])}
-		else
-			cur_tok_a=
-		fi
-
-		if has ${cur_tok_b%%+([0-9])} alpha beta pre rc p; then
-			cur_idx_b+=1
-			num_part_b=${cur_tok_b##+([a-z])}
-			# I still don't like octal
-			num_part_b=${num_part_b##+(0)}
-			: ${num_part_b:=0}
-			cur_tok_b=${cur_tok_b%%+([0-9])}
-		else
-			cur_tok_b=
-		fi
-
-		if [[ ${cur_tok_a} != ${cur_tok_b} ]]; then
-			local suffix
-			for suffix in alpha beta pre rc "" p; do
-				[[ ${cur_tok_a} == ${suffix} ]] && eshopts_pop && return 1
-				[[ ${cur_tok_b} == ${suffix} ]] && eshopts_pop && return 3
-			done
-		elif [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]]; then
-			break
-		else
-			((num_part_a < num_part_b)) && eshopts_pop && return 1
-			((num_part_a > num_part_b)) && eshopts_pop && return 3
-		fi
-	done
-
-	# At this point, the only thing that should be left is the -r# part
-	[[ ${parts_a[cur_idx_a]} == - ]] && ((cur_idx_a++))
-	[[ ${parts_b[cur_idx_b]} == - ]] && ((cur_idx_b++))
-
-	# Sanity check
-	if [[ ${parts_a[cur_idx_a]/r+([0-9])} || ${parts_b[cur_idx_b]/r+([0-9])} ]]; then
-		die "versionator compare bug [revisions, ${ver_a}, ${ver_b}]"
-	fi
-
-	num_part_a=${parts_a[cur_idx_a]#r}
-	num_part_a=${num_part_a##+(0)}
-	: ${num_part_a:=0}
-	num_part_b=${parts_b[cur_idx_b]#r}
-	num_part_b=${num_part_b##+(0)}
-	: ${num_part_b:=0}
-
-	((num_part_a < num_part_b)) && eshopts_pop && return 1
-	((num_part_a > num_part_b)) && eshopts_pop && return 3
-
-	### no differences.
-	eshopts_pop
-	return 2
-}
-
-# @FUNCTION: version_sort
-# @USAGE: <version> [more versions...]
-# @DESCRIPTION:
-# Returns its parameters sorted, highest version last. We're using a quadratic
-# algorithm for simplicity, so don't call it with more than a few dozen items.
-# Uses version_compare, so be careful.
-version_sort() {
-	eshopts_push -s extglob
-	local items=
-	local -i left=0
-	items=("$@")
-	while ((left < ${#items[@]})); do
-		local -i lowest_idx=left
-		local -i idx=lowest_idx+1
-		while ((idx < ${#items[@]})); do
-			version_compare "${items[lowest_idx]}" "${items[idx]}"
-			[[ $? -eq 3 ]] && lowest_idx=idx
-			idx+=1
-		done
-		local tmp=${items[lowest_idx]}
-		items[lowest_idx]=${items[left]}
-		items[left]=${tmp}
-		left+=1
-	done
-	echo ${items[@]}
-	eshopts_pop
-}
-
-# @FUNCTION: version_format_string
-# @USAGE: <format> [version]
-# @DESCRIPTION:
-# Reformat complicated version strings.  The first argument is the string
-# to reformat with while the rest of the args are passed on to the
-# get_version_components function.  You should make sure to single quote
-# the first argument since it'll have variables that get delayed expansions.
-# @EXAMPLE:
-# P="cow-hat-1.2.3_p4"
-# MY_P=$(version_format_string '${PN}_source_$1_$2-$3_$4')
-# Now MY_P will be: cow-hat_source_1_2-3_p4
-version_format_string() {
-	local fstr=$1
-	shift
-	set -- $(get_version_components "$@")
-	eval echo "${fstr}"
-}
-
-fi


^ permalink raw reply related	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2024-10-08 15:30 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-02 15:21 [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/ Michał Górny
  -- strict thread matches above, loose matches on Subject: below --
2024-10-08 15:29 Ulrich Müller
2024-02-10 10:47 Michał Górny
2024-02-10 10:47 Michał Górny
2023-09-14  5:30 Michał Górny
2023-06-18 14:57 Michał Górny
2023-06-18 14:57 Michał Górny
2023-06-07  9:03 Ulrich Müller
2022-11-15 16:34 Michał Górny
2022-10-10 20:52 Michał Górny
2022-09-28 20:55 Michał Górny
2022-05-01  7:30 Michał Górny
2022-02-09  9:39 Michał Górny
2022-01-09  8:09 Michał Górny
2021-06-23 21:44 Michał Górny
2021-01-15 17:05 Michał Górny
2021-01-05 23:01 Sergei Trofimovich
2020-05-25  6:12 Michał Górny
2020-03-28 19:54 Sergei Trofimovich
2020-03-26  7:51 Sergei Trofimovich
2020-01-11 23:53 Sergei Trofimovich
2019-12-30 12:59 Michał Górny
2019-12-30 12:59 Michał Górny
2019-12-24 11:01 Sergei Trofimovich
2018-04-18 18:13 Mike Gilbert
2018-01-04 21:56 Michał Górny
2017-09-26 18:46 Ulrich Müller
2017-09-19 11:08 Michał Górny
2017-08-25 13:53 Michał Górny
2017-08-11 14:35 Michał Górny
2017-08-08 19:42 Michał Górny
2017-03-18  7:33 Michał Górny
2017-02-09 18:16 Mike Frysinger
2016-12-18 13:46 Michał Górny
2016-06-27  5:58 Michał Górny
2016-06-26 15:36 Michał Górny
2016-01-08  5:14 Michał Górny
2016-01-08  5:14 Michał Górny
2015-12-09 20:42 Michał Górny
2015-11-24 17:03 Mike Frysinger
2015-11-11 10:27 Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox