/* goredo -- djb's redo implementation on pure Go Copyright (C) 2020-2023 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ package main import ( "errors" "io/fs" ) func sourcesWalker( tgts []*Tgt, seen map[string]struct{}, seenDeps map[string]struct{}, srcs map[string]*Tgt, ) error { for _, tgt := range tgts { if _, ok := seenDeps[tgt.rel]; ok { continue } seenDeps[tgt.rel] = struct{}{} depInfo, err := depRead(tgt) if err != nil { if errors.Is(err, fs.ErrNotExist) { continue } return ErrLine(err) } for _, dep := range depInfo.ifchanges { if _, ok := seen[dep.tgt.rel]; ok { continue } seen[dep.tgt.rel] = struct{}{} if isSrc(dep.tgt) { srcs[dep.tgt.rel] = dep.tgt } else if dep.tgt.rel != tgt.rel { if err := sourcesWalker( []*Tgt{dep.tgt}, seen, seenDeps, srcs, ); err != nil { return err } } } } return nil }