Commit a874132c authored by Eric Engestrom's avatar Eric Engestrom Committed by Marge Bot

intel/genxml: drop sort_xml.sh and move the loop directly in gen_sort_tags.py

Signed-off-by: Eric Engestrom's avatarEric Engestrom <eric@engestrom.ch>
Reviewed-by: Lionel Landwerlin's avatarLionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <!5353>
parent c67ef769
Pipeline #156753 passed with stages
in 10 minutes and 39 seconds
......@@ -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 :
......
#!/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.')
#!/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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment