Skip to contentSkip to conversation

build golang tools

PATCH In review Nick Rosbrook 2 participants 4 messages Apr 24, 2020 – Apr 27, 2020

lore
Share & tools
lore
#0 lore raw

v2 cover build golang tools

These patches add support for the golang tools in the build system.

The behavior of configure with respect to the make variable, CONFIG_GOLANG is copied from other components, such as the Ocaml tools. Namely, build the tools by default if the go compiler is found.

Changes in v2:
- Change make variable to CONFIG_GOLANG, and use golang rather than golang_tools to avoid mixing underscores and hyphens in configure flags.

Nick Rosbrook (2):
tools: build golang tools if go compiler is present golang/xenlight: stop tracking generated files

 .gitignore                           |    3 +
 .hgignore                            |    2 +
 config/Tools.mk.in                   |    1 +
 m4/golang.m4                         |    4 +
 tools/Rules.mk                       |    2 -
 tools/configure                      |  138 +
 tools/configure.ac                   |   12 +
 tools/golang/xenlight/Makefile       |    1 +
 tools/golang/xenlight/helpers.gen.go | 4722 --------------------------
 tools/golang/xenlight/types.gen.go   | 1225 -------
 10 files changed, 161 insertions(+), 5949 deletions(-)
 create mode 100644 m4/golang.m4
 delete mode 100644 tools/golang/xenlight/helpers.gen.go
 delete mode 100644 tools/golang/xenlight/types.gen.go
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/2 tools: build golang tools if go compiler is present

By default, if the go compiler is found by the configure script, build the golang tools. If the compiler is not found, and --enable-golang was not explicitly set, do not build to the golang tools.

The corresponding make variable is CONFIG_GOLANG. Remove CONFIG_GOLANG from tools/Rules.mk since the variable is now set by configure in config/Tools.mk.

---
 config/Tools.mk.in |   1 +
 m4/golang.m4       |   4 ++
 tools/Rules.mk     |   2 -
 tools/configure    | 138 +++++++++++++++++++++++++++++++++++++++++++++
 tools/configure.ac |  12 ++++
 5 files changed, 155 insertions(+), 2 deletions(-)
 create mode 100644 m4/golang.m4
config/Tools.mk.in +1 -0
index 189fda1596..23df47af8d 100644
@@ -55,6 +55,7 @@ CONFIG_QEMU_TRAD    := @qemu_traditional@
 CONFIG_QEMU_XEN     := @qemu_xen@
 CONFIG_QEMUU_EXTRA_ARGS:= @EXTRA_QEMUU_CONFIGURE_ARGS@
 CONFIG_LIBNL        := @libnl@
+CONFIG_GOLANG       := @golang@
 
 CONFIG_SYSTEMD      := @systemd@
 SYSTEMD_CFLAGS      := @SYSTEMD_CFLAGS@
m4/golang.m4 new file +4 -0
new file mode 100644
index 0000000000..0b4bd54ce0
@@ -0,0 +1,4 @@
+AC_DEFUN([AC_PROG_GO], [
+    dnl Check for the go compiler
+    AC_CHECK_TOOL([GO],[go],[no])
+])
tools/Rules.mk +0 -2
index 9bac15c8d1..5b8cf748ad 100644
@@ -35,8 +35,6 @@ XENSTORE_XENSTORED ?= y
 debug ?= y
 debug_symbols ?= $(debug)
 
-# Set CONFIG_GOLANG=y in .config (or in make) to build golang
-CONFIG_GOLANG ?= n
 XEN_GOPATH        = $(XEN_ROOT)/tools/golang
 XEN_GOCODE_URL    = golang.xenproject.org
 
tools/configure +138 -0

180 lines not on this page · raw message

tools/configure.ac +12 -0
index ea0272766f..b6f8882be4 100644
@@ -73,6 +73,7 @@ m4_include([../m4/fetcher.m4])
 m4_include([../m4/ax_compare_version.m4])
 m4_include([../m4/paths.m4])
 m4_include([../m4/systemd.m4])
+m4_include([../m4/golang.m4])
 
 AX_XEN_EXPAND_CONFIG()
 
