X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=ifchange.go;h=0f430fdebd76741065215382cb76ee406690e3fe;hb=ca5290c19761bc1806b98d54d966a9cbbfeabd15;hp=1f2c38194934da44475e97e039fb73601536a5a0;hpb=314f58ec690c7321535d6718e8d3a0ecb4cac019;p=goredo.git diff --git a/ifchange.go b/ifchange.go index 1f2c381..0f430fd 100644 --- a/ifchange.go +++ b/ifchange.go @@ -27,6 +27,7 @@ func collectDeps( cwd, tgtOrig string, level int, deps map[string]map[string]struct{}, + includeSrc bool, ) []string { cwd, tgt := cwdAndTgt(path.Join(cwd, tgtOrig)) depPath := path.Join(cwd, RedoDir, tgt+DepSuffix) @@ -60,7 +61,10 @@ func collectDeps( if dep == "" { return alwayses } - if dep == tgt || isSrc(cwd, dep) { + if dep == tgt { + continue + } + if !includeSrc && isSrc(cwd, dep) { continue } if !returnReady { @@ -68,11 +72,14 @@ func collectDeps( if m, ok := deps[depRel]; ok { m[tgtRel] = struct{}{} } else { - m = make(map[string]struct{}, 0) + m = map[string]struct{}{} m[tgtRel] = struct{}{} deps[depRel] = m } - alwayses = append(alwayses, collectDeps(cwd, dep, level+1, deps)...) + alwayses = append( + alwayses, + collectDeps(cwd, dep, level+1, deps, includeSrc)..., + ) } } return alwayses @@ -84,7 +91,7 @@ func buildDependants(tgts []string) map[string]struct{} { seen := map[string]struct{}{} deps := map[string]map[string]struct{}{} for _, tgtInitial := range tgts { - for _, tgt := range collectDeps(Cwd, tgtInitial, 0, deps) { + for _, tgt := range collectDeps(Cwd, tgtInitial, 0, deps, false) { if tgt != tgtInitial { seen[tgt] = struct{}{} }