summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-06 07:56:23 -0600
committerJeff Carr <[email protected]>2025-03-06 07:56:23 -0600
commit10d4942e6c1815634ce54150d8882db122beebf2 (patch)
tree95b0466312317f04cbd204a975bd83ba7e8c58de
parent4b08f576743eadac8ecbd481415c10d9abefdc05 (diff)
add options to debug plugin load failuresv0.22.38
-rw-r--r--argv.go1
-rw-r--r--init.go3
-rw-r--r--plugin.go20
3 files changed, 24 insertions, 0 deletions
diff --git a/argv.go b/argv.go
index e5514de..b7e75df 100644
--- a/argv.go
+++ b/argv.go
@@ -14,6 +14,7 @@ type ArgsGui struct {
NoGui bool `arg:"--no-gui" help:"ignore all these gui problems"`
GuiPlugin string `arg:"--gui" help:"Use this gui toolkit [andlabs,gocui,nocui,stdin]"`
GuiFile string `arg:"--gui-file" help:"Use a specific plugin.so file"`
+ GuiTest string `arg:"--gui-test" help:"test a specific plugin.so will load"`
GuiVerbose bool `arg:"--gui-verbose" help:"enable all logging"`
}
diff --git a/init.go b/init.go
index f56fa15..d6e1678 100644
--- a/init.go
+++ b/init.go
@@ -281,6 +281,9 @@ func New() *Node {
// trapStdout()
}
*/
+ if argGui.GuiTest != "" {
+ testPlugin()
+ }
initNew()
return me.rootNode
diff --git a/plugin.go b/plugin.go
index 0a8f993..396829d 100644
--- a/plugin.go
+++ b/plugin.go
@@ -149,6 +149,15 @@ func searchPaths(name string) *aplug {
var pfile []byte
var err error
+ // try the filename from the command line first
+ if argGui.GuiFile != "" {
+ p := initToolkit(name, argGui.GuiFile)
+ if p != nil {
+ log.Log(NOW, "gui.Init() loaded ok!", argGui.GuiFile)
+ return p
+ }
+ }
+
// first try to load the embedded plugin file
// always try this first as it should have been
// tested by whomever compiled your binary
@@ -219,6 +228,17 @@ func searchPaths(name string) *aplug {
return nil
}
+// tests the plugin file will load
+func testPlugin() {
+ _, err := plugin.Open(argGui.GuiTest)
+ if err != nil {
+ log.Log(PLUG, "plugin.Open() FAILED =", argGui.GuiTest, err)
+ os.Exit(-1)
+ }
+ log.Log(PLUG, "plugin.Open() SUCCESS loading plugin =", argGui.GuiTest)
+ os.Exit(0)
+}
+
// load module
// 1. open the shared object file to load the symbols
func initToolkit(name string, filename string) *aplug {