Skip to content

Commit

Permalink
epunt-cxx.eclass: Split C++ check punting code out of eutils
Browse files Browse the repository at this point in the history
Split the epunt_cxx (plus internal code) to a dedicated eclass. This is
rarely needed, usually indicates a dead upstream and requires
the ELT-patches framework. The patches are going to be split to
a separate package, and the new eclass will therefore need to DEPEND
on it. We do not want the dependency to apply to all eutils users
though.
  • Loading branch information
mgorny committed Mar 24, 2017
1 parent 3e8715e commit f1c4804
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 42 deletions.
65 changes: 65 additions & 0 deletions eclass/epunt-cxx.eclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

# @ECLASS: epunt-cxx.eclass
# @MAINTAINER:
# [email protected]
# @BLURB: A function to punt C++ compiler checks from autoconf
# @DESCRIPTION:
# Support for punting C++ compiler checks from autoconf (based
# on ELT-patches).

if [[ -z ${_EPUNT_CXX_ECLASS} ]]; then

# TODO: replace this with 'inherit eutils' once eutils stops inheriting
# us
if ! declare -F eqawarn >/dev/null ; then
eqawarn() {
has qa ${PORTAGE_ELOG_CLASSES} && ewarn "$@"
:
}
fi

# If an overlay has eclass overrides, but doesn't actually override the
# libtool.eclass, we'll have ECLASSDIR pointing to the active overlay's
# eclass/ dir, but libtool.eclass is still in the main Gentoo tree. So
# add a check to locate the ELT-patches/ regardless of what's going on.
# Note: Duplicated in libtool.eclass.
_EUTILS_ECLASSDIR_LOCAL=${BASH_SOURCE[0]%/*}
eutils_elt_patch_dir() {
local d="${ECLASSDIR}/ELT-patches"
if [[ ! -d ${d} ]] ; then
d="${_EUTILS_ECLASSDIR_LOCAL}/ELT-patches"
fi
echo "${d}"
}

# @FUNCTION: epunt_cxx
# @USAGE: [dir to scan]
# @DESCRIPTION:
# Many configure scripts wrongly bail when a C++ compiler could not be
# detected. If dir is not specified, then it defaults to ${S}.
#
# https://bugs.gentoo.org/73450
epunt_cxx() {
local dir=$1
[[ -z ${dir} ]] && dir=${S}
ebegin "Removing useless C++ checks"
local f p any_found
while IFS= read -r -d '' f; do
for p in "$(eutils_elt_patch_dir)"/nocxx/*.patch ; do
if patch --no-backup-if-mismatch -p1 "${f}" "${p}" >/dev/null ; then
any_found=1
break
fi
done
done < <(find "${dir}" -name configure -print0)

if [[ -z ${any_found} ]]; then
eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt)."
fi
eend 0
}

_EPUNT_CXX_ECLASS=1
fi #_EPUNT_CXX_ECLASS
44 changes: 2 additions & 42 deletions eclass/eutils.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ _EUTILS_ECLASS=1
# implicitly inherited (now split) eclasses
case ${EAPI:-0} in
0|1|2|3|4|5|6)
inherit epatch estack ltprune multilib toolchain-funcs
# note: we want to remove epunt-cxx retroactively for #566424
inherit epatch epunt-cxx estack ltprune multilib toolchain-funcs
;;
esac

Expand Down Expand Up @@ -740,47 +741,6 @@ built_with_use() {
[[ ${opt} = "-a" ]]
}

# If an overlay has eclass overrides, but doesn't actually override the
# libtool.eclass, we'll have ECLASSDIR pointing to the active overlay's
# eclass/ dir, but libtool.eclass is still in the main Gentoo tree. So
# add a check to locate the ELT-patches/ regardless of what's going on.
# Note: Duplicated in libtool.eclass.
_EUTILS_ECLASSDIR_LOCAL=${BASH_SOURCE[0]%/*}
eutils_elt_patch_dir() {
local d="${ECLASSDIR}/ELT-patches"
if [[ ! -d ${d} ]] ; then
d="${_EUTILS_ECLASSDIR_LOCAL}/ELT-patches"
fi
echo "${d}"
}

# @FUNCTION: epunt_cxx
# @USAGE: [dir to scan]
# @DESCRIPTION:
# Many configure scripts wrongly bail when a C++ compiler could not be
# detected. If dir is not specified, then it defaults to ${S}.
#
# https://bugs.gentoo.org/73450
epunt_cxx() {
local dir=$1
[[ -z ${dir} ]] && dir=${S}
ebegin "Removing useless C++ checks"
local f p any_found
while IFS= read -r -d '' f; do
for p in "$(eutils_elt_patch_dir)"/nocxx/*.patch ; do
if patch --no-backup-if-mismatch -p1 "${f}" "${p}" >/dev/null ; then
any_found=1
break
fi
done
done < <(find "${dir}" -name configure -print0)

if [[ -z ${any_found} ]]; then
eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt)."
fi
eend 0
}

# @FUNCTION: make_wrapper
# @USAGE: <wrapper> <target> [chdir] [libpaths] [installpath]
# @DESCRIPTION:
Expand Down

0 comments on commit f1c4804

Please sign in to comment.