X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=targets.go;h=662612ea976b77f8418abc1d3c1fb4cb51ae541b;hb=3f8ee87bd625a38b57a0a38e3c34bb26fe6e1b8e;hp=6459a2db5529d9061ce393b044073f62e9c2ba71;hpb=4655c362aed45a161e0bac3a6987347bb35c3eaa;p=goredo.git diff --git a/targets.go b/targets.go index 6459a2d..662612e 100644 --- a/targets.go +++ b/targets.go @@ -25,7 +25,6 @@ import ( ) func targetsCollect(root string, tgts map[string]struct{}) error { - root = mustAbs(root) dir, err := os.Open(root) if err != nil { return ErrLine(err) @@ -72,9 +71,9 @@ func targetsCollect(root string, tgts map[string]struct{}) error { } func targetsWalker(tgts []string) ([]string, error) { - tgtsMap := map[string]struct{}{} + tgtsMap := make(map[string]struct{}) for _, tgt := range tgts { - if err := targetsCollect(tgt, tgtsMap); err != nil { + if err := targetsCollect(mustAbs(tgt), tgtsMap); err != nil { return nil, err } } @@ -86,12 +85,15 @@ func targetsWalker(tgts []string) ([]string, error) { } func collectWholeDeps( - tgts map[string]struct{}, - deps map[string]map[string]struct{}, - seen map[string]struct{}, + tgts map[string]*Tgt, + deps map[string]map[string]*Tgt, + seen map[string]*Tgt, ) { - for tgt := range tgts { - seen[tgt] = struct{}{} - collectWholeDeps(deps[tgt], deps, seen) + for _, tgt := range tgts { + if _, exists := seen[tgt.a]; exists { + continue + } + seen[tgt.a] = tgt + collectWholeDeps(deps[tgt.a], deps, seen) } }