[Libguestfs] [PATCH nbdkit v3 2/2] golang: Compile against the local nbdkit build, not installed.

Richard W.M. Jones rjones at redhat.com
Thu Apr 23 19:13:19 UTC 2020


Compiling nbdkit from source when an older nbdkit is installed would
fail because certain symbols such as .get_ready are not defined in the
(installed) <nbdkit-plugin.h>:

  ../../src/libguestfs.org/nbdkit/nbdkit.go:541:8: plugin.get_ready undefined (type _Ctype_struct_nbdkit_plugin has no field or method get_ready)

Of course we should be compiling against the local
include/nbdkit-plugin.h file.

We don't want to modify the *.go files themselves as they might be
copied into other projects.  Instead we can set PKG_CONFIG_PATH to
point to server/local/nbdkit.pc which will return the correct CFLAGS.

Fixes: commit 1ff44288ae1cf95428283e252edd9474c3fe3b55
Thanks: Dan Berrangé, Eric Blake
---
 plugins/golang/Makefile.am | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/plugins/golang/Makefile.am b/plugins/golang/Makefile.am
index f189184c..10ccea18 100644
--- a/plugins/golang/Makefile.am
+++ b/plugins/golang/Makefile.am
@@ -66,18 +66,21 @@ noinst_DATA = \
 examples/dump-plugin/nbdkit-godump-plugin.so: \
 	    $(plugin_sources) examples/dump-plugin/dumpplugin.go
 	cd examples/dump-plugin && \
+	PKG_CONFIG_PATH="$(abs_builddir)/server/local$${PKG_CONFIG_PATH:-:$$PKG_CONFIG_PATH}" \
 	GOPATH="$(abs_builddir)" \
 	$(GOLANG) build -o nbdkit-godump-plugin.so -buildmode=c-shared
 
 examples/minimal/nbdkit-gominimal-plugin.so: \
 	    $(plugin_sources) examples/minimal/minimal.go
 	cd examples/minimal && \
+	PKG_CONFIG_PATH="$(abs_builddir)/server/local$${PKG_CONFIG_PATH:-:$$PKG_CONFIG_PATH}" \
 	GOPATH="$(abs_builddir)" \
 	$(GOLANG) build -o nbdkit-gominimal-plugin.so -buildmode=c-shared
 
 examples/ramdisk/nbdkit-goramdisk-plugin.so: \
 	    $(plugin_sources) examples/ramdisk/ramdisk.go
 	cd examples/ramdisk && \
+	PKG_CONFIG_PATH="$(abs_builddir)/server/local$${PKG_CONFIG_PATH:-:$$PKG_CONFIG_PATH}" \
 	GOPATH="$(abs_builddir)" \
 	$(GOLANG) build -o nbdkit-goramdisk-plugin.so -buildmode=c-shared
 
@@ -87,6 +90,7 @@ check_DATA = test/nbdkit-gotest-plugin.so
 
 test/nbdkit-gotest-plugin.so: $(plugin_sources) test/test.go
 	cd test && \
+	PKG_CONFIG_PATH="$(abs_builddir)/server/local$${PKG_CONFIG_PATH:-:$$PKG_CONFIG_PATH}" \
 	GOPATH="$(abs_builddir)" \
 	$(GOLANG) build -o nbdkit-gotest-plugin.so -buildmode=c-shared
 
-- 
2.18.2




More information about the Libguestfs mailing list