When decided what dependencies should be part of the build environment
(and have appropriate entries added to variables like PKG_CONFIG_PATH),
we select the entire dependency tree except for
(1) inactive optional and recommended deps (2) indirect build-time deps
(i.e., build-time deps of other deps)
There is a third category that sould be excluded: dependencies of direct
build-time deps. These are irrelevant to the build, and including them
can cause unexpected linkages.
When expanding dependencies, repeated deps are treated as equal and all
but the first are discarded when #uniq is called on the resulting array.
However, they may have different sets of options attached, so we cannot
assume they are the same.
After the initial expansion, we group them by name and then create a new
Dependency object for each name, merging the options from each group.
FixesHomebrew/homebrew#20335.