[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 01/22] golang/xenlight: generate enum types from IDL



> On Nov 15, 2019, at 7:44 PM, Nick Rosbrook <rosbrookn@xxxxxxxxx> wrote:
> 
> From: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
> 
> Introduce gengotypes.py to generate Go code the from IDL. As a first step,
> implement 'enum' type generation.
> 
> As a result of the newly-generated code, remove the existing, and now
> conflicting definitions in xenlight.go. In the case of the Error type,
> rename the slice 'errors' to 'libxlErrors' so that it does not conflict
> with the standard library package 'errors.' And, negate the values used
> in 'libxlErrors' since the generated error values are negative.
> 
> Signed-off-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
> ---
> Changes in v2:
> - Introduce Makefile targets for code generation
> - Re-generate Go code (includes new libxl_passtrhough enum). 
> - Use *.gen.go naming convention for generated Go files.
> 
> tools/golang/xenlight/Makefile      |  18 +-
> tools/golang/xenlight/gengotypes.py | 109 ++++++++
> tools/golang/xenlight/types.gen.go  | 388 ++++++++++++++++++++++++++++
> tools/golang/xenlight/xenlight.go   | 140 ++--------
> 4 files changed, 535 insertions(+), 120 deletions(-)
> create mode 100644 tools/golang/xenlight/gengotypes.py
> create mode 100644 tools/golang/xenlight/types.gen.go
> 
> diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile
> index 0987305224..681f32c234 100644
> --- a/tools/golang/xenlight/Makefile
> +++ b/tools/golang/xenlight/Makefile
> @@ -7,20 +7,21 @@ GOCODE_DIR ?= $(prefix)/share/gocode/
> GOXL_PKG_DIR = /src/$(XEN_GOCODE_URL)/xenlight/
> GOXL_INSTALL_DIR = $(GOCODE_DIR)$(GOXL_PKG_DIR)
> 
> -# PKGSOURCES: Files which comprise the distributed source package
> -PKGSOURCES = xenlight.go
> -
> GO ?= go
> 
> .PHONY: all
> all: build
> 
> .PHONY: package
> -package: $(XEN_GOPATH)$(GOXL_PKG_DIR)$(PKGSOURCES)
> +package: $(XEN_GOPATH)$(GOXL_PKG_DIR)
> 
> -$(XEN_GOPATH)/src/$(XEN_GOCODE_URL)/xenlight/$(PKGSOURCES): $(PKGSOURCES)
> +$(XEN_GOPATH)/src/$(XEN_GOCODE_URL)/xenlight/: %.gen.go
>       $(INSTALL_DIR) $(XEN_GOPATH)$(GOXL_PKG_DIR)
> -     $(INSTALL_DATA) $(PKGSOURCES) $(XEN_GOPATH)$(GOXL_PKG_DIR)
> +     $(INSTALL_DATA) xenlight.go $(XEN_GOPATH)$(GOXL_PKG_DIR)
> +     $(INSTALL_DATA) types.gen.go $(XEN_GOPATH)$(GOXL_PKG_DIR)
> +
> +%.gen.go: gengotypes.py $(XEN_ROOT)/tools/libxl/libxl_types.idl 
> $(XEN_ROOT)/tools/libxl/idl.py
> +     XEN_ROOT=$(XEN_ROOT) $(PYTHON) gengotypes.py ../../libxl/libxl_types.idl

This seems to always run gengotypes.py and always do the ‘install’ here, 
regardless of whether anything has changed or not.  I think that’s probably 
fine for now, but it might be nice at some point to make it more 
dependency-driven.

That said:

Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.