mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 13:04:25 -04:00
feat(sointu): remove 16-bit output toggle from song; make it compile time option
This commit is contained in:
@ -13,13 +13,14 @@ import (
|
||||
)
|
||||
|
||||
type Compiler struct {
|
||||
Template *template.Template
|
||||
OS string
|
||||
Arch string
|
||||
Template *template.Template
|
||||
OS string
|
||||
Arch string
|
||||
Output16Bit bool
|
||||
}
|
||||
|
||||
// New returns a new compiler using the default .asm templates
|
||||
func New(os string, arch string) (*Compiler, error) {
|
||||
func New(os string, arch string, output16Bit bool) (*Compiler, error) {
|
||||
_, myname, _, _ := runtime.Caller(0)
|
||||
var subdir string
|
||||
if arch == "386" || arch == "amd64" {
|
||||
@ -30,17 +31,17 @@ func New(os string, arch string) (*Compiler, error) {
|
||||
return nil, fmt.Errorf("compiler.New failed, because only amd64, 386 and wasm archs are supported (targeted architecture was %v)", arch)
|
||||
}
|
||||
templateDir := filepath.Join(path.Dir(myname), "..", "templates", subdir)
|
||||
compiler, err := NewFromTemplates(os, arch, templateDir)
|
||||
compiler, err := NewFromTemplates(os, arch, output16Bit, templateDir)
|
||||
return compiler, err
|
||||
}
|
||||
|
||||
func NewFromTemplates(os string, arch string, templateDirectory string) (*Compiler, error) {
|
||||
func NewFromTemplates(os string, arch string, output16Bit bool, templateDirectory string) (*Compiler, error) {
|
||||
globPtrn := filepath.Join(templateDirectory, "*.*")
|
||||
tmpl, err := template.New("base").Funcs(sprig.TxtFuncMap()).ParseGlob(globPtrn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(`could not create template based on directory "%v": %v`, templateDirectory, err)
|
||||
}
|
||||
return &Compiler{Template: tmpl, OS: os, Arch: arch}, nil
|
||||
return &Compiler{Template: tmpl, OS: os, Arch: arch, Output16Bit: output16Bit}, nil
|
||||
}
|
||||
|
||||
func (com *Compiler) Library() (map[string]string, error) {
|
||||
|
Reference in New Issue
Block a user