Previously, when materilizing Go BUILD files, buildgen could err in two
1. Obsolete BUILD files were left behind.
2. If not all Go targets in the repo were included in the command line
remote libs with multiple packages might be trimmed to include too
few packages to support all the Go targets in the repo.
This change adds culling of unused local Go target BUILD files to
partially solve 1 and it forces a global scan of Go source roots when in
`--materialize` mode to solve 2.
Tests are updated to exercise the new global scanning in `--materialize`
mode and local unused BUILD culling.
contrib/go/src/python/pants/contrib/go/tasks/BUILD | 1 +
contrib/go/src/python/pants/contrib/go/tasks/go_buildgen.py | 126 +++++++++++++++++++++++++++++++++++++++++---------
contrib/go/tests/python/pants_test/contrib/go/tasks/test_go_buildgen.py | 90 +++++++++++++++++++++++-------------
3 files changed, 164 insertions(+), 53 deletions(-)
CI went green here:
I think this is a source root, not the build root.