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

Re: [PATCH v2 1/5] libxl: Generate golang bindings in libxl Makefile


  • To: Ian Jackson <Ian.Jackson@xxxxxxxxxx>
  • From: George Dunlap <George.Dunlap@xxxxxxxxxx>
  • Date: Mon, 8 Jun 2020 11:48:57 +0000
  • Accept-language: en-GB, en-US
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 08 Jun 2020 11:49:03 +0000
  • Ironport-sdr: jx8S19pF7gU8RSm153OO0r/y3tfvB6qlydoqpiSNfHBxxKkgIH5Ff1alKlnvKqAYj4JASJUqI8 095jNkh/T8xk5FGgwhRy8Xbag6lx3moPBQO9twauYo1Vcd9Ti6ZH3zWv+sQ6TyA5ck1w4C6hgk W03OesQT+CBzdBCjhYWTracFMP0EIbncUzVm6YAg2pBHfAhMKVaj1eW1wPdWFfkTU8jPSADfS1 1IhI9CbB80lL2cTn9O29Hlu7U90kqgNz59Du4Nt+MQHtkGRHNUDPj4hLKjbxKAMfCFbIuVcAiZ y5g=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHWM6tS08XNp9FsPk2dfrAVrD4GiajIlOUAgAXuyACAAAkKgA==
  • Thread-topic: [PATCH v2 1/5] libxl: Generate golang bindings in libxl Makefile


> On Jun 8, 2020, at 12:16 PM, Ian Jackson <ian.jackson@xxxxxxxxxx> wrote:
> 
> George Dunlap writes ("Re: [PATCH v2 1/5] libxl: Generate golang bindings in 
> libxl Makefile"):
>> So as written this turns out not to work correctly:  `gengotypes.py` spits 
>> out syntactically valid but unformatted Go code, and then runs `go fmt` on 
>> it to get the right style (including tabs, &c).  But the error code of `go 
>> fmt` isn’t checked; so on a system without go installed, if the build system 
>> decides it needs to re-run `gengotypes.py` for whatever reason, the build 
>> succeeds but the tree ends up “dirtied” with an unformatted version fo the 
>> generated text.
> 
> And `go fmt' overwrites its input file ?

Yes.

> The lost error is due to using `os.system' which does not raise an
> exception.  The python 3 docs for `os.system' say
>  | The subprocess module provides more powerful facilities for
>  | spawning new processes and retrieving their results; using that
>  | module is preferable to using this function. See the Replacing
>  | Older Functions with the subprocess Module section in the
>  | subprocess documentation for some helpful recipes.
> And the recipe suggests
>  | sts = os.system("mycmd" + " myarg")
>  | # becomes
>  | sts = call("mycmd" + " myarg", shell=True)
>  | Notes:
>  | * Calling the program through the shell is usually not required.
> 
> This is not particularly helpful advice because subprocess.call, like
> os.system, does not raise an exception when things go wrong.  But it
> does have a "more realistic example" immediately afterwards which does
> actually check the error code.
> 
> You wanted subprocess.check_call.  IDK which Python versions have
> subprocess.check_call.

Since the golang code generation recipe is now called from libxl/Makefile 
unconditionally, the effect of “fixing” the `go fmt` call in gengotypes.py to 
fail if `go fmt` is not available will be to make golang a required dependency 
for building the tools.  I think it’s rather late in the day to be discussing 
that for 4.14.

Nick has already submitted a patch which simply removes the `go fmt` call, 
leaving the generated code looking very “generated”.  That will do for this 
release.

 -George

 


Rackspace

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