Skip to content

Commit

Permalink
Fixed up a few things with reader refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
trhodeos committed Mar 22, 2018
1 parent 2c97915 commit 9e3e113
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
8 changes: 3 additions & 5 deletions cmd/spicy/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
flag "github.com/ogier/pflag"
log "github.com/sirupsen/logrus"
"github.com/trhodeos/n64rom"
Expand Down Expand Up @@ -95,6 +94,8 @@ func main() {
if err != nil {
panic(err)
}
defer f.Close()

gcc := spicy.NewRunner(*cpp_command)
ld := spicy.NewRunner(*ld_command)
as := spicy.NewRunner(*as_command)
Expand All @@ -106,9 +107,6 @@ func main() {
}

for _, w := range spec.Waves {
if err != nil {
panic(err)
}
entry, err := spicy.CreateEntryBinary(w, as)
if err != nil {
panic(err)
Expand All @@ -122,7 +120,7 @@ func main() {
panic(err)
}

out, err := os.Create(fmt.Sprintf("%s.n64", *rom_image_file))
out, err := os.Create(*rom_image_file)
if err != nil {
panic(err)
}
Expand Down
5 changes: 3 additions & 2 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (e ExecRunner) Run(r io.Reader, args []string) (io.Reader, error) {
cmd := exec.Command(e.command, args...)
var out bytes.Buffer
var errout bytes.Buffer
cmd.Stdin = r
cmd.Stdout = &out
cmd.Stderr = &errout
err := cmd.Run()
Expand Down Expand Up @@ -76,7 +77,7 @@ func writeTempFile(r io.Reader, prefix string) (string, error) {
if err != nil {
return "", err
}
log.Debugln("Writing file for prefix %s to %s", prefix, path)
log.Debugf("Writing file for prefix %s to %s", prefix, path)
_, err = io.Copy(tmpfile, r)
if err != nil {
return "", err
Expand All @@ -100,7 +101,7 @@ func (e MappedFileRunner) Run(r io.Reader, args []string) (io.Reader, error) {
newArgs[i] = args[i]
}
}
_, err := e.runner.Run(r, args)
_, err := e.runner.Run(r, newArgs)
if err != nil {
return nil, err
}
Expand Down
8 changes: 7 additions & 1 deletion spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"github.com/alecthomas/participle"
log "github.com/sirupsen/logrus"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -261,6 +262,7 @@ func PreprocessSpec(file io.Reader, gcc Runner, includeFlags []string, defineFla
}

func ParseSpec(r io.Reader) (*Spec, error) {
log.Infof("Parsing spec")
parser, err := participle.Build(&SpecAst{}, nil)
if err != nil {
return nil, err
Expand All @@ -271,7 +273,11 @@ func ParseSpec(r io.Reader) (*Spec, error) {
if err != nil {
return nil, err
}
return convertAstToSpec(*specAst)
out, err := convertAstToSpec(*specAst)
if err == nil {
log.Debugf("Parsed: %v", out)
}
return out, err
}

func (w *Wave) checkValidity() error {
Expand Down

0 comments on commit 9e3e113

Please sign in to comment.