-/*
-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/>.
// Out-of-date determination
package main
import (
+ "bytes"
"errors"
"fmt"
"io"
)
const (
- DepTypeIfcreate = "ifcreate"
- DepTypeIfchange = "ifchange"
- DepTypeAlways = "always"
- DepTypeStamp = "stamp"
-
EnvOODTgtsFd = "REDO_OOD_TGTS_FD"
EnvOODTgtsLockFd = "REDO_OOD_TGTS_LOCK_FD"
)
OODCache = make(map[string]bool)
FileExistsCache = make(map[string]bool)
- DepInfoCache = make(map[string]*DepInfo)
-
- ErrMissingTarget = errors.New("invalid format of .rec: missing Target")
)
func FileExists(p string) bool {
if FileExists(tgt.a + ".do") {
return false
}
- if FileExists(tgt.Dep()) {
+ if FileExists(tgt.dep) {
return false
}
return true
}
func isOODByBuildUUID(tgt *Tgt) bool {
- build, err := depReadBuild(tgt.Dep())
+ build, err := depBuildRead(tgt.dep)
return err != nil || build != BuildUUID
}
tracef(CDebug, "ood: %s%s -> is source", indent, tgt)
} else {
ood = true
- tracef(CDebug, "ood: %s%s -> no dep: %s", indent, tgt, tgt.Dep())
+ tracef(CDebug, "ood: %s%s -> no dep: %s", indent, tgt, tgt.dep)
}
OODCache[tgt.rel] = ood
return ood, nil
return ood, TgtError{tgt, ErrLine(err)}
}
- if inode.Size != dep.inode.Size {
+ if !bytes.Equal(inode[:8], ifchange.Inode()[:8]) {
tracef(CDebug, "ood: %s%s -> %s: size differs", indent, tgt, ifchange.tgt)
ood = true
- OODCache[dep.tgt.rel] = ood
+ OODCache[ifchange.tgt.rel] = ood
goto Done
}
- if InodeTrust != InodeTrustNone && inode.Equals(dep.inode) {
+ if InodeTrust != InodeTrustNone && inode.Equals(ifchange.Inode()) {
tracef(CDebug, "ood: %s%s -> %s: same inode", indent, tgt, ifchange.tgt)
} else {
tracef(CDebug, "ood: %s%s -> %s: inode differs", indent, tgt, ifchange.tgt)
if err != nil {
return ood, TgtError{tgt, ErrLine(err)}
}
- if dep.hash != hsh {
+ if ifchange.Hash() != hsh {
tracef(CDebug, "ood: %s%s -> %s: hash differs", indent, tgt, ifchange.tgt)
ood = true
OODCache[ifchange.tgt.rel] = ood