Skip to contentSkip to conversation

golang/xenlight: remove call to go fmt in gengotypes.py

PATCH In review Nick Rosbrook 3 participants 5 messages Jun 6, 2020 – Jun 8, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 golang/xenlight: remove call to go fmt in gengotypes.py

Since the golang bindings are now set to be re-generated whenever a change is made to tools/libxl/libxl_types.idl, the call to go fmt in gengotypes.py results in a dirty git tree for users without go installed.

As an immediate fix, just remove the call to go fmt from gengotypes.py. While here, make sure the DO NOT EDIT comment and package declaration remain formatted correctly. All other generated code is left un-formatted for now.

---
 tools/golang/xenlight/gengotypes.py  |   22 +-
 tools/golang/xenlight/helpers.gen.go | 7711 ++++++++++++--------------
 tools/golang/xenlight/types.gen.go   | 1708 +++---
 3 files changed, 4420 insertions(+), 5021 deletions(-)
tools/golang/xenlight/gengotypes.py +7 -15
index 2b71aa1ea8..3955f64114 100644
@@ -39,7 +39,7 @@ def xenlight_golang_generate_types(path = None, types = None, comment = None):
     with open(path, 'w') as f:
         if comment is not None:
             f.write(comment)
-        f.write('package xenlight\n')
+        f.write('package xenlight\n\n')
 
         for ty in types:
             (tdef, extras) = xenlight_golang_type_define(ty)
@@ -52,8 +52,6 @@ def xenlight_golang_generate_types(path = None, types = None, comment = None):
                 f.write(extra)
                 f.write('\n')
 
-    go_fmt(path)
-
 def xenlight_golang_type_define(ty = None):
     """
     Generate the Go type definition of ty.
@@ -205,7 +203,7 @@ def xenlight_golang_generate_helpers(path = None, types = None, comment = None):
     with open(path, 'w') as f:
         if comment is not None:
             f.write(comment)
-        f.write('package xenlight\n')
+        f.write('package xenlight\n\n')
         f.write('import (\n"unsafe"\n"errors"\n"fmt"\n)\n')
 
         # Cgo preamble
@@ -240,8 +238,6 @@ def xenlight_golang_generate_helpers(path = None, types = None, comment = None):
             f.write(xenlight_golang_define_to_C(ty))
             f.write('\n')
 
-    go_fmt(path)
-
 def xenlight_golang_define_from_C(ty = None):
     """
     Define the fromC marshaling function for the type
@@ -719,10 +715,6 @@ def xenlight_golang_fmt_name(name, exported = True):
 
     return words[0] + ''.join(x.title() for x in words[1:])
 
-def go_fmt(path):
-    """ Call go fmt on the given path. """
-    os.system('go fmt {}'.format(path))
-
 if __name__ == '__main__':
     idlname = sys.argv[1]
 
@@ -733,12 +725,12 @@ if __name__ == '__main__':
         builtin_type_names[name] = xenlight_golang_fmt_name(name)
 
     header_comment="""// DO NOT EDIT.
-    //
-    // This file is generated by:
-    // {}
-    //
+//
+// This file is generated by:
+// {}
+//
 
-    """.format(' '.join(sys.argv))
+""".format(' '.join(sys.argv))
 
     xenlight_golang_generate_types(types=types,
                                    comment=header_comment)
tools/golang/xenlight/helpers.gen.go +3577 -4134

2,941 lines not on this page · raw message

tools/golang/xenlight/types.gen.go +836 -872

1,708 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.

Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Nick Rosbrook

Since the golang bindings are now set to be re-generated whenever a change is made to tools/libxl/libxl_types.idl, the call to go fmt in gengotypes.py results in a dirty git tree for users without go installed.

Quoted 6 lines

As an immediate fix, just remove the call to go fmt from gengotypes.py. While here, make sure the DO NOT EDIT comment and package declaration remain formatted correctly. All other generated code is left un-formatted for now.

With one note: git complains that the resulting patch introduces loads of trailing whitespace. I went though gengotypes.py and essentially did s/ \n/\n/g. With your permission I’ll fold that (and the resulting patches) into this before checking it in.

-George

#2 lore raw
Quoted 13 lines · George Dunlap
Quoted 13 lines · Nick Rosbrook

Since the golang bindings are now set to be re-generated whenever a change is made to tools/libxl/libxl_types.idl, the call to go fmt in gengotypes.py results in a dirty git tree for users without go installed.

As an immediate fix, just remove the call to go fmt from gengotypes.py. While here, make sure the DO NOT EDIT comment and package declaration remain formatted correctly. All other generated code is left un-formatted for now.

Quoted 5 lines
Quoted 1 line

With one note: git complains that the resulting patch introduces loads of trailing whitespace. I went though gengotypes.py and essentially did s/ \n/\n/g. With your permission I’ll fold that (and the resulting patches) into this before checking it in.

Yes, that's fine. Thank you.

-NR

#3 lore raw
In reply to George Dunlap

CC’ing release manager

Quoted 10 lines · George Dunlap
Quoted 9 lines · Nick Rosbrook

Since the golang bindings are now set to be re-generated whenever a change is made to tools/libxl/libxl_types.idl, the call to go fmt in gengotypes.py results in a dirty git tree for users without go installed.

Quoted 8 lines
Quoted 6 lines

As an immediate fix, just remove the call to go fmt from gengotypes.py. While here, make sure the DO NOT EDIT comment and package declaration remain formatted correctly. All other generated code is left un-formatted for now.

Paul, this is a fix to the build system that only affects the formatting of some generated code. (At the moment, the generated code will look differently depending on whether you have golang installed or not.)

#4 lore raw
Quoted 25 lines

-----Original Message-----
From: George Dunlap <[email protected]>
Sent: 08 June 2020 15:16
To: Nick Rosbrook <[email protected]>
Cc: Xen-devel <[email protected]>; Nick Rosbrook <[email protected]>; Ian Jackson <[email protected]>; Wei Liu <[email protected]>; Paul Durrant <[email protected]>
Subject: Re: [PATCH for-4.14] golang/xenlight: remove call to go fmt in gengotypes.py

CC’ing release manager

Quoted 15 lines · George Dunlap
Quoted 14 lines · Nick Rosbrook

Since the golang bindings are now set to be re-generated whenever a change is made to tools/libxl/libxl_types.idl, the call to go fmt in gengotypes.py results in a dirty git tree for users without go installed.

As an immediate fix, just remove the call to go fmt from gengotypes.py. While here, make sure the DO NOT EDIT comment and package declaration remain formatted correctly. All other generated code is left un-formatted for now.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Paul, this is a fix to the build system that only affects the formatting of some generated code. (At the moment, the generated code will look differently depending on whether you have golang installed or not.)

Ok, that sounds low risk.