package main
import (
- "os"
"path"
"strings"
)
level int,
deps map[string]map[string]struct{},
includeSrc bool,
+ seen map[string]struct{},
) []string {
cwd, tgt := cwdAndTgt(path.Join(cwd, tgtOrig))
- depPath := path.Join(cwd, RedoDir, tgt+DepSuffix)
- fdDep, err := os.Open(depPath)
- if err != nil {
+ tgtFull := path.Join(cwd, tgt)
+ if _, ok := seen[tgtFull]; ok {
return nil
}
- depInfo, err := depRead(fdDep)
- fdDep.Close()
+ depPath := path.Join(cwd, RedoDir, tgt+DepSuffix)
+ depInfo, err := depRead(depPath)
if err != nil {
return nil
}
+ // DepInfoCache[depPath] = depInfo
+ seen[tgtFull] = struct{}{}
var alwayses []string
returnReady := false
tgtRel := cwdMustRel(cwd, tgt)
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 {
m[tgtRel] = struct{}{}
deps[depRel] = m
}
- alwayses = append(
- alwayses,
- collectDeps(cwd, dep, level+1, deps, includeSrc)...,
- )
+ alwayses = append(alwayses,
+ collectDeps(cwd, dep.tgt, level+1, deps, includeSrc, seen)...)
}
}
return alwayses
tracef(CDebug, "collecting deps")
seen := map[string]struct{}{}
deps := map[string]map[string]struct{}{}
+ collectDepsSeen := make(map[string]struct{})
for _, tgtInitial := range tgts {
- for _, tgt := range collectDeps(Cwd, tgtInitial, 0, deps, false) {
+ for _, tgt := range collectDeps(Cwd, tgtInitial, 0, deps, false, collectDepsSeen) {
if tgt != tgtInitial {
seen[tgt] = struct{}{}
}
if len(seen) == 0 {
return seen
}
+ collectDepsSeen = nil
levelOrig := Level
defer func() {
if err != nil {
Jobs.Wait()
close(errs)
- return false, err
+ return false, ErrLine(err)
}
}
if !ood {
if err = runScript(tgt, errs, forced, traced); err != nil {
Jobs.Wait()
close(errs)
- return false, err
+ return false, ErrLine(err)
}
}
Jobs.Wait()