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 <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6070>
This commit is contained in:
Rob Clark 2020-07-23 15:28:47 -07:00 committed by Marge Bot
parent 05b2783270
commit 7de0842d42
1 changed files with 8 additions and 1 deletions

View File

@ -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