Improve mixed builds error messages

When a target does not have a certain provider we need,
currently we just fail at the dictionary lookup. Change
it so that we fail with a message that tells us what
target had the issue.

Bug: 260131489
Test: Presubmits
Change-Id: I99fd018835c14eba0d4db54ba2769b2da1b278f6
This commit is contained in:
Cole Faust
2022-11-22 14:08:59 -08:00
parent 2f213d0946
commit 97d1527dd2
2 changed files with 23 additions and 18 deletions

View File

@@ -81,7 +81,7 @@ type cqueryRequest interface {
// all request-relevant information about a target and returns a string containing
// this information.
// The function should have the following properties:
// - `target` is the only parameter to this function (a configured target).
// - The arguments are `target` (a configured target) and `id_string` (the label + configuration).
// - The return value must be a string.
// - The function body should not be indented outside of its own scope.
StarlarkFunctionBody() string
@@ -743,12 +743,12 @@ func (context *bazelContext) cqueryStarlarkFileContents() []byte {
}
`
functionDefFormatString := `
def %s(target):
def %s(target, id_string):
%s
`
mainSwitchSectionFormatString := `
if id_string in %s:
return id_string + ">>" + %s(target)
return id_string + ">>" + %s(target, id_string)
`
for requestType := range requestTypeToCqueryIdEntries {