From c2bcbfd07fc52658be540466ae525c9d816a42d7 Mon Sep 17 00:00:00 2001 From: xucong053 Date: Thu, 26 May 2022 21:57:35 +0800 Subject: [PATCH] fix: default output debugtalk_gen.py by building debugtalk.py --- hrp/internal/build/main.go | 4 ++-- hrp/internal/build/main_test.go | 2 +- hrp/plugin.go | 15 ++++++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/hrp/internal/build/main.go b/hrp/internal/build/main.go index afadf8aa..811801ab 100644 --- a/hrp/internal/build/main.go +++ b/hrp/internal/build/main.go @@ -261,9 +261,9 @@ func buildPy(path string, output string) error { // generate debugtalk.py if output == "" { dir, _ := os.Getwd() - output = filepath.Join(dir, "debugtalk.py") + output = filepath.Join(dir, "debugtalk_gen.py") } else if builtin.IsFolderPathExists(output) { - output = filepath.Join(output, "debugtalk.py") + output = filepath.Join(output, "debugtalk_gen.py") } err = templateContent.genDebugTalk(output, pyTemplate) if err != nil { diff --git a/hrp/internal/build/main_test.go b/hrp/internal/build/main_test.go index 8a58cfe4..a169c77a 100644 --- a/hrp/internal/build/main_test.go +++ b/hrp/internal/build/main_test.go @@ -17,7 +17,7 @@ func TestRun(t *testing.T) { t.Fatal() } - err = Run("examples/debugtalk_no_funppy.py", "./debugtalk_gen.py") + err = Run("examples/debugtalk_no_funppy.py", "./debugtalk.py") if !assert.Nil(t, err) { t.Fatal() } diff --git a/hrp/plugin.go b/hrp/plugin.go index f9465a90..004fc1cb 100644 --- a/hrp/plugin.go +++ b/hrp/plugin.go @@ -14,10 +14,10 @@ import ( ) const ( - goPluginFile = "debugtalk.so" // built from go plugin - hashicorpGoPluginFile = "debugtalk.bin" // built from hashicorp go plugin - hashicorpPyPluginFile = "debugtalk.py" // used for hashicorp python plugin - projectInfoFile = "proj.json" // used for ensuring root project + goPluginFile = "debugtalk.so" // built from go plugin + hashicorpGoPluginFile = "debugtalk.bin" // built from hashicorp go plugin + hashicorpPyPluginFile = "debugtalk_gen.py" // used for hashicorp python plugin, automatically generated by HRP + debugtalkPyFile = "debugtalk.py" // write by user ) func initPlugin(path string, logOn bool) (plugin funplugin.IPlugin, pluginDir string, err error) { @@ -62,7 +62,7 @@ func initPlugin(path string, logOn bool) (plugin funplugin.IPlugin, pluginDir st } func locatePlugin(path string) (pluginPath string, err error) { - // priority: hashicorp plugin (debugtalk.bin > debugtalk.py) > go plugin (debugtalk.so) + // priority: hashicorp plugin (debugtalk.bin > debugtalk_gen.py > debugtalk.py) > go plugin (debugtalk.so) pluginPath, err = locateFile(path, hashicorpGoPluginFile) if err == nil { @@ -74,6 +74,11 @@ func locatePlugin(path string) (pluginPath string, err error) { return } + pluginPath, err = locateFile(path, debugtalkPyFile) + if err == nil { + return + } + pluginPath, err = locateFile(path, goPluginFile) if err == nil { return