]> xenbits.xensource.com Git - people/jgross/xen.git/commitdiff
golang/xenlight: standardize generated code comment
authorNick Rosbrook <rosbrookn@gmail.com>
Sun, 11 Oct 2020 23:31:25 +0000 (19:31 -0400)
committerWei Liu <wl@xen.org>
Tue, 13 Oct 2020 13:31:06 +0000 (13:31 +0000)
There is a standard format for generated Go code header comments, as set
by [1]. Modify gengotypes.py to follow this standard, and use the
additional

  // source: <IDL file basename>

convention used by protoc-gen-go.

This change is motivated by the fact that since 41aea82de2, the comment
would include the absolute path to libxl_types.idl, therefore creating
unintended diffs when generating code across different machines. This
approach fixes that problem.

[1] https://github.com/golang/go/issues/13560

Signed-off-by: Nick Rosbrook <rosbrookn@ainfosec.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
tools/golang/xenlight/gengotypes.py
tools/golang/xenlight/helpers.gen.go
tools/golang/xenlight/types.gen.go

index 4ac181ae4786736a8fee85cdd07a04c31cb95007..3e40c3d5dc4215b31438aed9942d2eeed13f68f0 100644 (file)
@@ -731,13 +731,11 @@ if __name__ == '__main__':
         name = b.typename
         builtin_type_names[name] = xenlight_golang_fmt_name(name)
 
-    header_comment="""// DO NOT EDIT.
-//
-// This file is generated by:
-// {0}
-//
+    header_comment="""// Code generated by {}. DO NOT EDIT.
+// source: {}
 
-""".format(' '.join(sys.argv))
+""".format(os.path.basename(sys.argv[0]),
+           ' '.join([os.path.basename(a) for a in sys.argv[1:]]))
 
     xenlight_golang_generate_types(types=types,
                                    comment=header_comment)
index 152c7e8e6b2a3bc939f4f5be5fde59dcb3baaebc..c8605994e7fe5e552f8a21aeea5f034be5424b09 100644 (file)
@@ -1,8 +1,5 @@
-// DO NOT EDIT.
-//
-// This file is generated by:
-// gengotypes.py ../../libxl/libxl_types.idl
-//
+// Code generated by gengotypes.py. DO NOT EDIT.
+// source: libxl_types.idl
 
 package xenlight
 
index 663c1e86b40efb96322917cc486c02dff8d5233c..b4c5df0f2c5cb5666f985cedf507a5ed1b39e735 100644 (file)
@@ -1,8 +1,5 @@
-// DO NOT EDIT.
-//
-// This file is generated by:
-// gengotypes.py ../../libxl/libxl_types.idl
-//
+// Code generated by gengotypes.py. DO NOT EDIT.
+// source: libxl_types.idl
 
 package xenlight