From 7de0842d428cb70237ed069f97919c82602932ee Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Thu, 23 Jul 2020 15:28:47 -0700 Subject: [PATCH] freedreno: make gen_header.py check parent directory With the next commit, the xml files will be no longer be all in the same directory. But checking up a single directory level to resolve import will be sufficient. Signed-off-by: Rob Clark Part-of: --- src/freedreno/registers/gen_header.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/freedreno/registers/gen_header.py b/src/freedreno/registers/gen_header.py index b8fa8cc0caa..291f7e9d299 100644 --- a/src/freedreno/registers/gen_header.py +++ b/src/freedreno/registers/gen_header.py @@ -332,7 +332,14 @@ class Parser(object): raise self.error(e); def do_parse(self, filename): - file = open(filename, "rb") + try: + file = open(filename, "rb") + except FileNotFoundError as e: + # Look for the file in the parent directory if not + # found in same directory: + path = os.path.dirname(filename) + base = os.path.basename(filename) + file = open(path + "/../" + base, "rb") parser = xml.parsers.expat.ParserCreate() self.stack.append((parser, filename)) parser.StartElementHandler = self.start_element -- 2.30.2