Display diagnostic message for each conversion error.
Also, use better names for the error handling entities. Bug: 204062171 Test: manual Change-Id: I65869120ed08fc40d9ec6267c882e53aaedde9ed
This commit is contained in:
@@ -81,7 +81,7 @@ func init() {
|
||||
|
||||
var backupSuffix string
|
||||
var tracedVariables []string
|
||||
var errorLogger = errorsByType{data: make(map[string]datum)}
|
||||
var errorLogger = errorSink{data: make(map[string]datum)}
|
||||
var makefileFinder = &LinuxMakefileFinder{}
|
||||
var versionDefaultsMk = filepath.Join("build", "make", "core", "version_defaults.mk")
|
||||
|
||||
@@ -339,9 +339,7 @@ func convertOne(mkFile string) (ok bool) {
|
||||
WarnPartialSuccess: !*noWarn,
|
||||
SourceFS: os.DirFS(*rootDir),
|
||||
MakefileFinder: makefileFinder,
|
||||
}
|
||||
if *errstat {
|
||||
mk2starRequest.ErrorLogger = errorLogger
|
||||
ErrorLogger: errorLogger,
|
||||
}
|
||||
ss, err := mk2rbc.Convert(mk2starRequest)
|
||||
if err != nil {
|
||||
@@ -456,10 +454,8 @@ func printStats() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if *verbose {
|
||||
fmt.Fprintf(os.Stderr, "%-16s%5d\n", "Succeeded:", nOk)
|
||||
fmt.Fprintf(os.Stderr, "%-16s%5d\n", "Partial:", nPartial)
|
||||
fmt.Fprintf(os.Stderr, "%-16s%5d\n", "Failed:", nFailed)
|
||||
if *verbose && (nPartial > 0 || nFailed > 0) {
|
||||
fmt.Fprintln(os.Stderr, "Succeeded: ", nOk, " Partial: ", nPartial, " Failed: ", nFailed)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,11 +464,18 @@ type datum struct {
|
||||
formattingArgs []string
|
||||
}
|
||||
|
||||
type errorsByType struct {
|
||||
type errorSink struct {
|
||||
data map[string]datum
|
||||
}
|
||||
|
||||
func (ebt errorsByType) NewError(message string, node parser.Node, args ...interface{}) {
|
||||
func (ebt errorSink) NewError(sourceFile string, sourceLine int, node parser.Node, message string, args ...interface{}) {
|
||||
fmt.Fprintf(os.Stderr, "%s:%d ", sourceFile, sourceLine)
|
||||
fmt.Fprintf(os.Stderr, message, args...)
|
||||
fmt.Fprintln(os.Stderr)
|
||||
if !*errstat {
|
||||
return
|
||||
}
|
||||
|
||||
v, exists := ebt.data[message]
|
||||
if exists {
|
||||
v.count++
|
||||
@@ -497,7 +500,7 @@ func (ebt errorsByType) NewError(message string, node parser.Node, args ...inter
|
||||
ebt.data[message] = v
|
||||
}
|
||||
|
||||
func (ebt errorsByType) printStatistics() {
|
||||
func (ebt errorSink) printStatistics() {
|
||||
if len(ebt.data) > 0 {
|
||||
fmt.Fprintln(os.Stderr, "Error counts:")
|
||||
}
|
||||
|
Reference in New Issue
Block a user