add implementation to 'default types'
This commit is contained in:
parent
17bb63b9de
commit
fd6d7b661e
|
@ -9,6 +9,8 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var defaultTypeFolder = filepath.Join(os.Getenv("GOPATH"), "src/git.xdrm.io/go/aicra/internal/checker/default/*")
|
||||
|
||||
func main() {
|
||||
|
||||
starttime := time.Now()
|
||||
|
@ -39,7 +41,36 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
/* (2) Compile Types */
|
||||
/* (2) Compile Default Types */
|
||||
if schema.Types.Default {
|
||||
clifmt.Title("compile default types")
|
||||
files, err := filepath.Glob(defaultTypeFolder)
|
||||
if err != nil {
|
||||
fmt.Printf("cannot load default types")
|
||||
} else {
|
||||
|
||||
for _, file := range files {
|
||||
|
||||
typeName, err := filepath.Rel(filepath.Dir(file), file)
|
||||
if err != nil {
|
||||
fmt.Printf("cannot load type '%s'\n", typeName)
|
||||
continue
|
||||
|
||||
}
|
||||
|
||||
fmt.Printf(" [%s]\n", clifmt.Color(33, typeName))
|
||||
|
||||
// Get useful paths
|
||||
source := filepath.Join(file, "main.go")
|
||||
build := filepath.Join(schema.Root, ".build/type", fmt.Sprintf("%s.so", typeName))
|
||||
|
||||
compile(source, build)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* (3) Compile Types */
|
||||
if len(schema.Types.Map) > 0 {
|
||||
clifmt.Title("compile types")
|
||||
for name, upath := range schema.Types.Map {
|
||||
|
@ -54,7 +85,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
/* (3) Compile controllers */
|
||||
/* (4) Compile controllers */
|
||||
if len(schema.Controllers.Map) > 0 {
|
||||
clifmt.Title("compile controllers")
|
||||
for name, upath := range schema.Controllers.Map {
|
||||
|
@ -70,7 +101,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
/* (4) Compile middlewares */
|
||||
/* (5) Compile middlewares */
|
||||
if len(schema.Middlewares.Map) > 0 {
|
||||
clifmt.Title("compile middlewares")
|
||||
for name, upath := range schema.Middlewares.Map {
|
||||
|
|
|
@ -6,18 +6,18 @@ var Default = Schema{
|
|||
Port: 80,
|
||||
DriverName: "",
|
||||
Types: &builder{
|
||||
IgnoreBuiltIn: false,
|
||||
Folder: "",
|
||||
Map: nil,
|
||||
Default: true,
|
||||
Folder: "",
|
||||
Map: nil,
|
||||
},
|
||||
Controllers: &builder{
|
||||
IgnoreBuiltIn: true,
|
||||
Folder: "",
|
||||
Map: nil,
|
||||
Default: false,
|
||||
Folder: "",
|
||||
Map: nil,
|
||||
},
|
||||
Middlewares: &builder{
|
||||
IgnoreBuiltIn: true,
|
||||
Folder: "",
|
||||
Map: nil,
|
||||
Default: false,
|
||||
Folder: "",
|
||||
Map: nil,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
)
|
||||
|
||||
type builder struct {
|
||||
// IgnoreBuiltIn tells whether or not to ignore the built-in components
|
||||
IgnoreBuiltIn bool `json:"default,ommitempty"`
|
||||
// Default tells whether or not to ignore the built-in components
|
||||
Default bool `json:"default,ommitempty"`
|
||||
|
||||
// Folder is used to infer the 'Map' object
|
||||
Folder string `json:"folder,ommitempty"`
|
||||
|
|
Loading…
Reference in New Issue