diff options
| author | Jeff Carr <[email protected]> | 2025-03-12 13:18:22 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-12 13:18:22 -0500 |
| commit | 65a18185792e92029eeb85dac79f6f63781fd042 (patch) | |
| tree | 98c54b376e87fe5c68fc713fbfe64bf5a60a436e /plugin.go | |
| parent | d8f5ca6f939a7b67a7d1df0edcae232150bac13e (diff) | |
Diffstat (limited to 'plugin.go')
| -rw-r--r-- | plugin.go | 41 |
1 files changed, 23 insertions, 18 deletions
@@ -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 { |
