feat(sointu): remove 16-bit output toggle from song; make it compile time option

This commit is contained in:
vsariola
2021-01-05 18:08:13 +02:00
parent 30379c981d
commit 588488ce54
98 changed files with 48 additions and 140 deletions

View File

@ -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) {