From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
Date: Tue, 15 Nov 2022 16:34:55 +0000 (UTC) [thread overview]
Message-ID: <1668530046.95a6dff78a57dde2133dba050d16cae2c5113b23.mgorny@gentoo> (raw)
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
next reply other threads:[~2022-11-15 16:34 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 16:34 Michał Górny [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-03-03 19:27 [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/ Sam James
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-07-02 15:21 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-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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1668530046.95a6dff78a57dde2133dba050d16cae2c5113b23.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox