]> Cypherpunks.ru repositories - goredo.git/blobdiff - ood.go
Unify copyright comment format
[goredo.git] / ood.go
diff --git a/ood.go b/ood.go
index c11b23f5995ab89ef95089477828429e5df00cc0..120a7de8afd554d95cb8397c01182a4db6eac99e 100644 (file)
--- a/ood.go
+++ b/ood.go
@@ -1,25 +1,24 @@
-/*
-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"
@@ -32,11 +31,6 @@ import (
 )
 
 const (
-       DepTypeIfcreate = "ifcreate"
-       DepTypeIfchange = "ifchange"
-       DepTypeAlways   = "always"
-       DepTypeStamp    = "stamp"
-
        EnvOODTgtsFd     = "REDO_OOD_TGTS_FD"
        EnvOODTgtsLockFd = "REDO_OOD_TGTS_LOCK_FD"
 )
@@ -48,9 +42,6 @@ var (
 
        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 {
@@ -86,14 +77,14 @@ func isSrc(tgt *Tgt) 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
 }
 
@@ -116,7 +107,7 @@ func isOOD(tgt *Tgt, level int, seen map[string]*Tgt) (bool, error) {
                                        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
@@ -169,13 +160,13 @@ func isOOD(tgt *Tgt, level int, seen map[string]*Tgt) (bool, error) {
                        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)
@@ -188,7 +179,7 @@ func isOOD(tgt *Tgt, level int, seen map[string]*Tgt) (bool, error) {
                        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