add default types
This commit is contained in:
parent
5cc1e091e9
commit
92e7954dbc
|
@ -14,7 +14,6 @@ import (
|
||||||
// recursively and generate .so files
|
// recursively and generate .so files
|
||||||
// into the @out folder with the same structure
|
// into the @out folder with the same structure
|
||||||
func buildControllers(in string, out string) error {
|
func buildControllers(in string, out string) error {
|
||||||
clifmt.Title("compile controllers")
|
|
||||||
|
|
||||||
/* (1) Create build folder */
|
/* (1) Create build folder */
|
||||||
clifmt.Align(" . create output folder")
|
clifmt.Align(" . create output folder")
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
// recursively and generate .so files
|
// recursively and generate .so files
|
||||||
// into the @out folder with the same structure
|
// into the @out folder with the same structure
|
||||||
func buildTypes(in string, out string) error {
|
func buildTypes(in string, out string) error {
|
||||||
clifmt.Title("compile types")
|
|
||||||
|
|
||||||
/* (1) Create build folder */
|
/* (1) Create build folder */
|
||||||
clifmt.Align(" . create output folder")
|
clifmt.Align(" . create output folder")
|
||||||
|
@ -24,7 +23,7 @@ func buildTypes(in string, out string) error {
|
||||||
}
|
}
|
||||||
fmt.Printf("ok\n")
|
fmt.Printf("ok\n")
|
||||||
|
|
||||||
/* (1) List recursively */
|
/* (2) List recursively */
|
||||||
types := []string{}
|
types := []string{}
|
||||||
err = filepath.Walk(in, func(path string, f os.FileInfo, err error) error {
|
err = filepath.Walk(in, func(path string, f os.FileInfo, err error) error {
|
||||||
if strings.HasSuffix(path, "/main.go") {
|
if strings.HasSuffix(path, "/main.go") {
|
||||||
|
@ -37,7 +36,7 @@ func buildTypes(in string, out string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (2) Print files */
|
/* (3) Print files */
|
||||||
for _, name := range types {
|
for _, name := range types {
|
||||||
|
|
||||||
// 1. process output file name
|
// 1. process output file name
|
||||||
|
@ -46,20 +45,20 @@ func buildTypes(in string, out string) error {
|
||||||
|
|
||||||
clifmt.Align(fmt.Sprintf(" . compile %s", clifmt.Color(33, name)))
|
clifmt.Align(fmt.Sprintf(" . compile %s", clifmt.Color(33, name)))
|
||||||
|
|
||||||
// 3. compile
|
// 2. compile
|
||||||
stdout, err := exec.Command("go",
|
stdout, err := exec.Command("go",
|
||||||
"build", "-buildmode=plugin",
|
"build", "-buildmode=plugin",
|
||||||
"-o", outfile,
|
"-o", outfile,
|
||||||
infile,
|
infile,
|
||||||
).Output()
|
).Output()
|
||||||
|
|
||||||
// 4. success
|
// 3. success
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fmt.Printf("ok\n")
|
fmt.Printf("ok\n")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. debug error
|
// 4. debug error
|
||||||
fmt.Printf("error\n")
|
fmt.Printf("error\n")
|
||||||
if len(stdout) > 0 {
|
if len(stdout) > 0 {
|
||||||
fmt.Printf("%s\n%s\n%s\n", clifmt.Color(31, "-=-"), stdout, clifmt.Color(31, "-=-"))
|
fmt.Printf("%s\n%s\n%s\n", clifmt.Color(31, "-=-"), stdout, clifmt.Color(31, "-=-"))
|
||||||
|
|
|
@ -58,6 +58,9 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default types folder
|
||||||
|
dtPath := filepath.Join(os.Getenv("GOPATH"), "src/git.xdrm.io/go/aicra/checker/default")
|
||||||
|
|
||||||
/* (3) Check path are existing dirs
|
/* (3) Check path are existing dirs
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
clifmt.Title("file check")
|
clifmt.Title("file check")
|
||||||
|
@ -82,7 +85,17 @@ func main() {
|
||||||
fmt.Printf("ok\n")
|
fmt.Printf("ok\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (3) Types path */
|
/* (3) Default types path */
|
||||||
|
clifmt.Align(" . default types")
|
||||||
|
if stat, err := os.Stat(dtPath); err != nil || !stat.IsDir() {
|
||||||
|
fmt.Printf("missing\n")
|
||||||
|
compileTypes = false
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fmt.Printf("ok\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (4) Types path */
|
||||||
clifmt.Align(" . custom types")
|
clifmt.Align(" . custom types")
|
||||||
if stat, err := os.Stat(tPath); err != nil || !stat.IsDir() {
|
if stat, err := os.Stat(tPath); err != nil || !stat.IsDir() {
|
||||||
fmt.Printf("missing\n")
|
fmt.Printf("missing\n")
|
||||||
|
@ -112,21 +125,31 @@ func main() {
|
||||||
|
|
||||||
/* (2) Compile controllers */
|
/* (2) Compile controllers */
|
||||||
if compileControllers {
|
if compileControllers {
|
||||||
|
clifmt.Title("compile controllers")
|
||||||
err = buildControllers(cPath, filepath.Join(projectPath, ".build/controller"))
|
err = buildControllers(cPath, filepath.Join(projectPath, ".build/controller"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%s compilation error: %s\n", clifmt.Warn(), err)
|
fmt.Printf("%s compilation error: %s\n", clifmt.Warn(), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (3) Compile types */
|
/* (3) Compile DEFAULT types */
|
||||||
|
clifmt.Title("compile default types")
|
||||||
|
err = buildTypes(
|
||||||
|
dtPath,
|
||||||
|
filepath.Join(projectPath, ".build/types"))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("%s compilation error: %s\n", clifmt.Warn(), err)
|
||||||
|
}
|
||||||
|
/* (4) Compile types */
|
||||||
if compileTypes {
|
if compileTypes {
|
||||||
|
clifmt.Title("compile types")
|
||||||
err = buildTypes(tPath, filepath.Join(projectPath, ".build/types"))
|
err = buildTypes(tPath, filepath.Join(projectPath, ".build/types"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%s compilation error: %s\n", clifmt.Warn(), err)
|
fmt.Printf("%s compilation error: %s\n", clifmt.Warn(), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (4) finished */
|
/* (5) finished */
|
||||||
fmt.Printf("\n[ %s ] files are located inside the %s directory inside the project folder\n",
|
fmt.Printf("\n[ %s ] files are located inside the %s directory inside the project folder\n",
|
||||||
clifmt.Color(32, "finished"),
|
clifmt.Color(32, "finished"),
|
||||||
clifmt.Color(33, ".build"),
|
clifmt.Color(33, ".build"),
|
||||||
|
|
Loading…
Reference in New Issue