From: Rob Clark Date: Thu, 23 Jul 2020 22:28:47 +0000 (-0700) Subject: freedreno: make gen_header.py check parent directory X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7de0842d428cb70237ed069f97919c82602932ee;p=mesa.git 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: --- 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