build: ignore non-explicit build-time dependencies

Given the following dependency tree:

  foo
    bar (bottled)
      baz (build-time only)

We skip installing baz because it is a build-time dependency of
something that is bottled. However, during the build of foo, this filter
is not applied because the dependent-dep relationship is not considered
at this stage. If baz wasn't installed prior to this build, fixopt(baz)
will fail.

Further, build-time deps are tightly coupled to the formula they are
specified by, and we shouldn't rely on them coming from dependencies
several levels down.

Fixes #17697.