SHA256
1
0
forked from pool/Mesa
Mesa/u_0002-intel-genxml-Add-a-untyped-OrderedDict-fallback-for-.patch
Stefan Dirsch 3214aee2ca - python36-buildfix.patch
* src/freedreno/registers/gen_header.py: hopefully fixes aarch64
    build

- u_0001-intel-genxml-Drop-from-__future__-import-annotations.patch
  u_0002-intel-genxml-Add-a-untyped-OrderedDict-fallback-for-.patch
  python36-buildfix.patch
  * fixes build against python 3.6

OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/Mesa?expand=0&rev=1252
2024-01-20 13:49:19 +00:00

79 lines
3.0 KiB
Diff

From 89ede5b851a6a15f85e83278257ee4e3783f6bd2 Mon Sep 17 00:00:00 2001
From: Jordan Justen <jordan.l.justen@intel.com>
Date: Sat, 20 Jan 2024 01:00:56 -0800
Subject: [PATCH 2/2] intel/genxml: Add a untyped OrderedDict fallback for
Python 3.6
typing.OrderedDict was introduced in Python 3.7.2.
Python 3.6 and 3.7 have been deprecated and are no longer supported,
but this seems like an easy enough fallback to include for now.
https://devguide.python.org/versions/
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
---
src/intel/genxml/intel_genxml.py | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/intel/genxml/intel_genxml.py b/src/intel/genxml/intel_genxml.py
index 9388ebecfce..eefd7b44992 100755
--- a/src/intel/genxml/intel_genxml.py
+++ b/src/intel/genxml/intel_genxml.py
@@ -45,10 +45,22 @@ BASE_TYPES = {
FIXED_PATTERN = re.compile(r"(s|u)(\d+)\.(\d+)")
+try:
+ # Python 3.7 and newer should be able to support strong typing for
+ # our OrderedDict usage.
+ def typed_ordered_dict(key_ty, val_ty):
+ return typing.OrderedDict[str, bool]
+ # This will raise an exception on Python 3.6
+ typed_ordered_dict(int, int)
+except Exception:
+ # For Python 3.6 we return an untyped OrderedDict
+ def typed_ordered_dict(key_ty, val_ty):
+ return OrderedDict
+
def is_base_type(name: str) -> bool:
return name in BASE_TYPES or FIXED_PATTERN.match(name) is not None
-def add_struct_refs(items: typing.OrderedDict[str, bool], node: et.Element) -> None:
+def add_struct_refs(items: typed_ordered_dict(str, bool), node: et.Element) -> None:
if node.tag == 'field':
if 'type' in node.attrib and not is_base_type(node.attrib['type']):
t = node.attrib['type']
@@ -64,16 +76,16 @@ class Struct(object):
def __init__(self, xml: et.Element):
self.xml = xml
self.name = xml.attrib['name']
- self.deps: typing.OrderedDict[str, Struct] = OrderedDict()
+ self.deps: typed_ordered_dict(str, Struct) = OrderedDict()
def find_deps(self, struct_dict, enum_dict) -> None:
- deps: typing.OrderedDict[str, bool] = OrderedDict()
+ deps: typed_ordered_dict(str, bool) = OrderedDict()
add_struct_refs(deps, self.xml)
for d in deps.keys():
if d in struct_dict:
self.deps[d] = struct_dict[d]
- def add_xml(self, items: typing.OrderedDict[str, et.Element]) -> None:
+ def add_xml(self, items: typed_ordered_dict(str, et.Element)) -> None:
for d in self.deps.values():
d.add_xml(items)
items[self.name] = self.xml
@@ -151,7 +163,7 @@ def sort_xml(xml: et.ElementTree) -> None:
for ws in wrapped_struct_dict.values():
ws.find_deps(wrapped_struct_dict, enum_dict)
- sorted_structs: typing.OrderedDict[str, et.Element] = OrderedDict()
+ sorted_structs: typed_ordered_dict(str, et.Element) = OrderedDict()
for s in structs:
_s = wrapped_struct_dict[s.attrib['name']]
_s.add_xml(sorted_structs)
--
2.35.3