예제 #1
0
func getGen(t *testing.T) gen.GenRoot {
	opts := options.NewGenOptions(
		23,
		"mock",
		"github.com/tamtam-im/teleport/lib/go/tl",
	)
	prog, err := syntax.Parse(program.Program, strings.NewReader(src))
	assert.NoError(t, err)
	g := gen.NewGenRoot(
		prog.(syntax.Program), opts)
	assert.NotNil(t, g)
	return g
}
예제 #2
0
파일: main.go 프로젝트: tamtam-im/teleport
func main() {
	fs := flags.New().SetVersion(Version)
	fs.UseEnv = false
	fs.Boot()

	logx.SetLevel(log_level)
	prog, err := program.ParseFiles(flag.Args()...)
	logx.OnFatal(err)

	opts := options.NewGenOptions(layer, pack, core)

	gen_root := gen.NewGenRoot(prog, opts)

	// make package dir
	err = os.MkdirAll(filepath.Join(out, pack), os.ModePerm)
	logx.OnFatal(err)

	// Write types
	res, err := gen_root.Out()
	logx.OnFatal(err)
	for filename, box_res := range res {
		target := filepath.Join(out, pack, filename)
		err = ioutil.WriteFile(target, box_res, os.ModePerm)
		logx.OnFatal(err)
		logx.Infof("==> %s", target)
	}

	// Write Fns
	//	fn_fname, fn_res, err := gen_root.PipeOut()
	//	logx.OnFatal(err)
	//	target := filepath.Join(out, pack, fn_fname)
	//	err = ioutil.WriteFile(target, fn_res, os.ModePerm)
	//	logx.Infof("==> %s", target)
	//
	//	// Write package
	//	pack_res, err := gen_root.PackageOut()
	//	logx.OnFatal(err)
	//	target = filepath.Join(out, pack, pack) + ".go"
	//	err = ioutil.WriteFile(target, pack_res, os.ModePerm)
	//	logx.OnFatal(err)
	//	logx.Infof("==> %s", target)
}