Compile command created in initial working state
This commit is contained in:
parent
89c30ca5eb
commit
9ad93eb620
@ -15,7 +15,6 @@
|
|||||||
package compiler
|
package compiler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@ -30,8 +29,16 @@ func CompileDir(path string, opts *settings.Settings) {
|
|||||||
scores, collector := generateScores()
|
scores, collector := generateScores()
|
||||||
filepath.Walk(path, compilePath(path, opts, collector))
|
filepath.Walk(path, compilePath(path, opts, collector))
|
||||||
|
|
||||||
|
PrepareLilypond(opts)
|
||||||
for _, score := range *scores {
|
for _, score := range *scores {
|
||||||
fmt.Println(score)
|
msg, err := Lilypond(score.Path)
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"message": msg,
|
||||||
|
"error": err,
|
||||||
|
"score": score,
|
||||||
|
}).Warning("score failed to compile")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/jjdekker/ponder/helpers"
|
"github.com/jjdekker/ponder/helpers"
|
||||||
"github.com/jjdekker/ponder/settings"
|
"github.com/jjdekker/ponder/settings"
|
||||||
)
|
)
|
||||||
@ -30,16 +31,18 @@ var (
|
|||||||
// PrepareLilypond sets all arguments and options for the Lilypond
|
// PrepareLilypond sets all arguments and options for the Lilypond
|
||||||
// compilation function using the given settings
|
// compilation function using the given settings
|
||||||
func PrepareLilypond(opts *settings.Settings) {
|
func PrepareLilypond(opts *settings.Settings) {
|
||||||
|
// TODO: Escape these directory strings
|
||||||
// Adds all includes to the lilypond arguments
|
// Adds all includes to the lilypond arguments
|
||||||
for _, dir := range opts.LilypondIncludes {
|
for _, dir := range opts.LilypondIncludes {
|
||||||
lilypondArgs = append(lilypondArgs, "--include=\""+dir+"\"")
|
lilypondArgs = append(lilypondArgs, "--include="+dir)
|
||||||
}
|
}
|
||||||
lilypondArgs = append(lilypondArgs, "--loglevel=ERROR")
|
lilypondArgs = append(lilypondArgs, "--loglevel=ERROR")
|
||||||
lilypondArgs = append(lilypondArgs, "--pdf")
|
lilypondArgs = append(lilypondArgs, "--pdf")
|
||||||
|
|
||||||
// TODO: Make this an absolute path.
|
// TODO: Make this an absolute path.
|
||||||
lilypondArgs = append(lilypondArgs, "--output=\""+opts.OutputDir+"\"")
|
lilypondArgs = append(lilypondArgs, "--output="+opts.OutputDir)
|
||||||
if !helpers.Exists(opts.OutputDir) {
|
if !helpers.Exists(opts.OutputDir) {
|
||||||
|
log.WithFields(log.Fields{"path": opts.OutputDir}).Info("creating output directory")
|
||||||
err := os.MkdirAll(opts.OutputDir, os.ModePerm)
|
err := os.MkdirAll(opts.OutputDir, os.ModePerm)
|
||||||
helpers.Check(err, "Could not create output directory")
|
helpers.Check(err, "Could not create output directory")
|
||||||
}
|
}
|
||||||
@ -49,6 +52,10 @@ func PrepareLilypond(opts *settings.Settings) {
|
|||||||
// using the arguments prepared by the PrepareLilypond function
|
// using the arguments prepared by the PrepareLilypond function
|
||||||
func Lilypond(path string) (string, error) {
|
func Lilypond(path string) (string, error) {
|
||||||
cmd := exec.Command(lilypondCmd, append(lilypondArgs, path)...)
|
cmd := exec.Command(lilypondCmd, append(lilypondArgs, path)...)
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"path": path,
|
||||||
|
"cmd": cmd,
|
||||||
|
}).Info("compiling file using lilypond")
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
return string(out), err
|
return string(out), err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user