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