@@ -84,6 +85,7 @@ AX_ARG_DEFAULT_ENABLE([ocamltools], [Disable Ocaml tools])
 AX_ARG_DEFAULT_ENABLE([xsmpolicy], [Disable XSM policy compilation])
 AX_ARG_DEFAULT_DISABLE([ovmf], [Enable OVMF])
 AX_ARG_DEFAULT_ENABLE([seabios], [Disable SeaBIOS])
+AX_ARG_DEFAULT_ENABLE([golang], [Disable Go tools])
 
 AC_ARG_WITH([linux-backend-modules],
     AS_HELP_STRING([--with-linux-backend-modules="mod1 mod2"],
@@ -320,6 +322,16 @@ AS_IF([test "x$ocamltools" = "xy"], [
     ])
 ])
 
+AS_IF([test "x$golang" = "xy"], [
+    AC_PROG_GO
+    AS_IF([test "x$GO" = "xno"], [
+        AS_IF([test "x$enable_golang" =  "xyes"], [
+            AC_MSG_ERROR([Go tools enabled, but missing go compiler])
+        ])
+        golang="n"
+    ])
+])
+
 m4_include([../m4/xenstored.m4])
 AX_XENSTORE_OPTIONS
 AX_XENSTORE_SET
Signature · 1 line
2.17.1
Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] tools: build golang tools if go compiler is present

Quoted 11 lines · Nick Rosbrook

By default, if the go compiler is found by the configure script, build the golang tools. If the compiler is not found, and --enable-golang was not explicitly set, do not build to the golang tools.

The corresponding make variable is CONFIG_GOLANG. Remove CONFIG_GOLANG from tools/Rules.mk since the variable is now set by configure in config/Tools.mk.

LGTM:

#3 lore raw

PATCH v2 2/2 golang/xenlight: stop tracking generated files

In reply to Nick Rosbrook

The generated go files were tracked temporarily while the initial implementation of gengotypes.py was in progress. They can now be removed and ignored by git and hg.

While here, make sure generated files are removed by make clean.

---
 .gitignore                           |    3 +
 .hgignore                            |    2 +
 tools/golang/xenlight/Makefile       |    1 +
 tools/golang/xenlight/helpers.gen.go | 4722 --------------------------
 tools/golang/xenlight/types.gen.go   | 1225 -------
 5 files changed, 6 insertions(+), 5947 deletions(-)
 delete mode 100644 tools/golang/xenlight/helpers.gen.go
 delete mode 100644 tools/golang/xenlight/types.gen.go
.gitignore +3 -0
index 4ca679ddbc..93c11019a2 100644
@@ -405,6 +405,9 @@ tools/xenstore/xenstore-watch
 tools/xl/_paths.h
 tools/xl/xl
 
+tools/golang/src
+tools/golang/*/*.gen.go
+
 docs/txt/misc/*.txt
 docs/txt/man/*.txt
 docs/figs/*.png
.hgignore +2 -0
index 2d41670632..2ec52982e1 100644
@@ -282,6 +282,8 @@
 ^tools/ocaml/test/xtl$
 ^tools/ocaml/test/send_debug_keys$
 ^tools/ocaml/test/list_domains$
+^tools/golang/src$
+^tools/golang/.*/.*\.gen\.go$
 ^tools/autom4te\.cache$
 ^tools/config\.h$
 ^tools/config\.log$
tools/golang/xenlight/Makefile +1 -0
index 753132306a..144c133ced 100644
@@ -49,6 +49,7 @@ install: build
 clean:
 	$(RM) -r $(XEN_GOPATH)$(GOXL_PKG_DIR)
 	$(RM) $(XEN_GOPATH)/pkg/*/$(XEN_GOCODE_URL)/xenlight.a
+	$(RM) *.gen.go
 
 .PHONY: distclean
 distclean: clean
tools/golang/xenlight/helpers.gen.go deleted +0 -4722

2,976 lines not on this page · raw message

tools/golang/xenlight/types.gen.go deleted +0 -1225

1,225 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.1

Part of the diff is not shown here. View the raw message.