Message ID | d8615f72d205b8a818ea397ccbb86f6ade1cd158.1602458773.git.rosbrookn@ainfosec.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | None | expand |
> On Oct 12, 2020, at 12:31 AM, Nick Rosbrook <rosbrookn@gmail.com> wrote: > > 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>
diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py index 4ac181ae47..3e40c3d5dc 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -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) diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go index 152c7e8e6b..c8605994e7 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -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 diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go index 663c1e86b4..b4c5df0f2c 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -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
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> --- tools/golang/xenlight/gengotypes.py | 10 ++++------ tools/golang/xenlight/helpers.gen.go | 7 ++----- tools/golang/xenlight/types.gen.go | 7 ++----- 3 files changed, 8 insertions(+), 16 deletions(-)