Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH] epunt-cxx.eclass: Split C++ check punting code out of eutils
Date: Fri, 17 Mar 2017 16:58:26
Message-Id: 20170317165751.1149-1-mgorny@gentoo.org
1 Split the epunt_cxx (plus internal code) to a dedicated eclass. This is
2 rarely needed, usually indicates a dead upstream and requires
3 the ELT-patches framework. The patches are going to be split to
4 a separate package, and the new eclass will therefore need to DEPEND
5 on it. We do not want the dependency to apply to all eutils users
6 though.
7 ---
8 eclass/epunt-cxx.eclass | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
9 eclass/eutils.eclass | 44 ++-------------------------------
10 2 files changed, 67 insertions(+), 42 deletions(-)
11 create mode 100644 eclass/epunt-cxx.eclass
12
13 diff --git a/eclass/epunt-cxx.eclass b/eclass/epunt-cxx.eclass
14 new file mode 100644
15 index 000000000000..660b1d138fac
16 --- /dev/null
17 +++ b/eclass/epunt-cxx.eclass
18 @@ -0,0 +1,65 @@
19 +# Copyright 1999-2017 Gentoo Foundation
20 +# Distributed under the terms of the GNU General Public License v2
21 +
22 +# @ECLASS: epunt-cxx.eclass
23 +# @MAINTAINER:
24 +# base-system@g.o
25 +# @BLURB: A function to punt C++ compiler checks from autoconf
26 +# @DESCRIPTION:
27 +# Support for punting C++ compiler checks from autoconf (based
28 +# on ELT-patches).
29 +
30 +if [[ -z ${_EPUNT_CXX_ECLASS} ]]; then
31 +
32 +# TODO: replace this with 'inherit eutils' once eutils stops inheriting
33 +# us
34 +if ! declare -F eqawarn >/dev/null ; then
35 + eqawarn() {
36 + has qa ${PORTAGE_ELOG_CLASSES} && ewarn "$@"
37 + :
38 + }
39 +fi
40 +
41 +# If an overlay has eclass overrides, but doesn't actually override the
42 +# libtool.eclass, we'll have ECLASSDIR pointing to the active overlay's
43 +# eclass/ dir, but libtool.eclass is still in the main Gentoo tree. So
44 +# add a check to locate the ELT-patches/ regardless of what's going on.
45 +# Note: Duplicated in libtool.eclass.
46 +_EUTILS_ECLASSDIR_LOCAL=${BASH_SOURCE[0]%/*}
47 +eutils_elt_patch_dir() {
48 + local d="${ECLASSDIR}/ELT-patches"
49 + if [[ ! -d ${d} ]] ; then
50 + d="${_EUTILS_ECLASSDIR_LOCAL}/ELT-patches"
51 + fi
52 + echo "${d}"
53 +}
54 +
55 +# @FUNCTION: epunt_cxx
56 +# @USAGE: [dir to scan]
57 +# @DESCRIPTION:
58 +# Many configure scripts wrongly bail when a C++ compiler could not be
59 +# detected. If dir is not specified, then it defaults to ${S}.
60 +#
61 +# https://bugs.gentoo.org/73450
62 +epunt_cxx() {
63 + local dir=$1
64 + [[ -z ${dir} ]] && dir=${S}
65 + ebegin "Removing useless C++ checks"
66 + local f p any_found
67 + while IFS= read -r -d '' f; do
68 + for p in "$(eutils_elt_patch_dir)"/nocxx/*.patch ; do
69 + if patch --no-backup-if-mismatch -p1 "${f}" "${p}" >/dev/null ; then
70 + any_found=1
71 + break
72 + fi
73 + done
74 + done < <(find "${dir}" -name configure -print0)
75 +
76 + if [[ -z ${any_found} ]]; then
77 + eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt)."
78 + fi
79 + eend 0
80 +}
81 +
82 +_EPUNT_CXX_ECLASS=1
83 +fi #_EPUNT_CXX_ECLASS
84 diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
85 index c932d685c0e9..ea2a76200f09 100644
86 --- a/eclass/eutils.eclass
87 +++ b/eclass/eutils.eclass
88 @@ -20,7 +20,8 @@ _EUTILS_ECLASS=1
89 # implicitly inherited (now split) eclasses
90 case ${EAPI:-0} in
91 0|1|2|3|4|5|6)
92 - inherit epatch estack ltprune multilib toolchain-funcs
93 + # note: we want to remove epunt-cxx retroactively for #566424
94 + inherit epatch epunt-cxx estack ltprune multilib toolchain-funcs
95 ;;
96 esac
97
98 @@ -740,47 +741,6 @@ built_with_use() {
99 [[ ${opt} = "-a" ]]
100 }
101
102 -# If an overlay has eclass overrides, but doesn't actually override the
103 -# libtool.eclass, we'll have ECLASSDIR pointing to the active overlay's
104 -# eclass/ dir, but libtool.eclass is still in the main Gentoo tree. So
105 -# add a check to locate the ELT-patches/ regardless of what's going on.
106 -# Note: Duplicated in libtool.eclass.
107 -_EUTILS_ECLASSDIR_LOCAL=${BASH_SOURCE[0]%/*}
108 -eutils_elt_patch_dir() {
109 - local d="${ECLASSDIR}/ELT-patches"
110 - if [[ ! -d ${d} ]] ; then
111 - d="${_EUTILS_ECLASSDIR_LOCAL}/ELT-patches"
112 - fi
113 - echo "${d}"
114 -}
115 -
116 -# @FUNCTION: epunt_cxx
117 -# @USAGE: [dir to scan]
118 -# @DESCRIPTION:
119 -# Many configure scripts wrongly bail when a C++ compiler could not be
120 -# detected. If dir is not specified, then it defaults to ${S}.
121 -#
122 -# https://bugs.gentoo.org/73450
123 -epunt_cxx() {
124 - local dir=$1
125 - [[ -z ${dir} ]] && dir=${S}
126 - ebegin "Removing useless C++ checks"
127 - local f p any_found
128 - while IFS= read -r -d '' f; do
129 - for p in "$(eutils_elt_patch_dir)"/nocxx/*.patch ; do
130 - if patch --no-backup-if-mismatch -p1 "${f}" "${p}" >/dev/null ; then
131 - any_found=1
132 - break
133 - fi
134 - done
135 - done < <(find "${dir}" -name configure -print0)
136 -
137 - if [[ -z ${any_found} ]]; then
138 - eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt)."
139 - fi
140 - eend 0
141 -}
142 -
143 # @FUNCTION: make_wrapper
144 # @USAGE: <wrapper> <target> [chdir] [libpaths] [installpath]
145 # @DESCRIPTION:
146 --
147 2.12.0

Replies