Here's an eclass proposal to wrap EXPORT_FUNCTIONS with auto detection
of functions. This way all eclasses don't have to duplicate the EAPI
detection code. If people find this useful, I will document it properly
with eclass-manpages etc.

Regards,
Petteri
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

#
# Original Author: Petteri Räty <betelge...@gentoo.org>
# Purpose: Automatically export functions.
#

EAPI_FUNCTIONS=(
        [0]="
        pkg_setup
        src_unpack
        src_compile
        src_install
        pkg_prerm
        pkg_postrm
        pkg_preinst
        pkg_postinst
        "
        [1]=""
        [2]="
        src_prepare
        src_configure
        "
)

#function has() {
#       true
#}

has ${EAPI:-0} ${!eapi_functio...@]} || DEPEND="UNKNOWN_EAPI"

func-exists() {
        declare -F ${1} > /dev/null
}

auto-export() {
        local result=''
        for eapi in ${!eapi_functio...@]}; do
                for func in ${EAPI_FUNCTIONS[${eapi}]}; do
                        func-exists ${ECLASS}_${func} && result="${result} 
${func}"
                done

                [[ ${eapi} == ${EAPI:-0} ]] && break
        done

        echo "exporting ${result}"
        EXPORT_FUNCTIONS ${result}
}

#function EXPORT_FUNCTIONS() {
#       echo "$...@}"
#}

#ECLASS="foo"
#foo_src_unpack() { :; }

#auto-export

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to