This is a feature request based on a bug I just discovered in an ebuild I'm writing. The ebuild is for a PHP application with an extensive test suite. I therefore have, RDEPEND="dev-lang/php[cli,xml,xmlreader]" DEPEND="test? ( ${RDEPEND} dev-php/phpunit )" DEPEND contains RDEPEND because, if the tests are to be run, I need to run the application (which needs its RDEPENDs). The problem is that I don't just need these USE flags for *some* dev-lang/php, I need them for *all* versions installed by PHP_TARGETS. Furthermore, at build time, the eselected version of cli php must have these USE flags set or else installation will fail. So, what we'd need is a way to set (R)DEPEND for each version of php mentioned in PHP_TARGETS. We should only set (R)DEPEND for the versions in PHP_TARGETS -- nothing more -- because that's what the user asked us to do. That still means that installation can fail if the user is running a version of php that isn't in PHP_TARGETS. But we know which USE flags are required; it should be possible to do an automatic check for their presence at build time using e.g. php-config. We could then die with a helpful error message if the running php is not in PHP_TARGETS and is missing some of the necessary build-time USE flags. The ruby language had a similar problem with its RUBY_TARGETS. I don't believe they do the running-interpreter check, but they do have two functions in an eclass that add {b,r}depends automatically based on the value of RUBY_TARGETS: 1. ruby_add_bdepend 2. ruby_add_rdepend Both can be found in ruby-ng.eclass. If PHP could copy this idea, it would at least prevent build failures for the users who aren't doing anything sneaky.
A quick followup after asking on #gentoo-ruby. The ruby-ng eclass doesn't have a special case for the eselected interpreter; instead, they run the tests with each version of interpreter in RUBY_TARGETS. This could work for PHP as well, as long as nobody requests two versions of PHP_TARGETS that are incompatible.
PHP_TARGETS is not used for php code, only for the C extensions. We do not support having multiple PHP versions installed with different USE flags since this is a very uncommon setup.
Ok, no problem. Thought I'd ask.