Merge "Fix error reporting when parsing genrule cmd"
This commit is contained in:
@@ -223,13 +223,18 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
task := g.taskGenerator(ctx, String(g.properties.Cmd), srcFiles)
|
task := g.taskGenerator(ctx, String(g.properties.Cmd), srcFiles)
|
||||||
|
|
||||||
rawCommand, err := android.Expand(task.cmd, func(name string) (string, error) {
|
rawCommand, err := android.Expand(task.cmd, func(name string) (string, error) {
|
||||||
|
// report the error directly without returning an error to android.Expand to catch multiple errors in a
|
||||||
|
// single run
|
||||||
|
reportError := func(fmt string, args ...interface{}) (string, error) {
|
||||||
|
ctx.PropertyErrorf("cmd", fmt, args...)
|
||||||
|
return "SOONG_ERROR", nil
|
||||||
|
}
|
||||||
|
|
||||||
switch name {
|
switch name {
|
||||||
case "location":
|
case "location":
|
||||||
if len(g.properties.Tools) == 0 && len(toolFiles) == 0 {
|
if len(g.properties.Tools) == 0 && len(toolFiles) == 0 {
|
||||||
return "", fmt.Errorf("at least one `tools` or `tool_files` is required if $(location) is used")
|
return reportError("at least one `tools` or `tool_files` is required if $(location) is used")
|
||||||
}
|
} else if len(g.properties.Tools) > 0 {
|
||||||
|
|
||||||
if len(g.properties.Tools) > 0 {
|
|
||||||
return tools[g.properties.Tools[0]].String(), nil
|
return tools[g.properties.Tools[0]].String(), nil
|
||||||
} else {
|
} else {
|
||||||
return tools[toolFiles[0].Rel()].String(), nil
|
return tools[toolFiles[0].Rel()].String(), nil
|
||||||
@@ -241,7 +246,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
case "depfile":
|
case "depfile":
|
||||||
referencedDepfile = true
|
referencedDepfile = true
|
||||||
if !Bool(g.properties.Depfile) {
|
if !Bool(g.properties.Depfile) {
|
||||||
return "", fmt.Errorf("$(depfile) used without depfile property")
|
return reportError("$(depfile) used without depfile property")
|
||||||
}
|
}
|
||||||
return "__SBOX_DEPFILE__", nil
|
return "__SBOX_DEPFILE__", nil
|
||||||
case "genDir":
|
case "genDir":
|
||||||
@@ -252,22 +257,22 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
if tool, ok := tools[label]; ok {
|
if tool, ok := tools[label]; ok {
|
||||||
return tool.String(), nil
|
return tool.String(), nil
|
||||||
} else {
|
} else {
|
||||||
return "", fmt.Errorf("unknown location label %q", label)
|
return reportError("unknown location label %q", label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("unknown variable '$(%s)'", name)
|
return reportError("unknown variable '$(%s)'", name)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if Bool(g.properties.Depfile) && !referencedDepfile {
|
|
||||||
ctx.PropertyErrorf("cmd", "specified depfile=true but did not include a reference to '${depfile}' in cmd")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.PropertyErrorf("cmd", "%s", err.Error())
|
ctx.PropertyErrorf("cmd", "%s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Bool(g.properties.Depfile) && !referencedDepfile {
|
||||||
|
ctx.PropertyErrorf("cmd", "specified depfile=true but did not include a reference to '${depfile}' in cmd")
|
||||||
|
}
|
||||||
|
|
||||||
// tell the sbox command which directory to use as its sandbox root
|
// tell the sbox command which directory to use as its sandbox root
|
||||||
buildDir := android.PathForOutput(ctx).String()
|
buildDir := android.PathForOutput(ctx).String()
|
||||||
sandboxPath := shared.TempDirForOutDir(buildDir)
|
sandboxPath := shared.TempDirForOutDir(buildDir)
|
||||||
|
Reference in New Issue
Block a user