X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=ifchange.go;h=5c294013f7bf270e7dc89a5c50db0586e3213492;hb=a9455044065855ae42d95d939ed0027f7a895b83;hp=0cb50c51d0785bef62596e28669936be3f28fff6;hpb=0cadba691640011e1b17d950aabc6c9b64dd631f;p=goredo.git diff --git a/ifchange.go b/ifchange.go index 0cb50c5..5c29401 100644 --- a/ifchange.go +++ b/ifchange.go @@ -1,19 +1,17 @@ -/* -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 . -*/ +// goredo -- djb's redo implementation on pure Go +// Copyright (C) 2020-2024 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 @@ -26,25 +24,21 @@ func collectDeps( level int, deps map[string]map[string]*Tgt, includeSrc bool, - seen map[string]struct{}, ) []*Tgt { - if _, ok := seen[tgt.a]; ok { + if _, ok := DepCache[tgt.rel]; ok { return nil } dep, err := depRead(tgt) if err != nil { return nil } - DepInfoCache[tgt.Dep()] = depInfo - seen[tgt.a] = struct{}{} + DepCache[tgt.rel] = dep var alwayses []*Tgt returnReady := false if dep.always { if dep.build == BuildUUID { - tracef( - CDebug, "ood: %s%s always, but already build", - strings.Repeat(". ", level), tgt, - ) + tracef(CDebug, "ood: %s%s always, but already build", + strings.Repeat(". ", level), tgt) returnReady = true } else { tracef(CDebug, "ood: %s%s always", strings.Repeat(". ", level), tgt) @@ -66,7 +60,7 @@ func collectDeps( deps[ifchange.tgt.rel] = map[string]*Tgt{tgt.rel: tgt} } alwayses = append(alwayses, - collectDeps(dep.tgt, level+1, deps, includeSrc, seen)...) + collectDeps(ifchange.tgt, level+1, deps, includeSrc)...) } } return alwayses @@ -77,20 +71,15 @@ func buildDependants(tgts []*Tgt) map[string]*Tgt { tracef(CDebug, "collecting deps") seen := make(map[string]*Tgt) deps := make(map[string]map[string]*Tgt) - { - collectDepsSeen := make(map[string]struct{}) - for _, tgtInitial := range tgts { - for _, tgt := range collectDeps(tgtInitial, 0, deps, false, collectDepsSeen) { - if tgt.a != tgtInitial.a { - seen[tgt.a] = tgt - } + for _, tgtInitial := range tgts { + for _, tgt := range collectDeps(tgtInitial, 0, deps, false) { + if tgt.rel != tgtInitial.rel { + seen[tgt.rel] = tgt } } - InodeCache = make(map[string][]*Inode) } - TgtCache = nil - HashCache = nil - InodeCache = nil + TgtCache = make(map[string]*Tgt) + IfchangeCache = nil if len(seen) == 0 { return seen }