X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=ifchange.go;h=2108de291e022a61abdac05174d3436db99c6a87;hb=7450215ec9b548a3f883423da367cbeaa4186329;hp=d4588107b6fc3e4ae1b9ac02cf4102799d60bdcb;hpb=1acd70630cf8aabeed4f63cac167ca7dc7f274b3;p=goredo.git diff --git a/ifchange.go b/ifchange.go index d458810..2108de2 100644 --- a/ifchange.go +++ b/ifchange.go @@ -1,6 +1,6 @@ /* goredo -- redo implementation on pure Go -Copyright (C) 2020 Sergey Matveev +Copyright (C) 2020-2021 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 @@ -83,9 +83,11 @@ func buildDependants(tgts []string) map[string]struct{} { trace(CDebug, "collecting deps") seen := map[string]struct{}{} deps := map[string]map[string]struct{}{} - for _, tgt := range tgts { - for _, tgt := range collectDeps(Cwd, tgt, 0, deps) { - seen[tgt] = struct{}{} + for _, tgtInitial := range tgts { + for _, tgt := range collectDeps(Cwd, tgtInitial, 0, deps) { + if tgt != tgtInitial { + seen[tgt] = struct{}{} + } } } if len(seen) == 0 { @@ -99,7 +101,7 @@ func buildDependants(tgts []string) map[string]struct{} { Level = 1 trace(CDebug, "building %d alwayses: %v", len(seen), seen) errs := make(chan error, len(seen)) - for tgt, _ := range seen { + for tgt := range seen { if err := runScript(tgt, errs, false); err != nil { trace(CErr, "always run error: %s, skipping dependants", err) return nil @@ -112,12 +114,12 @@ func buildDependants(tgts []string) map[string]struct{} { Jobs.Wait() close(errs) if !ok { - trace(CDebug, "alwayses failed, skipping depdendants") + trace(CDebug, "alwayses failed, skipping dependants") return nil } queueSrc := make([]string, 0, len(seen)) - for tgt, _ := range seen { + for tgt := range seen { queueSrc = append(queueSrc, tgt) } if len(queueSrc) == 0 { @@ -128,7 +130,7 @@ RebuildDeps: trace(CDebug, "checking %d dependant targets: %v", len(queueSrc), queueSrc) queue := []string{} for _, tgt := range queueSrc { - for dep, _ := range deps[tgt] { + for dep := range deps[tgt] { queue = append(queue, dep) } } @@ -181,7 +183,7 @@ func ifchange(tgts []string, forced, traced bool) (bool, error) { var err error for _, tgt := range tgts { if _, ok := seen[tgt]; ok { - trace(CDebug, "%s was already build as a dependenant", tgt) + trace(CDebug, "%s was already build as a dependant", tgt) continue } ood = true