From: Alec Warner <antarus@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: python@gentoo.org, hasufell@gentoo.org, ulm@gentoo.org,
"Michał Górny" <mgorny@gentoo.org>
Subject: Re: [gentoo-dev] [PATCH] multibuild: introduce a generic framework for custom phase functions.
Date: Sun, 10 Mar 2013 11:37:09 -0700 [thread overview]
Message-ID: <CAAr7Pr9jPLH9kvobO2wBeb9zA+QX-Y+vh+dqABV2i1pbVif5pA@mail.gmail.com> (raw)
In-Reply-To: <1362930617-20031-1-git-send-email-mgorny@gentoo.org>
On Sun, Mar 10, 2013 at 8:50 AM, Michał Górny <mgorny@gentoo.org> wrote:
> The framework provides functions to declare, export and obtain custom
> phase functions.
Thanks for fixing this up.
-A
>
> Each of the custom phases can be defined by eclasses and ebuilds
> in a manner similar to regular phases. The eclasses define
> ${ECLASS}_${phase} function and run 'multibuild_export_phases' to
> register them. The ebuilds define ${phase} function and it automatically
> takes precedence over eclass-defined ones.
> ---
> gx86/eclass/multibuild.eclass | 66 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 66 insertions(+)
>
> diff --git a/gx86/eclass/multibuild.eclass b/gx86/eclass/multibuild.eclass
> index bc510e9..3187c9e 100644
> --- a/gx86/eclass/multibuild.eclass
> +++ b/gx86/eclass/multibuild.eclass
> @@ -245,5 +245,71 @@ run_in_build_dir() {
> return ${ret}
> }
>
> +# @ECLASS-VARIABLE: _MULTIBUILD_EXPORTED_PHASES
> +# @INTERNAL
> +# @DESCRIPTION:
> +# The list of currently exported phase functions.
> +#
> +# Each function is stored in the form of 'eclass:phase-name'.
> +# New exports are prepended to the list, so the first matching value
> +# is the most recent one.
> +_MULTIBUILD_EXPORTED_PHASES=()
> +
> +# @FUNCTION: multibuild_export_phases
> +# @USAGE: <phase-name>...
> +# @DESCRIPTION:
> +# Export the eclass phase functions for named phases. The functions need
> +# be named ${ECLASS}_<phase-name>. The exported functions will override
> +# any previously exported phases.
> +multibuild_export_phases() {
> + debug-print-function ${FUNCNAME} "${@}"
> +
> + [[ ${#} -eq 0 ]] && die "Usage: multibuild_export_phases <phase-name>..."
> +
> + # just prepend to the list
> + _MULTIBUILD_EXPORTED_PHASES=(
> + "${@/#/${ECLASS}:}"
> + "${_MULTIBUILD_EXPORTED_PHASES[@]}"
> + )
> +}
> +
> +# @FUNCTION: multibuild_get_phase_function
> +# @USAGE: <phase-name>
> +# @DESCRIPTION:
> +# Find the topmost handler for the named phase. It can be either
> +# user-defined phase handler (with the same name as the phase)
> +# or a handler exported most recently by an eclass.
> +#
> +# Prints the function name to stdout or null string if there is
> +# no handler for the phase.
> +multibuild_get_phase_function() {
> + debug-print-function ${FUNCNAME} "${@}"
> +
> + [[ ${#} -ne 1 ]] && die "Usage: multibuild_get_phase_function <phase-name>"
> +
> + local phase=${1}
> +
> + # user-defined phase
> + if ! declare -f "${phase}" >/dev/null; then
> + local found p
> + for p in "${_MULTIBUILD_EXPORTED_PHASES[@]}"; do
> + if [[ ${p} == *:${phase} ]]; then
> + # we're breaking out, so we can overwrite it.
> + phase=${p/:/_}
> + found=1
> + break
> + fi
> + done
> +
> + if [[ ! ${found} ]]; then
> + return
> + elif ! declare -f "${phase}" >/dev/null; then
> + die "Phase function ${phase} exported but never defined!"
> + fi
> + fi
> +
> + echo "${phase}"
> +}
> +
> _MULTIBUILD=1
> fi
> --
> 1.8.1.5
>
>
next prev parent reply other threads:[~2013-03-10 18:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-10 10:16 [gentoo-dev] [PATCHES] multibuild.eclass: custom phase function helpers Michał Górny
2013-03-10 10:18 ` [gentoo-dev] [PATCH 1/7] multibuild: introduce a generic framework for custom phase functions Michał Górny
2013-03-10 11:36 ` Ulrich Mueller
2013-03-10 12:16 ` Ulrich Mueller
2013-03-10 12:18 ` Ciaran McCreesh
2013-03-10 13:19 ` Michał Górny
2013-03-10 13:44 ` Ulrich Mueller
2013-03-10 13:48 ` Michał Górny
2013-03-10 15:26 ` Ciaran McCreesh
2013-03-10 15:46 ` Michał Górny
2013-03-10 15:46 ` Ciaran McCreesh
2013-03-10 15:50 ` [gentoo-dev] [PATCH] " Michał Górny
2013-03-10 18:37 ` Alec Warner [this message]
2013-03-10 10:18 ` [gentoo-dev] [PATCH 2/7] distutils-r1: use multibuild phase helpers Michał Górny
2013-03-10 10:18 ` [gentoo-dev] [PATCH 3/7] multilib-minimal: split out mkdir to unify sub-functions Michał Górny
2013-03-10 10:18 ` [gentoo-dev] [PATCH 4/7] multilib-minimal: reuse run_in_build_dir Michał Górny
2013-03-10 10:18 ` [gentoo-dev] [PATCH 5/7] multilib-minimal: reuse multibuild phase function handlers Michał Górny
2013-03-10 10:18 ` [gentoo-dev] [PATCH 6/7] multilib-minimal: run multilib_src_configure in parallel Michał Górny
2013-03-10 10:18 ` [gentoo-dev] [PATCH 7/7] autotools-multilib: reuse phase functions from multilib-minimal Michał Górny
2013-03-17 13:35 ` [gentoo-dev] [PATCHES] multibuild.eclass: custom phase function helpers 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=CAAr7Pr9jPLH9kvobO2wBeb9zA+QX-Y+vh+dqABV2i1pbVif5pA@mail.gmail.com \
--to=antarus@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
--cc=hasufell@gentoo.org \
--cc=mgorny@gentoo.org \
--cc=python@gentoo.org \
--cc=ulm@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