Define include path in one place
This commit is contained in:
parent
bc46e1e982
commit
d6cb7935fe
|
@ -1,6 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "strconv"
|
import (
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
func writeFilenames(charmaps []string, filename string) error {
|
func writeFilenames(charmaps []string, filename string) error {
|
||||||
s, err := createCSource(filename)
|
s, err := createCSource(filename)
|
||||||
|
@ -10,9 +12,8 @@ func writeFilenames(charmaps []string, filename string) error {
|
||||||
|
|
||||||
w := s.writer
|
w := s.writer
|
||||||
w.WriteString(header)
|
w.WriteString(header)
|
||||||
w.WriteString(
|
s.include("test.h")
|
||||||
"#include \"convert/test.h\"\n" +
|
w.WriteString("const char *const kCharsetFilename[] = {\n")
|
||||||
"const char *const kCharsetFilename[] = {\n")
|
|
||||||
for _, fn := range charmaps {
|
for _, fn := range charmaps {
|
||||||
if fn != "" {
|
if fn != "" {
|
||||||
w.WriteByte('\t')
|
w.WriteByte('\t')
|
||||||
|
|
|
@ -13,7 +13,10 @@ import (
|
||||||
"moria.us/macscript/table"
|
"moria.us/macscript/table"
|
||||||
)
|
)
|
||||||
|
|
||||||
const header = "/* This file is automatically generated. */\n"
|
const (
|
||||||
|
header = "/* This file is automatically generated. */\n"
|
||||||
|
srcdirname = "convert"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
flagDest string
|
flagDest string
|
||||||
|
@ -44,7 +47,7 @@ func mainE() error {
|
||||||
}
|
}
|
||||||
destdir := flagDest
|
destdir := flagDest
|
||||||
if destdir == "" {
|
if destdir == "" {
|
||||||
destdir = filepath.Join(srcdir, "convert")
|
destdir = filepath.Join(srcdir, srcdirname)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read metadata.
|
// Read metadata.
|
||||||
|
|
|
@ -78,9 +78,9 @@ func writeMap(d *scriptdata, m []*scriptmap, filename string) error {
|
||||||
|
|
||||||
w := s.writer
|
w := s.writer
|
||||||
w.WriteString(header)
|
w.WriteString(header)
|
||||||
|
s.include("convert.h")
|
||||||
w.WriteString(
|
w.WriteString(
|
||||||
"#include \"convert/convert.h\"\n" +
|
"int GetCharmap(int script, int region) {\n" +
|
||||||
"int GetCharmap(int script, int region) {\n" +
|
|
||||||
"switch (script) {\n")
|
"switch (script) {\n")
|
||||||
for _, s := range m {
|
for _, s := range m {
|
||||||
fmt.Fprintf(w, "case %d: /* %s */\n", s.script, d.scripts.values[s.script])
|
fmt.Fprintf(w, "case %d: /* %s */\n", s.script, d.scripts.values[s.script])
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
type csource struct {
|
type csource struct {
|
||||||
|
@ -62,3 +63,7 @@ func (s *csource) flush() error {
|
||||||
s.filename = ""
|
s.filename = ""
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *csource) include(name string) {
|
||||||
|
fmt.Fprintf(s.writer, "#include \"%s\"\n", path.Join(srcdirname, name))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue