From 4cff07db2564cee8fad1145824e6aaf56bcc042b Mon Sep 17 00:00:00 2001 From: Usta Shrestha Date: Tue, 21 Feb 2023 23:06:40 -0500 Subject: [PATCH] cosmetic: readability Test: run `m nothing` Bug: NA Change-Id: Id58635cc949f07e5263ad67b0e78c66d19abba40 --- context.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/context.go b/context.go index d516b2f..ddaea4d 100644 --- a/context.go +++ b/context.go @@ -3757,32 +3757,30 @@ func (c *Context) AllTargets() (map[string]string, error) { } targets := map[string]string{} - - // Collect all the module build targets. - for _, module := range c.moduleInfo { - for _, buildDef := range module.actionDefs.buildDefs { + var collectTargets = func(actionDefs localBuildActions) error { + for _, buildDef := range actionDefs.buildDefs { ruleName := buildDef.Rule.fullName(c.pkgNames) for _, output := range append(buildDef.Outputs, buildDef.ImplicitOutputs...) { outputValue, err := output.Eval(c.globalVariables) if err != nil { - return nil, err + return err } targets[outputValue] = ruleName } } + return nil + } + // Collect all the module build targets. + for _, module := range c.moduleInfo { + if err := collectTargets(module.actionDefs); err != nil { + return nil, err + } } // Collect all the singleton build targets. for _, info := range c.singletonInfo { - for _, buildDef := range info.actionDefs.buildDefs { - ruleName := buildDef.Rule.fullName(c.pkgNames) - for _, output := range append(buildDef.Outputs, buildDef.ImplicitOutputs...) { - outputValue, err := output.Eval(c.globalVariables) - if err != nil { - return nil, err - } - targets[outputValue] = ruleName - } + if err := collectTargets(info.actionDefs); err != nil { + return nil, err } }