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 <eric.engestrom@intel.com>
This commit is contained in:
Mathieu Bridon 2018-06-27 12:37:38 +02:00 committed by Eric Engestrom
parent d337713ec4
commit fe8a153648
5 changed files with 8 additions and 5 deletions

View file

@ -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
]

View file

@ -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

View file

@ -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))),

View file

@ -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

View file

@ -24,6 +24,7 @@
# Authors:
# Ian Romanick <idr@us.ibm.com>
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 = {}