]> Cypherpunks.ru repositories - goredo.git/blobdiff - targets.go
Fix another whichdo regression fix
[goredo.git] / targets.go
index d7c4ebbc49b6a62a55650fbfe400db373301fa77..8e2668494dca9511b5b9745ba89cca235fbc9e47 100644 (file)
@@ -21,15 +21,10 @@ import (
        "io"
        "os"
        "path"
-       "path/filepath"
        "strings"
 )
 
 func targetsCollect(root string, tgts map[string]struct{}) error {
-       root, err := filepath.Abs(root)
-       if err != nil {
-               panic(err)
-       }
        dir, err := os.Open(root)
        if err != nil {
                return ErrLine(err)
@@ -76,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
                }
        }
@@ -90,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.rel]; exists {
+                       continue
+               }
+               seen[tgt.rel] = tgt
+               collectWholeDeps(deps[tgt.rel], deps, seen)
        }
 }