Skip to content

Commit

Permalink
feat: debugging with delve
Browse files Browse the repository at this point in the history
  1. run `[PLUGIN=<PLUGIN_NAME>] make debug` to launch delve
  2. fix `scripts/compile-plugins.sh` error swallowing
  • Loading branch information
klesh authored and warren830 committed Jun 22, 2022
1 parent 2a557b7 commit bf6ead1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand All @@ -42,6 +45,9 @@ worker:

dev: build-plugin run

debug: build-plugin-debug
dlv debug main.go

configure:
docker-compose up config-ui

Expand Down
21 changes: 18 additions & 3 deletions scripts/compile-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

0 comments on commit bf6ead1

Please sign in to comment.