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 6564C1381F3 for ; Thu, 4 Apr 2013 20:51:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4C785E0887; Thu, 4 Apr 2013 20:50:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6B0ECE0864 for ; Thu, 4 Apr 2013 20:50:52 +0000 (UTC) Received: from pomiocik.lan (77-253-144-190.adsl.inetia.pl [77.253.144.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id AE1AC33DC52; Thu, 4 Apr 2013 20:50:50 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 1/2] Move header wrapping code into multilib-build. Date: Thu, 4 Apr 2013 22:51:19 +0200 Message-Id: <1365108680-22099-1-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <20130404225046.434b7ba1@pomiocik.lan> References: <20130404225046.434b7ba1@pomiocik.lan> 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 X-Archives-Salt: 1dfe93a6-2536-459a-b00c-0b0030970fdc X-Archives-Hash: ba9b6f841c5909f304bb35afe5cf5d58 --- gx86/eclass/autotools-multilib.eclass | 82 +---------------------- gx86/eclass/multilib-build.eclass | 121 ++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 79 deletions(-) diff --git a/gx86/eclass/autotools-multilib.eclass b/gx86/eclass/autotools-multilib.eclass index 55d32d7..6b0960f 100644 --- a/gx86/eclass/autotools-multilib.eclass +++ b/gx86/eclass/autotools-multilib.eclass @@ -33,28 +33,6 @@ inherit autotools-utils multilib-build EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install -# @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS -# @DESCRIPTION: -# A list of headers to wrap for multilib support. The listed headers -# will be moved to a non-standard location and replace with a file -# including them conditionally to current ABI. -# -# This variable has to be a bash array. Paths shall be relative to -# installation root (${ED}), and name regular files. Recursive wrapping -# is not supported. -# -# Please note that header wrapping is *discouraged*. It is preferred to -# install all headers in a subdirectory of libdir and use pkg-config to -# locate the headers. Some C preprocessors will not work with wrapped -# headers. -# -# Example: -# @CODE -# MULTILIB_WRAPPED_HEADERS=( -# /usr/include/foobar/config.h -# ) -# @CODE - autotools-multilib_src_prepare() { autotools-utils_src_prepare "${@}" } @@ -71,71 +49,17 @@ autotools-multilib_src_test() { multilib_foreach_abi autotools-utils_src_test "${@}" } -_autotools-multilib_wrap_headers() { - debug-print-function ${FUNCNAME} "$@" - local f - - for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do - # drop leading slash if it's there - f=${f#/} - - if [[ ${f} != usr/include/* ]]; then - die "Wrapping headers outside of /usr/include is not supported at the moment." - fi - # and then usr/include - f=${f#usr/include} - - local dir=${f%/*} - - # $CHOST shall be set by multilib_toolchain_setup - dodir "/tmp/multilib-include/${CHOST}${dir}" - mv "${ED}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die - - if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then - dodir "/tmp/multilib-include${dir}" - # a generic template - cat > "${ED}/tmp/multilib-include${f}" <<_EOF_ || die -/* This file is auto-generated by autotools-multilib.eclass - * as a multilib-friendly wrapper. For the original content, - * please see the files that are #included below. - */ - -#if defined(__x86_64__) /* amd64 */ -# if defined(__ILP32__) /* x32 ABI */ -# error "x86_x32 not supported by the package." -# else /* 64-bit ABI */ -# error "x86_64 not supported by the package." -# endif -#elif defined(__i386__) /* plain x86 */ -# error "x86_32 not supported by the package." -#else -# error "No ABI matched, please report a bug to bugs.gentoo.org" -#endif -_EOF_ - fi - - # Note: match a space afterwards to avoid collision potential. - sed -e "/${MULTILIB_ABI} /s&error.*&include <${CHOST}/${f}>&" \ - -i "${ED}/tmp/multilib-include${f}" || die - done -} - autotools-multilib_src_install() { autotools-multilib_secure_install() { autotools-utils_src_install "${@}" - _autotools-multilib_wrap_headers + multilib_prepare_wrappers # Make sure all headers are the same for each ABI. multilib_check_headers } multilib_foreach_abi autotools-multilib_secure_install "${@}" - # merge the wrapped headers - if [[ -d "${ED}"/tmp/multilib-include ]]; then - multibuild_merge_root \ - "${ED}"/tmp/multilib-include "${ED}"/usr/include - # it can fail if something else uses /tmp - rmdir "${ED}"/tmp &>/dev/null - fi + # merge the wrappers + multilib_install_wrappers } diff --git a/gx86/eclass/multilib-build.eclass b/gx86/eclass/multilib-build.eclass index fdaed6b..f0c433b 100644 --- a/gx86/eclass/multilib-build.eclass +++ b/gx86/eclass/multilib-build.eclass @@ -235,5 +235,126 @@ multilib_copy_sources() { multibuild_copy_sources } +# @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS +# @DESCRIPTION: +# A list of headers to wrap for multilib support. The listed headers +# will be moved to a non-standard location and replaced with a file +# including them conditionally to current ABI. +# +# This variable has to be a bash array. Paths shall be relative to +# installation root (${ED}), and name regular files. Recursive wrapping +# is not supported. +# +# Please note that header wrapping is *discouraged*. It is preferred to +# install all headers in a subdirectory of libdir and use pkg-config to +# locate the headers. Some C preprocessors will not work with wrapped +# headers. +# +# Example: +# @CODE +# MULTILIB_WRAPPED_HEADERS=( +# /usr/include/foobar/config.h +# ) +# @CODE + +# @FUNCTION: multilib_prepare_wrappers +# @USAGE: [] +# @DESCRIPTION: +# Perform the preparation of all kinds of wrappers for the current ABI. +# This function shall be called once per each ABI, after installing +# the files to be wrapped. +# +# Takes an optional custom from which files will be +# used. If no root is specified, uses ${ED}. +# +# The files to be wrapped are specified using separate variables, +# e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed +# between the successive calls to multilib_prepare_wrappers +# and multilib_install_wrappers. +# +# After all wrappers are prepared, multilib_install_wrappers shall +# be called to commit them to the installation tree. +multilib_prepare_wrappers() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments" + + local root=${1:-${ED}} + local f + + for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do + # drop leading slash if it's there + f=${f#/} + + if [[ ${f} != usr/include/* ]]; then + die "Wrapping headers outside of /usr/include is not supported at the moment." + fi + # and then usr/include + f=${f#usr/include} + + local dir=${f%/*} + + # $CHOST shall be set by multilib_toolchain_setup + dodir "/tmp/multilib-include/${CHOST}${dir}" + mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die + + if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then + dodir "/tmp/multilib-include${dir}" + # a generic template + cat > "${ED}/tmp/multilib-include${f}" <<_EOF_ || die +/* This file is auto-generated by multilib-build.eclass + * as a multilib-friendly wrapper. For the original content, + * please see the files that are #included below. + */ + +#if defined(__x86_64__) /* amd64 */ +# if defined(__ILP32__) /* x32 ABI */ +# error "x86_x32 not supported by the package." +# else /* 64-bit ABI */ +# error "x86_64 not supported by the package." +# endif +#elif defined(__i386__) /* plain x86 */ +# error "x86_32 not supported by the package." +#else +# error "No ABI matched, please report a bug to bugs.gentoo.org" +#endif +_EOF_ + fi + + # Note: match a space afterwards to avoid collision potential. + sed -e "/${MULTILIB_ABI} /s&error.*&include <${CHOST}/${f}>&" \ + -i "${ED}/tmp/multilib-include${f}" || die + done +} + +# @FUNCTION: multilib_install_wrappers +# @USAGE: [] +# @DESCRIPTION: +# Install the previously-prepared wrappers. This function shall +# be called once, after all wrappers were prepared. +# +# Takes an optional custom to which the wrappers will be +# installed. If no root is specified, uses ${ED}. There is no need to +# use the same root as when preparing the wrappers. +# +# The files to be wrapped are specified using separate variables, +# e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed +# between the calls to multilib_prepare_wrappers +# and multilib_install_wrappers. +multilib_install_wrappers() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments" + + local root=${1:-${ED}} + + if [[ -d "${ED}"/tmp/multilib-include ]]; then + multibuild_merge_root \ + "${ED}"/tmp/multilib-include "${root}"/usr/include + # it can fail if something else uses /tmp + rmdir "${ED}"/tmp &>/dev/null + fi +} + _MULTILIB_BUILD=1 fi -- 1.8.1.5