summaryrefslogtreecommitdiff
path: root/plugin.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin.go')
-rw-r--r--plugin.go41
1 files changed, 23 insertions, 18 deletions
diff --git a/plugin.go b/plugin.go
index 1f3bc98..a1322ee 100644
--- a/plugin.go
+++ b/plugin.go
@@ -136,13 +136,13 @@ func sendCallback(p *aplug, funcName string) func(chan widget.Action) {
}
/*
-TODO: clean this up. use command args?
-TODO: use LD_LIBRARY_PATH ?
This searches in the following order for the plugin .so files:
- ./toolkit/
+ /usr/lib/go-gui-toolkits/
~/go/src/go.wit.com/toolkits/
- /usr/lib/go-gui/
+ /usr/lib/local/go-gui-toolkits/
+
+ TODO: plugin.Open() seem to always fail after the first attempt fails
*/
func searchPaths(name string) *aplug {
var filename string
@@ -158,10 +158,17 @@ func searchPaths(name string) *aplug {
}
}
- // first try to load the embedded plugin file
- // always try this first as it should have been
- // tested by whomever compiled your binary
- // todo: fix this so it does not have to be written to /tmp/
+ // This is the 'default' location
+ // if you are a linux distribution package maintainer, please put the tookits here
+ filename = "/usr/lib/go-gui-toolkits/" + name + ".so"
+ p := initToolkit(name, filename)
+ if p != nil {
+ log.Log(NOW, "gui.Init() loaded", filename, "ok!")
+ return p
+ }
+
+ // try to load the embedded plugin file
+ // TODO: fix the filename used in /tmp/
resname := filepath.Join("resources/", name+".so")
pfile, err = me.resFS.ReadFile(resname)
if err == nil {
@@ -183,13 +190,18 @@ func searchPaths(name string) *aplug {
// attempt to write out the file from the internal resource
// is this the same as above. todo: sort this out.
filename = "resources/" + name + ".so"
- p := initToolkit(name, filename)
+ p = initToolkit(name, filename)
if p != nil {
log.Log(NOW, "gui.Init() loaded", filename, "ok!")
return p
}
- // first check the user's home dir
+ // check for custom toolkit builds. This looks:
+ // with 'go build': ~/go/src/go.wit.com/toolkits/gocui/gocui.go
+ // with 'make install': ~/go/lib/go-gui/gocui.go
+ //
+ // TODO: use forge to find the "go.work" dir
+ // TODO: fix 'go install' to support building plugins
homeDir, err := os.UserHomeDir()
if err != nil {
log.Error(err, "os.UserHomeDir() error", err)
@@ -211,14 +223,7 @@ func searchPaths(name string) *aplug {
}
}
- // fall back to the system packages
- filename = "/usr/lib/go-gui/" + name + ".so"
- p = initToolkit(name, filename)
- if p != nil {
- log.Log(NOW, "gui.Init() loaded", filename, "ok!")
- return p
- }
-
+ // try /usr/local/
filename = "/usr/local/lib/go-gui/" + name + ".so"
p = initToolkit(name, filename)
if p != nil {