]> Cypherpunks.ru repositories - goredo.git/blobdiff - ifchange.go
Less unnecessary Close()s
[goredo.git] / ifchange.go
index 8a4677597aa2473f0716699565ef52e7dd6458ed..bfe65f1d6468c6e163825d29b7a866f4a68104d4 100644 (file)
@@ -18,7 +18,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 package main
 
 import (
-       "os"
        "path"
        "strings"
 )
@@ -36,15 +35,11 @@ func collectDeps(
                return nil
        }
        depPath := path.Join(cwd, RedoDir, tgt+DepSuffix)
-       fdDep, err := os.Open(depPath)
-       if err != nil {
-               return nil
-       }
-       depInfo, err := depRead(fdDep)
-       fdDep.Close()
+       depInfo, err := depRead(depPath)
        if err != nil {
                return nil
        }
+       // DepInfoCache[depPath] = depInfo
        seen[tgtFull] = struct{}{}
        var alwayses []string
        returnReady := false
@@ -62,19 +57,15 @@ func collectDeps(
                        returnReady = true
                }
        }
-       for _, m := range depInfo.ifchanges {
-               dep := m["Target"]
-               if dep == "" {
-                       return alwayses
-               }
-               if dep == tgt {
+       for _, dep := range depInfo.ifchanges {
+               if dep.tgt == tgt {
                        continue
                }
-               if !includeSrc && isSrc(cwd, dep) {
+               if !includeSrc && isSrc(cwd, dep.tgt) {
                        continue
                }
                if !returnReady {
-                       depRel := cwdMustRel(cwd, dep)
+                       depRel := cwdMustRel(cwd, dep.tgt)
                        if m, ok := deps[depRel]; ok {
                                m[tgtRel] = struct{}{}
                        } else {
@@ -83,7 +74,7 @@ func collectDeps(
                                deps[depRel] = m
                        }
                        alwayses = append(alwayses,
-                               collectDeps(cwd, dep, level+1, deps, includeSrc, seen)...)
+                               collectDeps(cwd, dep.tgt, level+1, deps, includeSrc, seen)...)
                }
        }
        return alwayses
@@ -242,7 +233,7 @@ func ifchange(tgts []string, forced, traced bool) (bool, error) {
                        if err != nil {
                                Jobs.Wait()
                                close(errs)
-                               return false, err
+                               return false, ErrLine(err)
                        }
                }
                if !ood {
@@ -255,7 +246,7 @@ func ifchange(tgts []string, forced, traced bool) (bool, error) {
                if err = runScript(tgt, errs, forced, traced); err != nil {
                        Jobs.Wait()
                        close(errs)
-                       return false, err
+                       return false, ErrLine(err)
                }
        }
        Jobs.Wait()