move .build/types to .build/type + update checker accordingly
This commit is contained in:
parent
c7a6772b2b
commit
ee72e2d285
|
@ -9,9 +9,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateRegistry creates an empty type registry
|
// CreateRegistry creates an empty type registry
|
||||||
// - if loadDir is TruE if will load all available types
|
// - if loadDir is True if will load all available types
|
||||||
// inside the local ./types folder
|
// inside the local ./types folder
|
||||||
func CreateRegistry(loadDir bool) *TypeRegistry {
|
func CreateRegistry(loadDir ...string) *TypeRegistry {
|
||||||
|
|
||||||
/* (1) Create registry */
|
/* (1) Create registry */
|
||||||
reg := &TypeRegistry{
|
reg := &TypeRegistry{
|
||||||
|
@ -19,12 +19,12 @@ func CreateRegistry(loadDir bool) *TypeRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (2) If no default to use -> empty registry */
|
/* (2) If no default to use -> empty registry */
|
||||||
if !loadDir {
|
if len(loadDir) < 1 {
|
||||||
return reg
|
return reg
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (3) List types */
|
/* (3) List types */
|
||||||
plugins, err := ioutil.ReadDir("./types")
|
plugins, err := ioutil.ReadDir(loadDir[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ func (tr *TypeRegistry) Add(pluginName string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (4) Try to load the plugin */
|
/* (4) Try to load the plugin */
|
||||||
p, err := plugin.Open(fmt.Sprintf("./types/%s", pluginName))
|
p, err := plugin.Open(fmt.Sprintf(".build/type/%s", pluginName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,14 +136,14 @@ func main() {
|
||||||
clifmt.Title("compile default types")
|
clifmt.Title("compile default types")
|
||||||
err = buildTypes(
|
err = buildTypes(
|
||||||
dtPath,
|
dtPath,
|
||||||
filepath.Join(projectPath, ".build/types"))
|
filepath.Join(projectPath, ".build/type"))
|
||||||
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) Compile types */
|
/* (4) Compile types */
|
||||||
if compileTypes {
|
if compileTypes {
|
||||||
clifmt.Title("compile types")
|
clifmt.Title("compile types")
|
||||||
err = buildTypes(tPath, filepath.Join(projectPath, ".build/types"))
|
err = buildTypes(tPath, filepath.Join(projectPath, ".build/type"))
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Init initilises a new framework instance
|
// Init initilises a new framework instance
|
||||||
//
|
|
||||||
// - path is the configuration path
|
// - path is the configuration path
|
||||||
//
|
|
||||||
// - if typeChecker is nil, defaults will be used (all *.so files
|
// - if typeChecker is nil, defaults will be used (all *.so files
|
||||||
// inside ./types local directory)
|
// inside ./.build/types local directory)
|
||||||
func Init(path string, typeChecker *checker.TypeRegistry) (*Server, error) {
|
func Init(path string, typeChecker *checker.TypeRegistry) (*Server, error) {
|
||||||
|
|
||||||
/* (1) Init instance */
|
/* (1) Init instance */
|
||||||
|
@ -39,7 +37,7 @@ func Init(path string, typeChecker *checker.TypeRegistry) (*Server, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (4) Default registry creation */
|
/* (4) Default registry creation */
|
||||||
inst.Checker = checker.CreateRegistry(true)
|
inst.Checker = checker.CreateRegistry(".build/type")
|
||||||
|
|
||||||
return inst, nil
|
return inst, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue