Gentoo Archives: gentoo-dev

From: Mike Frysinger <vapier@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] multiple inclusion protection with eclasses
Date: Thu, 08 Dec 2011 23:07:38
Message-Id: 201112081724.09591.vapier@gentoo.org
1 ferringb did some tests and found that doing multiple inclusion protection in
2 eclasses gets us some nice speed ups. it isn't nearly as nice as if we had a
3 way of skipping the `source` altogether, but that that would require PMS/tree
4 changes. the change i'm proposing can be implemented $now and should work
5 with all versions. PMS extensions can thus be discussed in parallel.
6
7 simply put, it's the same thing as doing standard #ifdef logic in headers to
8 protect against multiple inclusion errors. on to the example:
9
10 --- autotools.eclass
11 +++ autotools.eclass
12 @@ -10,6 +10,9 @@
13 # This eclass is for safely handling autotooled software packages that need
14 # regenerate their build scripts. All functions will abort in case of
15
16 +if [[ ${___ECLASS_ONCE_AUTOTOOLS} != "recur -_+^+_- spank" ]] ; then
17 +___ECLASS_ONCE_AUTOTOOLS="recur -_+^+_- spank"
18 +
19 inherit eutils libtool
20
21 # @ECLASS-VARIABLE: WANT_AUTOCONF
22 @@ -399,3 +402,5 @@
23
24 echo $include_opts
25 }
26 +
27 +fi
28
29 this assumes that the eclass in question isn't doing something weird. for
30 example, if you had an ebuild today that did:
31 inherit eutils
32 epatch() { die erp; }
33 inherit eutils
34
35 that local epatch() would get reset by the eutils inherit. but i can't see
36 any ebuild having a valid reason for doing things like this, so screw 'em.
37
38 i plan on implementing this in the eclasses i generally look over. i don't
39 plan on doing it for all eclasses since i'm not familiar with them.
40 -mike

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies