mirror of
https://github.com/gosticks/gml.git
synced 2026-10-06 07:37:02 +00:00
added new search paths and initial code for ExecDev
This commit is contained in:
@@ -50,6 +50,9 @@ func init() {
|
||||
if err != nil {
|
||||
log.Fatalf("gml: failed to create global application: %v", err)
|
||||
}
|
||||
|
||||
SetSearchPaths("qml", []string{":/qml"})
|
||||
SetSearchPaths("res", []string{":/resources"})
|
||||
}
|
||||
|
||||
// Must exits the application with a fatal log if the error is present.
|
||||
@@ -127,3 +130,52 @@ func SetSearchPaths(prefix string, searchPaths []string) {
|
||||
|
||||
C.gml_global_set_search_paths(prefixC, pathsC, C.int(len(searchPaths)))
|
||||
}
|
||||
|
||||
/*
|
||||
func ExecDev(basePath, url string) (retCode int, err error) {
|
||||
AddImportPath(basePath)
|
||||
|
||||
w := watcher.New()
|
||||
w.SetMaxEvents(1)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case event := <-w.Event:
|
||||
RunMain(func() {
|
||||
fmt.Println(event) // Print the event's info. TODO: log
|
||||
gapp.ClearComponentCache()
|
||||
})
|
||||
|
||||
case err := <-w.Error:
|
||||
log.Println("dev file watcher error: %v", err)
|
||||
|
||||
case <-w.Closed:
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
err = w.AddRecursive(filepath.Join(basePath, "qml"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
err := w.Start(time.Millisecond * 250)
|
||||
if err != nil {
|
||||
log.Println("dev file watcher failed: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
return Exec(url)
|
||||
}
|
||||
|
||||
func ExecDevExit(basePath, url string) {
|
||||
ret, err := ExecDev(basePath, url)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
os.Exit(ret)
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -9,5 +9,6 @@ require (
|
||||
github.com/json-iterator/go v1.1.6
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||
github.com/radovskyb/watcher v1.0.6
|
||||
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a
|
||||
)
|
||||
|
||||
@@ -29,6 +29,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/radovskyb/watcher v1.0.6 h1:8WIQ9UxEYMZjem1OwU7dVH94DXXk9mAIE1i8eqHD+IY=
|
||||
github.com/radovskyb/watcher v1.0.6/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a h1:Igim7XhdOpBnWPuYJ70XcNpq8q3BCACtVgNfoJxOV7g=
|
||||
|
||||
Reference in New Issue
Block a user