From: Mathieu Bridon Date: Wed, 27 Jun 2018 10:37:38 +0000 (+0200) Subject: python: Stabilize some script outputs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fe8a153648f98c6dfbb621f31c212253c06f9467;p=mesa.git python: Stabilize some script outputs In Python, dictionaries and sets are unordered, and as a result their is no guarantee that running this script twice will produce the same output. Using ordered dicts and explicitly sorting items makes the build more reproducible, and will make it possible to verify that we're not breaking anything when we move the build scripts to Python 3. Reviewed-by: Eric Engestrom --- diff --git a/src/amd/common/sid_tables.py b/src/amd/common/sid_tables.py index 4e53acefa44..ca90f82535d 100644 --- a/src/amd/common/sid_tables.py +++ b/src/amd/common/sid_tables.py @@ -65,7 +65,7 @@ class StringTable: fragments = [ '"%s\\0" /* %s */' % ( te[0].encode('string_escape'), - ', '.join(str(idx) for idx in te[2]) + ', '.join(str(idx) for idx in sorted(te[2])) ) for te in self.table ] diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py index d6784df004e..847c59dbd89 100644 --- a/src/compiler/nir/nir_algebraic.py +++ b/src/compiler/nir/nir_algebraic.py @@ -25,6 +25,7 @@ from __future__ import print_function import ast +from collections import OrderedDict import itertools import struct import sys @@ -601,7 +602,7 @@ ${pass_name}(nir_shader *shader) class AlgebraicPass(object): def __init__(self, pass_name, transforms): - self.xform_dict = {} + self.xform_dict = OrderedDict() self.pass_name = pass_name error = False diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index db907df8545..2f1cba398f0 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -23,6 +23,7 @@ # Authors: # Jason Ekstrand (jason@jlekstrand.net) +from collections import OrderedDict import nir_algebraic import itertools @@ -628,7 +629,7 @@ optimizations = [ 'options->lower_unpack_snorm_4x8'), ] -invert = {'feq': 'fne', 'fne': 'feq', 'fge': 'flt', 'flt': 'fge' } +invert = OrderedDict([('feq', 'fne'), ('fne', 'feq'), ('fge', 'flt'), ('flt', 'fge')]) for left, right in list(itertools.combinations(invert.keys(), 2)) + zip(invert.keys(), invert.keys()): optimizations.append((('inot', ('ior(is_used_once)', (left, a, b), (right, c, d))), diff --git a/src/mapi/glapi/gen/glX_proto_size.py b/src/mapi/glapi/gen/glX_proto_size.py index e16dbab3e09..8dbb0af86d7 100644 --- a/src/mapi/glapi/gen/glX_proto_size.py +++ b/src/mapi/glapi/gen/glX_proto_size.py @@ -191,7 +191,7 @@ class glx_enum_function(object): print ' switch( e ) {' - for c in self.count: + for c in sorted(self.count): for e in self.count[c]: first = 1 diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index a5320e90a1d..1bab5fee51f 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -24,6 +24,7 @@ # Authors: # Ian Romanick +from collections import OrderedDict from decimal import Decimal import xml.etree.ElementTree as ET import re, sys, string @@ -861,7 +862,7 @@ class gl_item_factory(object): class gl_api(object): def __init__(self, factory): - self.functions_by_name = {} + self.functions_by_name = OrderedDict() self.enums_by_name = {} self.types_by_name = {}