From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 7FE49198005 for ; Sun, 10 Mar 2013 18:37:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A9908E0802; Sun, 10 Mar 2013 18:37:11 +0000 (UTC) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BCD07E07FB for ; Sun, 10 Mar 2013 18:37:10 +0000 (UTC) Received: by mail-ve0-f172.google.com with SMTP id cz11so2232964veb.31 for ; Sun, 10 Mar 2013 11:37:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:x-originating-ip:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding:x-gm-message-state; bh=vGraxgy4HI5JjV4SihAwQBqAU/Xj34Pyl5U496wsLIg=; b=ZI9Ng4wEWczcDj/D8h9TdPejp7dKrgaKtwAsK1sIn9eJCQGaHTwxfMV9dtkEsvybUj 7Zsm+zIUiUY141R9t1RA/3qzzAz8UR/nCtLB9WTyzE/pXQHpx+dYZhmwKq2fc1Kql7eu uV8+sClwQTTC4nUJs83vY0LE0hC8of00oOAz6Xl4xruxv8/6d4SZUv+DeEj/xI2Ofo8d DeA3pDVkhMDwJaJ9Bb3+TMd6HxicwWZtaK0iQcNqs/XAZpx8CDmjTy2zTGX2fQmudfxI oySoqDqygnOByg2Sv3EMVDvXiemNwwYhu7He40fsH8bV/ZYN2AWdkDiJDw4Bd4jW982u +v6w== Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 X-Received: by 10.52.17.104 with SMTP id n8mr3328773vdd.12.1362940629854; Sun, 10 Mar 2013 11:37:09 -0700 (PDT) Sender: antarus@scriptkitty.com Received: by 10.220.4.78 with HTTP; Sun, 10 Mar 2013 11:37:09 -0700 (PDT) X-Originating-IP: [75.147.136.182] In-Reply-To: <1362930617-20031-1-git-send-email-mgorny@gentoo.org> References: <20796.31150.637490.654018@a1i15.kph.uni-mainz.de> <1362930617-20031-1-git-send-email-mgorny@gentoo.org> Date: Sun, 10 Mar 2013 11:37:09 -0700 X-Google-Sender-Auth: N4LCtvIReiApR8dENOYA3kWNK50 Message-ID: Subject: Re: [gentoo-dev] [PATCH] multibuild: introduce a generic framework for custom phase functions. From: Alec Warner To: gentoo-dev@lists.gentoo.org Cc: python@gentoo.org, hasufell@gentoo.org, ulm@gentoo.org, =?UTF-8?B?TWljaGHFgiBHw7Nybnk=?= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQm3a1CdsLKXc33sA5q3VBGSBwTqNovwR6IPBZBX6tPbkFUdTsS16ZYEWkVNQewqqtaMMj9f X-Archives-Salt: 08a067db-a619-4a5a-96e3-d9547811b008 X-Archives-Hash: b09015bf2909f84b19b646eb2f8ff5c3 On Sun, Mar 10, 2013 at 8:50 AM, Micha=C5=82 G=C3=B3rny = 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.eclas= s > 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=3D() > + > +# @FUNCTION: multibuild_export_phases > +# @USAGE: ... > +# @DESCRIPTION: > +# Export the eclass phase functions for named phases. The functions need > +# be named ${ECLASS}_. The exported functions will override > +# any previously exported phases. > +multibuild_export_phases() { > + debug-print-function ${FUNCNAME} "${@}" > + > + [[ ${#} -eq 0 ]] && die "Usage: multibuild_export_phases ..." > + > + # just prepend to the list > + _MULTIBUILD_EXPORTED_PHASES=3D( > + "${@/#/${ECLASS}:}" > + "${_MULTIBUILD_EXPORTED_PHASES[@]}" > + ) > +} > + > +# @FUNCTION: multibuild_get_phase_function > +# @USAGE: > +# @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 " > + > + local phase=3D${1} > + > + # user-defined phase > + if ! declare -f "${phase}" >/dev/null; then > + local found p > + for p in "${_MULTIBUILD_EXPORTED_PHASES[@]}"; do > + if [[ ${p} =3D=3D *:${phase} ]]; then > + # we're breaking out, so we can overwrite= it. > + phase=3D${p/:/_} > + found=3D1 > + break > + fi > + done > + > + if [[ ! ${found} ]]; then > + return > + elif ! declare -f "${phase}" >/dev/null; then > + die "Phase function ${phase} exported but never d= efined!" > + fi > + fi > + > + echo "${phase}" > +} > + > _MULTIBUILD=3D1 > fi > -- > 1.8.1.5 > >