"io"
"os"
"path"
- "path/filepath"
"sort"
"strconv"
"strings"
}
func showBuildLogSub(sub *BuildLogJob, depth int) error {
- abs, err := filepath.Abs(path.Join(sub.dir, sub.tgt))
- if err != nil {
- return err
- }
+ abs := mustAbs(path.Join(sub.dir, sub.tgt))
if _, ok := buildLogSeen[abs]; ok {
return nil
}
"log"
"os"
"path"
- "path/filepath"
"strings"
)
}
func redoDirClean(root, what string) error {
- root, err := filepath.Abs(root)
- if err != nil {
- panic(err)
- }
+ root = mustAbs(root)
dir, err := os.Open(root)
if err != nil {
return ErrLine(err)
}
func cleanupWalker(root, what string) error {
- root, err := filepath.Abs(root)
- if err != nil {
- panic(err)
- }
+ root = mustAbs(root)
dir, err := os.Open(root)
if err != nil {
return ErrLine(err)
"io"
"os"
"path"
- "path/filepath"
"go.cypherpunks.ru/recfile"
"lukechampine.com/blake3"
tracef(CDebug, "no opened fdDep: %s", tgts)
return nil
}
+ var err error
for _, tgt := range tgts {
- tgtAbs, err := filepath.Abs(tgt)
- if err != nil {
- panic(err)
- }
+ tgtAbs := mustAbs(tgt)
cwd := Cwd
if DepCwd != "" && Cwd != DepCwd {
cwd = DepCwd
}
tgtDir := path.Join(cwd, DirPrefix)
- tgtRel, err := filepath.Rel(tgtDir, tgtAbs)
- if err != nil {
- panic(err)
- }
+ tgtRel := mustRel(tgtDir, tgtAbs)
if _, errStat := os.Stat(tgt); errStat == nil {
err = ErrLine(depWrite(fdDep, tgtDir, tgtRel, ""))
} else {
import (
"os"
"path"
- "path/filepath"
"strings"
)
}
}
levels = append(levels, "..")
- dirAbs, err := filepath.Abs(path.Join(cwd, updir))
+ dirAbs := mustAbs(path.Join(cwd, updir))
if err != nil {
panic(err)
}
if TopDir == "" {
TopDir = "/"
} else {
- TopDir, err = filepath.Abs(TopDir)
- if err != nil {
- panic(err)
- }
+ TopDir = mustAbs(TopDir)
}
DirPrefix = os.Getenv(EnvDirPrefix)
DepCwd = os.Getenv(EnvDepCwd)
p = append(p, "..")
}
p = append(p, doFile)
- rel, err := filepath.Rel(Cwd, path.Join(p...))
- if err != nil {
- panic(err)
- }
+ rel := mustRel(Cwd, path.Join(p...))
fmt.Println(rel)
}
case CmdNameRedoTargets:
"log"
"os"
"path"
- "path/filepath"
"strings"
"golang.org/x/sys/unix"
return fmt.Sprintf("%s: %s", e.Tgt, e.Err)
}
-func cwdMustRel(paths ...string) string {
- rel, err := filepath.Rel(Cwd, path.Join(paths...))
- if err != nil {
- panic(err)
- }
- return rel
-}
-
-func cwdAndTgt(tgt string) (string, string) {
- cwd, tgt := path.Split(tgt)
- cwd, err := filepath.Abs(cwd)
- if err != nil {
- panic(err)
- }
- return cwd, tgt
-}
-
func isSrc(cwd, tgt string) bool {
d, f := path.Split(path.Join(cwd, tgt))
if !FileExists(path.Join(d, f)) {
level int,
seen map[string]struct{},
) (bool, error) {
- p, err := filepath.Abs(path.Join(cwd, tgtOrig))
- if err != nil {
- panic(err)
- }
+ p := mustAbs(path.Join(cwd, tgtOrig))
_, ood := OODTgts[p]
+ var err error
if ood {
if !isOODByBuildUUID(cwd, tgtOrig) {
tracef(
--- /dev/null
+package main
+
+import (
+ "path"
+ "path/filepath"
+)
+
+func mustAbs(pth string) string {
+ pth, err := filepath.Abs(pth)
+ if err != nil {
+ panic(err)
+ }
+ return pth
+}
+
+func mustRel(basepath, targpath string) string {
+ pth, err := filepath.Rel(basepath, targpath)
+ if err != nil {
+ panic(err)
+ }
+ return pth
+}
+
+func cwdMustRel(paths ...string) string {
+ return mustRel(Cwd, path.Join(paths...))
+}
+
+func cwdAndTgt(tgt string) (string, string) {
+ cwd, tgt := path.Split(tgt)
+ return mustAbs(cwd), tgt
+}
"os"
"os/exec"
"path"
- "path/filepath"
"strconv"
"strings"
"sync"
stdoutPath := fdStdout.Name()
fdStdout.Close()
tmpPath := stdoutPath + ".3" // and for $3
- tmpPathRel, err := filepath.Rel(cwd, tmpPath)
- if err != nil {
- panic(err)
- }
+ tmpPathRel := mustRel(cwd, tmpPath)
args = append(
args,
path.Join(dirPrefix, tgt),
"log"
"os"
"path"
- "path/filepath"
)
func sourcesWalker(tgts []string) ([]string, error) {
seen := make(map[string]struct{}, 1<<10)
for _, tgt := range tgts {
- tgtAbsPath, err := filepath.Abs(path.Join(Cwd, tgt))
- if err != nil {
- panic(err)
- }
+ tgtAbsPath := mustAbs(path.Join(Cwd, tgt))
cwd, f := path.Split(path.Join(Cwd, tgt))
fdDep, err := os.Open(path.Join(cwd, RedoDir, f+DepSuffix))
if err != nil {
}
for _, m := range depInfo.ifchanges {
depTgt := m["Target"]
- depTgtAbsPath, err := filepath.Abs(path.Join(cwd, depTgt))
- if err != nil {
- panic(err)
- }
+ depTgtAbsPath := mustAbs(path.Join(cwd, depTgt))
if isSrc(cwd, depTgt) {
seen[cwdMustRel(depTgtAbsPath)] = struct{}{}
} else if depTgtAbsPath != tgtAbsPath {
"io"
"os"
"path"
- "path/filepath"
"strings"
)
func targetsCollect(root string, tgts map[string]struct{}) error {
- root, err := filepath.Abs(root)
- if err != nil {
- panic(err)
- }
+ root = mustAbs(root)
dir, err := os.Open(root)
if err != nil {
return ErrLine(err)