This is an automated email from the ASF dual-hosted git repository.

warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new bf6ead17 feat: debugging with delve
bf6ead17 is described below

commit bf6ead179fbf8ea2304b1b5bfc35151e483887b7
Author: Klesh Wong <[email protected]>
AuthorDate: Wed Jun 22 22:28:33 2022 +0800

    feat: debugging with delve
    
      1. run `[PLUGIN=<PLUGIN_NAME>] make debug` to launch delve
      2. fix `scripts/compile-plugins.sh` error swallowing
---
 Makefile                   |  6 ++++++
 scripts/compile-plugins.sh | 21 ++++++++++++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 17ff5d67..50eb5404 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,9 @@ VERSION = $(TAG)@$(SHA)
 build-plugin:
        @sh scripts/compile-plugins.sh
 
+build-plugin-debug:
+       @sh scripts/compile-plugins.sh -gcflags='all=-N -l'
+
 build-worker:
        go build -ldflags "-X 
'github.com/apache/incubator-devlake/version.Version=$(VERSION)'" -o 
bin/lake-worker ./worker/
 
@@ -42,6 +45,9 @@ worker:
 
 dev: build-plugin run
 
+debug: build-plugin-debug
+       dlv debug main.go
+
 configure:
        docker-compose up config-ui
 
diff --git a/scripts/compile-plugins.sh b/scripts/compile-plugins.sh
index 7610797c..36fdd7c7 100755
--- a/scripts/compile-plugins.sh
+++ b/scripts/compile-plugins.sh
@@ -16,8 +16,17 @@
 # limitations under the License.
 #
 
-# If you want to use this, you need to run `PLUGIN=github make dev`
-# to compile all plugins `make dev`
+# compile all plugins and fire up api server:
+#   make dev
+#
+# compile specific plugin and fire up api server:
+#   PLUGIN=<PLUGIN_NAME> make dev
+#
+# compile all plugins and fire up api server in DEBUG MODE with `delve`:
+#   make debug
+#
+# compile specific plugin and fire up api server in DEBUG MODE with `delve`:
+#   PLUGIN=<PLUGIN_NAME> make dev
 
 set -e
 
@@ -36,9 +45,15 @@ else
 fi
 
 rm -rf $PLUGIN_OUTPUT_DIR/*
+
+PIDS=""
 for PLUG in $PLUGINS; do
     NAME=$(basename $PLUG)
     echo "Building plugin $NAME to bin/plugins/$NAME/$NAME.so"
     go build -buildmode=plugin "$@" -o $PLUGIN_OUTPUT_DIR/$NAME/$NAME.so 
$PLUG/*.go &
+    PIDS="$PIDS $!"
+done
+
+for PID in $PIDS; do
+    wait $PID
 done
-wait

Reply via email to