]> Cypherpunks.ru repositories - goredo.git/blobdiff - main.go
Fix JS deadlock and various optimizations
[goredo.git] / main.go
diff --git a/main.go b/main.go
index df9296f74b16875fb103947a3d5956cdebfec268..d0d3ab282cac7bb30cbff76d4ff222f7ce82486a 100644 (file)
--- a/main.go
+++ b/main.go
@@ -81,61 +81,12 @@ func mustParseFd(v, name string) *os.File {
        return fd
 }
 
-func ifchange(tgts []string) (bool, error) {
-       jsInit()
-       defer Jobs.Wait()
-       defer jsAcquire()
-       errs := make(chan error, len(tgts))
-       jobs := 0
-       ok := true
-       var err error
-       for _, tgt := range tgts {
-               var ood bool
-               if Force {
-                       ood = true
-               } else {
-                       ood, err = isOOD(Cwd, tgt, 0)
-                       if err != nil {
-                               return false, err
-                       }
-               }
-               if !ood {
-                       continue
-               }
-               if isSrc(Cwd, tgt) {
-                       trace(CDebug, "%s is source", tgt)
-                       continue
-               }
-               if err = runScript(tgt, errs); err != nil {
-                       return false, err
-               }
-               if Force {
-                       // Sequentially run jobs
-                       err = <-errs
-                       Jobs.Wait()
-                       if err != nil {
-                               trace(CErr, "%s", err)
-                               return false, nil
-                       }
-                       continue
-               }
-               jobs++
-       }
-       for i := 0; i < jobs; i++ {
-               if err = <-errs; err != nil {
-                       ok = false
-                       trace(CErr, "%s", err)
-               }
-       }
-       return ok, nil
-}
-
 func main() {
        xflag := flag.Bool("x", false, "trace current target (sh -x) (set REDO_TRACE=1 for others too)")
        stderrKeep := flag.Bool("stderr-keep", false, "keep job's stderr (REDO_STDERR_KEEP=1)")
        stderrSilent := flag.Bool("stderr-silent", false, "do not print job's stderr (REDO_STDERR_SILENT=1)")
        debug := flag.Bool("debug", false, "enable debug logging (REDO_DEBUG=1)")
-       logDone := flag.Bool("log-done", false, "enable done messages logging (REDO_LOG_DONE=1)")
+       logWait := flag.Bool("log-wait", false, "enable wait messages logging (REDO_LOG_WAIT=1)")
        logLock := flag.Bool("log-lock", false, "enable lock messages logging (REDO_LOG_LOCK=1)")
        logPid := flag.Bool("log-pid", false, "append PIDs (REDO_LOG_PID=1)")
        logJS := flag.Bool("log-js", false, "enable jobserver messages logging (REDO_LOG_JS=1)")
@@ -199,8 +150,8 @@ func main() {
        if *debug {
                mustSetenv("REDO_DEBUG", "1")
        }
-       if *logDone {
-               mustSetenv("REDO_LOG_DONE", "1")
+       if *logWait {
+               mustSetenv("REDO_LOG_WAIT", "1")
        }
        if *logLock {
                mustSetenv("REDO_LOG_LOCK", "1")
@@ -214,7 +165,7 @@ func main() {
        StderrKeep = os.Getenv("REDO_STDERR_KEEP") == "1"
        StderrSilent = os.Getenv("REDO_STDERR_SILENT") == "1"
        Debug = os.Getenv("REDO_DEBUG") == "1"
-       LogDone = os.Getenv("REDO_LOG_DONE") == "1"
+       LogWait = os.Getenv("REDO_LOG_WAIT") == "1"
        LogLock = os.Getenv("REDO_LOG_LOCK") == "1"
        LogJS = os.Getenv("REDO_LOG_JS") == "1"
        if Debug || os.Getenv("REDO_LOG_PID") == "1" {
@@ -347,7 +298,10 @@ CmdSwitch:
        if err != nil {
                log.Println(err)
        }
+       rc := 0
        if !ok || err != nil {
-               os.Exit(1)
+               rc = 1
        }
+       trace(CDebug, "[%s] finished: %s %s", BuildUUID, cmdName, tgts)
+       os.Exit(rc)
 }