Don't remove deps not in the manifest during recompaction

If you switch between different configurations, or entire manifests, but
keep the same .ninja_deps file, during recompaction all deps for nodes
not in the current manifest will be removed. This causes the affected
nodes in the build graph to be dirty during the next compilation.

In android, ninja is run three times for every build, each time running
with a superset of the previous manifest (each stage generates the next
stage, and optionally restarts the current stage). If recompaction
happens to run during one of the first two stages, nearly everything in
the third stage needs to be recompiled. Since the third stage is
significantly larger than the first two stages, and we check to see if
we need to recompact at startup, it's more likely for the first stage to
run recompaction.

So to fix this, make the deps log act like the build log -- keep any
entries that still exist on disk.

Test: m libc && .../ninja -f out/soong/.minibootstrap/build.ninja -t recompact && m libc
Change-Id: I3719c3992da9bd5e810ded3cf4ba55bf47d32160
5 files changed