-/*
-goredo -- djb's redo implementation on pure Go
-Copyright (C) 2020-2023 Sergey Matveev <stargrave@stargrave.org>
-
-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 <http://www.gnu.org/licenses/>.
-*/
+// goredo -- djb's redo implementation on pure Go
+// Copyright (C) 2020-2024 Sergey Matveev <stargrave@stargrave.org>
+//
+// 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 <http://www.gnu.org/licenses/>.
// Targets runner
if StopIfMod {
return fmt.Errorf("%s externally modified", tgt)
}
+ Jobs.Add(1)
tracef(CWarn, "%s externally modified: not redoing", tgt)
go func() {
errs <- nil
+ Jobs.Done()
}()
return nil
}
}
w := bufio.NewWriter(fdStderr)
- {
+ if !fdDepExists {
var ifchanges []string
ifchanges, err = depReadOnlyIfchanges(tgt.dep)
if err != nil {
line = scanner.Text()
if strings.HasPrefix(line, childStderrPrefix) {
line = line[len(childStderrPrefix):]
- LogMutex.Lock()
- os.Stderr.WriteString(StderrPrefix + line + "\n")
- LogMutex.Unlock()
+ if StderrPrefix == "" {
+ withPrependedTgt(line)
+ } else {
+ stderrWrite(StderrPrefix + line + "\n")
+ }
continue
}
if fdStderr != nil {
if StderrSilent {
continue
}
- if MyPid == 0 {
- tracef(CNone, "%s", line)
+ if MyPID != 0 {
+ line = pid + " " + line
+ }
+ if StderrPrefix == "" {
+ withPrependedTgt("[" + tgt.rel + "]" + line)
} else {
- tracef(CNone, "%s %s", pid, line)
+ stderrWrite(StderrPrefix + "[" + tgt.rel + "]" + line + "\n")
}
}
close(stderrTerm)