Include label in aquery error

When an Action fails to convert to a Ninja build statement,
include the bazel label in the error message.

Test: NA
Bug: 301638491
Change-Id: I592978c5e530043769b0232fdd200ad13b72c39b
This commit is contained in:
usta
2023-09-22 17:29:56 -04:00
parent eba2a2af22
commit a79afd7efa

View File

@@ -18,14 +18,16 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"path/filepath" "path/filepath"
analysis_v2_proto "prebuilts/bazel/common/proto/analysis_v2"
"reflect" "reflect"
"sort" "sort"
"strings" "strings"
"sync" "sync"
analysis_v2_proto "prebuilts/bazel/common/proto/analysis_v2"
"github.com/google/blueprint/metrics" "github.com/google/blueprint/metrics"
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
@@ -374,9 +376,14 @@ func AqueryBuildStatements(aqueryJsonProto []byte, eventHandler *metrics.EventHa
for i, actionEntry := range aqueryProto.Actions { for i, actionEntry := range aqueryProto.Actions {
wg.Add(1) wg.Add(1)
go func(i int, actionEntry *analysis_v2_proto.Action) { go func(i int, actionEntry *analysis_v2_proto.Action) {
buildStatement, aErr := aqueryHandler.actionToBuildStatement(actionEntry) if buildStatement, aErr := aqueryHandler.actionToBuildStatement(actionEntry); aErr != nil {
if aErr != nil {
errOnce.Do(func() { errOnce.Do(func() {
for _, t := range aqueryProto.Targets {
if t.GetId() == actionEntry.GetTargetId() {
aErr = fmt.Errorf("%s: [%s] [%s]", aErr.Error(), actionEntry.GetMnemonic(), t.GetLabel())
break
}
}
err = aErr err = aErr
}) })
} else { } else {
@@ -782,7 +789,7 @@ func (a *aqueryArtifactHandler) actionToBuildStatement(actionEntry *analysis_v2_
} }
if len(actionEntry.Arguments) < 1 { if len(actionEntry.Arguments) < 1 {
return nil, fmt.Errorf("received action with no command: [%s]", actionEntry.Mnemonic) return nil, errors.New("received action with no command")
} }
return a.normalActionBuildStatement(actionEntry) return a.normalActionBuildStatement(actionEntry)