summaryrefslogtreecommitdiff
path: root/plugin.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-03 01:19:51 -0500
committerJeff Carr <[email protected]>2025-09-03 01:19:51 -0500
commit09e94187bfbabdfad3a41e0b2a8b56d4e55650ca (patch)
tree229a7a906657f04a67aece19a5b3d7859d069a85 /plugin.go
parente657015a78ddf9b9ae6cc0fbe90dd72c1a25291a (diff)
redo order in which the plugins are searchedv0.22.49
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.
Diffstat (limited to 'plugin.go')
-rw-r--r--plugin.go70
1 files changed, 36 insertions, 34 deletions
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
}