From 09e94187bfbabdfad3a41e0b2a8b56d4e55650ca Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 3 Sep 2025 01:19:51 -0500 Subject: redo order in which the plugins are searched Now that this verifies the plugin will load by os.Exec() loading the plugin, this bypasses the current problems with GO not being able to retry loading the plugin. Now it can return to testing the ones that were built locally by the user before the system or distribution packaged default plugins. --- init.go | 1 + plugin.go | 70 ++++++++++++++++++++++++++++++++------------------------------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/init.go b/init.go index 716aefb..2d6a3d8 100644 --- a/init.go +++ b/init.go @@ -384,6 +384,7 @@ func (n *Node) StandardExit() { log.Log(INFO, "StandardExit() attempt to exit each toolkit plugin") for i, plug := range allPlugins { log.Log(INFO, "NewButton()", i, plug) + n.CloseToolkit(plug.name) } log.Exit(0) } diff --git a/plugin.go b/plugin.go index 03f6e84..ed1b940 100644 --- a/plugin.go +++ b/plugin.go @@ -148,20 +148,47 @@ func searchPaths(name string) *aplug { var filename string var pfile []byte var err error + var p *aplug // try the filename from the command line first if argGui.GuiFile != "" { - p := initToolkit(name, argGui.GuiFile) + p = initToolkit(name, argGui.GuiFile) if p != nil { log.Log(NOW, "gui.Init() loaded ok!", argGui.GuiFile) return p } } - // 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) + // 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) + } else { + // first look in the toolkit build directory + filename = homeDir + "/go/src/go.wit.com/toolkits/" + name + "/" + name + ".so" + p = initToolkit(name, filename) + if p != nil { + log.Log(NOW, "gui.Init() loaded", filename, "ok!") + return p + } + + // this is the "default" location when built and installed locally + filename = homeDir + "/go/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 { log.Log(NOW, "gui.Init() loaded", filename, "ok!") return p @@ -196,40 +223,15 @@ func searchPaths(name string) *aplug { return p } - // 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) - } else { - // first look in the toolkit build directory - filename = homeDir + "/go/src/go.wit.com/toolkits/" + name + "/" + name + ".so" - p = initToolkit(name, filename) - if p != nil { - log.Log(NOW, "gui.Init() loaded", filename, "ok!") - return p - } - - // this is the "default" location when built and installed locally - filename = homeDir + "/go/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" + // 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 } + return nil } -- cgit v1.2.3