import (
"errors"
"io/fs"
- "path"
)
func sourcesWalker(
- tgts []string,
+ tgts []*Tgt,
seen map[string]struct{},
seenDeps map[string]struct{},
- srcs map[string]struct{},
+ srcs map[string]*Tgt,
) error {
for _, tgt := range tgts {
- tgtAbsPath := mustAbs(path.Join(Cwd, tgt))
- cwd, f := path.Split(path.Join(Cwd, tgt))
- depPath := path.Join(cwd, RedoDir, f+DepSuffix)
- if _, ok := seenDeps[depPath]; ok {
+ if _, ok := seenDeps[tgt.rel]; ok {
continue
}
- seenDeps[depPath] = struct{}{}
- depInfo, err := depRead(depPath)
+ seenDeps[tgt.rel] = struct{}{}
+ dep, err := depRead(tgt)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
continue
}
return ErrLine(err)
}
- for _, dep := range depInfo.ifchanges {
- depTgtAbsPath := mustAbs(path.Join(cwd, dep.tgt))
- if _, ok := seen[depTgtAbsPath]; ok {
+ for _, ifchange := range dep.ifchanges {
+ if _, ok := seen[ifchange.tgt.rel]; ok {
continue
}
- seen[depTgtAbsPath] = struct{}{}
- if isSrc(cwd, dep.tgt) {
- srcs[cwdMustRel(depTgtAbsPath)] = struct{}{}
- } else if depTgtAbsPath != tgtAbsPath {
+ seen[ifchange.tgt.rel] = struct{}{}
+ if isSrc(ifchange.tgt) {
+ srcs[ifchange.tgt.rel] = ifchange.tgt
+ } else if ifchange.tgt.rel != tgt.rel {
if err := sourcesWalker(
- []string{cwdMustRel(depTgtAbsPath)},
+ []*Tgt{ifchange.tgt},
seen, seenDeps, srcs,
); err != nil {
return err