From 55baba21af4396555d32a60db7a4910178b73d89 Mon Sep 17 00:00:00 2001 From: Tyler Rhodes Date: Sun, 25 Feb 2018 15:02:05 -0800 Subject: [PATCH] Fill out rom_image a bit more, wire it into cmd --- bin/spicy.go | 18 ++++++++++++++++++ entry_source.go | 9 ++++----- ld.go | 27 +++++++++++++-------------- rom_image.go | 6 +++--- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/bin/spicy.go b/bin/spicy.go index 942ef0f..3c83f15 100644 --- a/bin/spicy.go +++ b/bin/spicy.go @@ -3,6 +3,7 @@ import ( "flag" "bufio" "os" + "fmt" "github.com/trhodeos/spicy" ) const ( @@ -71,4 +72,21 @@ func main() { if err != nil { panic(err) } err = spicy.LinkSpec(spec, *ld_command) if err != nil { panic(err) } + + var romheader *os.File + var bootstrap *os.File + var font *os.File + var entry *os.File + var code *os.File + var raw *os.File + name := spec.Waves[0].Name + out, err := os.OpenFile(fmt.Sprintf("%s.n64", name), os.O_CREATE|os.O_RDWR, 0755) + if err != nil { + panic(err) + } + err = spicy.WriteRomImage(out, romheader, bootstrap, font, entry, code, raw) + if err != nil { + panic(err) + } + } diff --git a/entry_source.go b/entry_source.go index 402cdf0..faf8007 100644 --- a/entry_source.go +++ b/entry_source.go @@ -1,14 +1,13 @@ package spicy + import ( - "os" + "os" ) - func generateEntrySource() (string, error) { - return "", nil + return "", nil } func CreateEntrySourceBinary() (*os.File, error) { - return nil, nil + return nil, nil } - diff --git a/ld.go b/ld.go index de762ea..40a27cc 100644 --- a/ld.go +++ b/ld.go @@ -1,13 +1,13 @@ package spicy import ( + "bytes" "fmt" "github.com/golang/glog" "io/ioutil" "os/exec" "path/filepath" "text/template" - "bytes" ) func createLdScript(s *Spec) (string, error) { @@ -76,7 +76,7 @@ SECTIONS { if err != nil { return "", err } - b := &bytes.Buffer{} + b := &bytes.Buffer{} err = tmpl.Execute(b, s) return b.String(), err } @@ -112,17 +112,16 @@ func LinkSpec(s *Spec, ld_command string) error { return err } cmd := exec.Command(ld_command, "-G 0", "-noinhibit-exec", "-T", ld_path, "-o", fmt.Sprintf("%s.out", name), "-M") - var out bytes.Buffer - var errout bytes.Buffer - cmd.Stdout = &out - cmd.Stderr = &errout + var out bytes.Buffer + var errout bytes.Buffer + cmd.Stdout = &out + cmd.Stderr = &errout err = cmd.Run() - if glog.V(2) { - glog.V(2).Info("Ld stdout: ", out.String()) - } - if err != nil { - glog.Error(errout.String()) - } - return err + if glog.V(2) { + glog.V(2).Info("Ld stdout: ", out.String()) + } + if err != nil { + glog.Error(errout.String()) + } + return err } - diff --git a/rom_image.go b/rom_image.go index b16ea2b..67e1b8c 100644 --- a/rom_image.go +++ b/rom_image.go @@ -1,9 +1,9 @@ package spicy import ( - "os" + "os" ) -func CreateRomImage() (*os.File, error) { - return nil, nil +func WriteRomImage(out *os.File, romheader *os.File, bootstrap *os.File, font *os.File, entry *os.File, code *os.File, raw *os.File) error { + return nil }