// DiffGraphs calculates the differences between two graphs. func DiffGraphs(before, after *query.JSONGraph, changedFiles, include, exclude []string, recurse bool) []core.BuildLabel { changedFileMap := toMap(changedFiles) allChanges := map[string]bool{} for pkgName, afterPkg := range after.Packages { beforePkg, present := before.Packages[pkgName] if !present { // Package didn't exist before, add every target in it. for targetName := range afterPkg.Targets { label := core.BuildLabel{PackageName: pkgName, Name: targetName} allChanges[label.String()] = true } continue } for targetName, afterTarget := range afterPkg.Targets { beforeTarget := beforePkg.Targets[targetName] if targetChanged(&beforeTarget, &afterTarget, pkgName, changedFileMap) { label := core.BuildLabel{PackageName: pkgName, Name: targetName} allChanges[label.String()] = true } } } // Now we have all the targets that are directly changed, we locate all transitive ones // in a second pass. We can't do this above because we've got no sensible ordering for it. ret := core.BuildLabels{} for pkgName, pkg := range after.Packages { for targetName, target := range pkg.Targets { if depsChanged(after, allChanges, pkgName, targetName, recurse) && shouldInclude(&target, include, exclude) { ret = append(ret, core.BuildLabel{PackageName: pkgName, Name: targetName}) } } } sort.Sort(ret) return ret }
func updateTarget(state *core.BuildState, plainOutput bool, buildingTarget *buildingTarget, label core.BuildLabel, active bool, failed bool, cached bool, description string, err error, colour string) { updateTarget2(buildingTarget, label, active, failed, cached, description, err, colour) if plainOutput { if failed { log.Errorf("%s: %s", label.String(), description) } else { if !active { active := pluralise(state.NumActive(), "task", "tasks") log.Notice("[%d/%s] %s: %s [%3.1fs]", state.NumDone(), active, label.String(), description, time.Now().Sub(buildingTarget.Started).Seconds()) } else { log.Info("%s: %s", label.String(), description) } } } }