1
0
Fork 0
go_plugin_demo/Makefile
Frédéric G. MARAND be1f9236e0 Code and findings updated for go 1.27.3.
tl;dr:
- Linux debugging works
- macOS running works, debugging doesn't.
2026-11-02 17:17:20 +01:00

26 lines
924 B
Makefile

# Debug build by default: host and plugins must share the same flags,
# or plugin.Open fails with "plugin was built with a different version of package".
# Use "make FLAGS= clean all" for an optimized build of both.
FLAGS=-gcflags="all=-N -l"
# Every binary depends on the shared package, which defines Worker, and on the
# module files: a change there must rebuild all of them, or stale plugins fail
# to load with the same error as a flags mismatch.
SHARED=main.go go.mod go.sum
.PHONY: all clean
all: cmd/demo plugins/bar/bar.so plugins/foo/foo.so
clean:
rm -fr cmd/demo
find . -name "*.so" -delete
cmd/demo: cmd/demo.go $(SHARED)
go build $(FLAGS) -o cmd/demo ./cmd
plugins/bar/bar.so: plugins/bar/bar.go $(SHARED)
go build -buildmode=plugin $(FLAGS) -o plugins/bar/bar.so ./plugins/bar
plugins/foo/foo.so: plugins/foo/foo.go $(SHARED)
go build -buildmode=plugin $(FLAGS) -o plugins/foo/foo.so ./plugins/foo