[PATCH] libevdev/make-event-names: Fix determinism issue
Filipe Laíns
lains at archlinux.org
Sat Feb 20 14:47:15 UTC 2021
On Sat, 2021-02-20 at 14:41 +0000, Richard Purdie wrote:
> The order of dict values is not deterministic in python leading to differing
> header file generation which results in differing build output for the same
> configuration. Sort to remove this inconsistency and make the output
> reproducible.
>
> Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
>
> ---
> libevdev/make-event-names.py | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libevdev/make-event-names.py b/libevdev/make-event-names.py
> index 88addd7..c973e2a 100755
> --- a/libevdev/make-event-names.py
> +++ b/libevdev/make-event-names.py
> @@ -70,10 +70,10 @@ def print_bits(bits, prefix):
> if not hasattr(bits, prefix):
> return
> print("static const char * const %s_map[%s_MAX + 1] = {" % (prefix,
> prefix.upper()))
> - for val, name in list(getattr(bits, prefix).items()):
> + for val, name in sorted(list(getattr(bits, prefix).items())):
> print(" [%s] = \"%s\"," % (name, name))
> if prefix == "key":
> - for val, name in list(getattr(bits, "btn").items()):
> + for val, name in sorted(list(getattr(bits, "btn").items())):
> print(" [%s] = \"%s\"," % (name, name))
> print("};")
> print("")
> @@ -118,7 +118,7 @@ def print_lookup(bits, prefix):
> if not hasattr(bits, prefix):
> return
>
> - names = list(getattr(bits, prefix).items())
> + names = sorted(list(getattr(bits, prefix).items()))
> if prefix == "btn":
> names = names + btn_additional
>
>
>
>
> _______________________________________________
> Input-tools mailing list
> Input-tools at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/input-tools
Yes, this is correct. You may have success making the builds reproducible by
setting PYTHONHASHSEED=0, but having the entries ordered here is a better
solution.
Reviewed-by: Filipe Laíns <lains at archlinux.org>
Cheers,
Filipe Laíns
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/input-tools/attachments/20210220/aa5c8d95/attachment.sig>
More information about the Input-tools
mailing list