diff options
author | Eric Engestrom <[email protected]> | 2020-06-05 11:49:06 +0200 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-06-05 13:44:18 +0000 |
commit | a874132cc41c2bffc8a547bbd8bc9074653912da (patch) | |
tree | 79d06163aa4cf174e551aeb483d61a890f27b7f1 /src | |
parent | c67ef7695a2577cc3161deb158fa89f1e9dd0fbc (diff) |
intel/genxml: drop sort_xml.sh and move the loop directly in gen_sort_tags.py
Signed-off-by: Eric Engestrom <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5353>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/genxml/README | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | src/intel/genxml/gen_sort_tags.py | 21 | ||||
-rwxr-xr-x | src/intel/genxml/sort_xml.sh | 8 |
3 files changed, 12 insertions, 19 deletions
diff --git a/src/intel/genxml/README b/src/intel/genxml/README index 11ac17ada3a..09a2adec9fc 100644 --- a/src/intel/genxml/README +++ b/src/intel/genxml/README @@ -64,7 +64,7 @@ Keeping genxml files tidy : In order to spot differences easily between generations, we keep genxml files sorted. You can trigger the sort by running : - $ cd src/intel/genxml; ./sort_xml.sh + $ cd src/intel/genxml; ./gen_sort_tags.py gen_sort_tags.py is the script that sorts genxml files using with the following rules : diff --git a/src/intel/genxml/gen_sort_tags.py b/src/intel/genxml/gen_sort_tags.py index 66b1011cef0..8543dabc7a1 100644..100755 --- a/src/intel/genxml/gen_sort_tags.py +++ b/src/intel/genxml/gen_sort_tags.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python #encoding=utf-8 # # Copyright © 2019 Intel Corporation @@ -25,8 +26,8 @@ from __future__ import print_function from collections import OrderedDict import os +import pathlib import re -import sys import xml.etree.cElementTree as et def get_filename(element): @@ -125,12 +126,7 @@ def print_node(f, offset, node): f.write('/>\n') -def main(): - if len(sys.argv) < 2: - print("No input xml file specified") - sys.exit(1) - - filename = sys.argv[1] +def process(filename): xml = et.parse(filename) genxml = xml.getroot() @@ -169,9 +165,14 @@ def main(): genxml[:] = enums + sorted_structs.values() + instructions + registers - print('<?xml version="1.0" ?>') - print_node(sys.stdout, 0, genxml) + with open(filename, 'w') as f: + f.write('<?xml version="1.0" ?>\n') + print_node(f, 0, genxml) if __name__ == '__main__': - main() + folder = pathlib.Path('.') + for f in folder.glob('*.xml'): + print('Processing {}... '.format(f), end='', flush=True) + process(f) + print('done.') diff --git a/src/intel/genxml/sort_xml.sh b/src/intel/genxml/sort_xml.sh deleted file mode 100755 index 48362743b63..00000000000 --- a/src/intel/genxml/sort_xml.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -for i in ./*.xml; do - echo -n "Processing $i... " - python ./gen_sort_tags.py $i > $i.tmp - mv $i.tmp $i - echo "done." -done |