Merge "Do not write build_error proto file if there are no build errors."
This commit is contained in:
commit
0835c1b27a
|
@ -20,6 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
|
@ -154,6 +155,7 @@ type errorProtoLog struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProtoErrorLog(log logger.Logger, filename string) StatusOutput {
|
func NewProtoErrorLog(log logger.Logger, filename string) StatusOutput {
|
||||||
|
os.Remove(filename)
|
||||||
return &errorProtoLog{
|
return &errorProtoLog{
|
||||||
errorProto: soong_build_error_proto.BuildError{},
|
errorProto: soong_build_error_proto.BuildError{},
|
||||||
filename: filename,
|
filename: filename,
|
||||||
|
@ -178,11 +180,17 @@ func (e *errorProtoLog) FinishAction(result ActionResult, counts Counts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *errorProtoLog) Flush() {
|
func (e *errorProtoLog) Flush() {
|
||||||
|
// Don't create the build error proto file if there is action errors.
|
||||||
|
if len(e.errorProto.ActionErrors) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
data, err := proto.Marshal(&e.errorProto)
|
data, err := proto.Marshal(&e.errorProto)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.log.Printf("Failed to marshal build status proto: %v\n", err)
|
e.log.Printf("Failed to marshal build status proto: %v\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(e.filename, []byte(data), 0644)
|
err = ioutil.WriteFile(e.filename, []byte(data), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.log.Printf("Failed to write file %s: %v\n", e.filename, err)
|
e.log.Printf("Failed to write file %s: %v\n", e.filename, err)
|
||||||
|
|
Loading…
Reference in New Issue