func GenModule(name string) { var ( moduleT = name cppTmp string ) name = strings.ToLower(name) parser.GetModule(name) if ShouldBuild(moduleT) { utils.RemoveAll(utils.GetQtPkgPath(name)) utils.RemoveAll(utils.GetQtPkgPath("internal", "binding", "dump", moduleT)) var fcount = 0 for _, c := range parser.ClassMap { if moduleT == strings.TrimPrefix(c.Module, "Qt") { //Dry run to catch all unsupported for _, f := range map[string]func(*parser.Class) string{"cpp": CppTemplate, "h": HTemplate, "go": GoTemplate} { f(c) } for e, f := range map[string]func(*parser.Class) string{"cpp": CppTemplate, "h": HTemplate, "go": GoTemplate} { utils.MakeFolder(utils.GetQtPkgPath(name)) CopyCgo(moduleT) if moduleT == "AndroidExtras" { utils.Save(utils.GetQtPkgPath(name, fmt.Sprintf("%v_android.%v", strings.ToLower(c.Name), e)), f(c)) if e == "go" { c.Stub = true utils.Save(utils.GetQtPkgPath(name, fmt.Sprintf("%v.%v", strings.ToLower(c.Name), e)), f(c)) c.Stub = false } } else { if e == "cpp" { cppTmp += f(c) } else { utils.Save(utils.GetQtPkgPath(name, fmt.Sprintf("%v.%v", strings.ToLower(c.Name), e)), f(c)) } } } c.Dump() fcount += len(c.Functions) } } utils.Save(utils.GetQtPkgPath(name, fmt.Sprintf("%v.cpp", strings.ToLower(moduleT))), cppTmp) fmt.Printf("%v%v\tfunctions:%v", name, terminalSeperator(name), fcount) } }
func main() { if len(os.Args) == 1 { fmt.Println("________________________Generate________________________") for _, module := range templater.GetLibs() { parser.GetModule(strings.ToLower(module)) } for _, module := range templater.GetLibs() { var before = time.Now() templater.GenModule(module) fmt.Println(name(module), functions(module), time.Since(before)/time.Second*time.Second) var out, err = exec.Command("go", "fmt", fmt.Sprintf("github.com/therecipe/qt/%v", strings.ToLower(module))).CombinedOutput() if err != nil { fmt.Println(string(out), err) os.Exit(1) } } } }