Loading genrule/genrule.go +16 −11 Original line number Diff line number Diff line Loading @@ -223,13 +223,18 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) { task := g.taskGenerator(ctx, String(g.properties.Cmd), srcFiles) 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 { case "location": 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") } if len(g.properties.Tools) > 0 { return reportError("at least one `tools` or `tool_files` is required if $(location) is used") } else if len(g.properties.Tools) > 0 { return tools[g.properties.Tools[0]].String(), nil } else { return tools[toolFiles[0].Rel()].String(), nil Loading @@ -241,7 +246,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) { case "depfile": referencedDepfile = true if !Bool(g.properties.Depfile) { return "", fmt.Errorf("$(depfile) used without depfile property") return reportError("$(depfile) used without depfile property") } return "__SBOX_DEPFILE__", nil case "genDir": Loading @@ -252,22 +257,22 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) { if tool, ok := tools[label]; ok { return tool.String(), nil } 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 { ctx.PropertyErrorf("cmd", "%s", err.Error()) 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 buildDir := android.PathForOutput(ctx).String() sandboxPath := shared.TempDirForOutDir(buildDir) Loading Loading
genrule/genrule.go +16 −11 Original line number Diff line number Diff line Loading @@ -223,13 +223,18 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) { task := g.taskGenerator(ctx, String(g.properties.Cmd), srcFiles) 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 { case "location": 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") } if len(g.properties.Tools) > 0 { return reportError("at least one `tools` or `tool_files` is required if $(location) is used") } else if len(g.properties.Tools) > 0 { return tools[g.properties.Tools[0]].String(), nil } else { return tools[toolFiles[0].Rel()].String(), nil Loading @@ -241,7 +246,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) { case "depfile": referencedDepfile = true if !Bool(g.properties.Depfile) { return "", fmt.Errorf("$(depfile) used without depfile property") return reportError("$(depfile) used without depfile property") } return "__SBOX_DEPFILE__", nil case "genDir": Loading @@ -252,22 +257,22 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) { if tool, ok := tools[label]; ok { return tool.String(), nil } 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 { ctx.PropertyErrorf("cmd", "%s", err.Error()) 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 buildDir := android.PathForOutput(ctx).String() sandboxPath := shared.TempDirForOutDir(buildDir) Loading