From ad824be8591dc1b0d31700b319914ed4cbe3744d Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Sun, 20 Mar 2016 23:39:55 +0100 Subject: [PATCH] Adds conditional compilations, depending on when the source was last modified --- compiler/compile.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/compiler/compile.go b/compiler/compile.go index dc4d737..3604562 100644 --- a/compiler/compile.go +++ b/compiler/compile.go @@ -19,6 +19,7 @@ import ( "path/filepath" log "github.com/Sirupsen/logrus" + "github.com/jjdekker/ponder/helpers" "github.com/jjdekker/ponder/settings" ) @@ -35,14 +36,18 @@ func CompileDir(path string, opts *settings.Settings) { PrepareLilypond(opts) for _, score := range scores { - // TODO: compile only if there are changes - msg, err := Lilypond(score.Path) - if err != nil { - log.WithFields(log.Fields{ - "message": msg, - "error": err, - "score": score, - }).Warning("score failed to compile") + output := outputPath(score.Path, opts) + + if !helpers.Exists(output) || + score.LastModified.After(helpers.LastModified(output)) { + msg, err := Lilypond(score.Path) + if err != nil { + log.WithFields(log.Fields{ + "message": msg, + "error": err, + "score": score, + }).Warning("score failed to compile") + } } } }