From ccb669a05fb47a637357ba5d7322997a7297456e Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 20 May 2026 11:15:16 +0200 Subject: [PATCH] util: add very basic way to validate drirc files This just checks for option names that don't exist. This is something that already happened in the past with RADV. Signed-off-by: Samuel Pitoiset Part-of: --- src/util/drirc_gen.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/util/drirc_gen.py b/src/util/drirc_gen.py index 61a9a0ee7e8..0131ddf64ee 100644 --- a/src/util/drirc_gen.py +++ b/src/util/drirc_gen.py @@ -6,6 +6,7 @@ import argparse import os import re import sys +import xml.etree.ElementTree as ET from enum import Enum from mako.template import Template @@ -193,6 +194,22 @@ ${driver_prefix}_parse_dri_options(struct ${driver_prefix}_drirc *drirc, } """ +def drirc_validate(conf_paths, sections): + declared = {opt.name for section in sections for opt in section.options} + conf_names = set() + for conf_path in conf_paths: + tree = ET.parse(conf_path) + for option in tree.iter('option'): + name = option.get('name') + if name: + conf_names.add(name) + missing = conf_names - declared + if missing: + print('ERROR: options used in conf but not declared:', file=sys.stderr) + for name in sorted(missing): + print(f' {name}', file=sys.stderr) + sys.exit(1) + def drirc_generate(cpath, hpath, driver_prefix, sections): environment = { 'driver_prefix': driver_prefix,