Path: blob/21.2-virgl/src/egl/egl-entrypoint-check.py
4558 views
#!/usr/bin/env python12import argparse3from generate.eglFunctionList import EGL_FUNCTIONS as GLVND_ENTRYPOINTS456PREFIX = 'EGL_ENTRYPOINT('7SUFFIX = ')'8910# These entrypoints should *not* be in the GLVND entrypoints11GLVND_EXCLUDED_ENTRYPOINTS = [12# EGL_KHR_debug13'eglDebugMessageControlKHR',14'eglQueryDebugKHR',15'eglLabelObjectKHR',16]171819def check_entrypoint_sorted(entrypoints):20print('Checking that EGL API entrypoints are sorted...')2122for i, _ in enumerate(entrypoints):23# Can't compare the first one with the previous24if i == 0:25continue26if entrypoints[i - 1] > entrypoints[i]:27print('ERROR: ' + entrypoints[i] + ' should come before ' + entrypoints[i - 1])28exit(1)2930print('All good :)')313233def check_glvnd_entrypoints(egl_entrypoints, glvnd_entrypoints):34print('Checking the GLVND entrypoints against the plain EGL ones...')35success = True3637for egl_entrypoint in egl_entrypoints:38if egl_entrypoint in GLVND_EXCLUDED_ENTRYPOINTS:39continue40if egl_entrypoint not in glvnd_entrypoints:41print('ERROR: ' + egl_entrypoint + ' is missing from the GLVND entrypoints (src/egl/generate/eglFunctionList.py)')42success = False4344for glvnd_entrypoint in glvnd_entrypoints:45if glvnd_entrypoint not in egl_entrypoints:46print('ERROR: ' + glvnd_entrypoint + ' is missing from the plain EGL entrypoints (src/egl/main/eglentrypoint.h)')47success = False4849for glvnd_entrypoint in GLVND_EXCLUDED_ENTRYPOINTS:50if glvnd_entrypoint in glvnd_entrypoints:51print('ERROR: ' + glvnd_entrypoint + ' is should *not* be in the GLVND entrypoints (src/egl/generate/eglFunctionList.py)')52success = False5354if success:55print('All good :)')56else:57exit(1)585960def main():61parser = argparse.ArgumentParser()62parser.add_argument('header')63args = parser.parse_args()6465with open(args.header) as header:66lines = header.readlines()6768entrypoints = []69for line in lines:70line = line.strip()71if line.startswith(PREFIX):72assert line.endswith(SUFFIX)73entrypoints.append(line[len(PREFIX):-len(SUFFIX)])7475check_entrypoint_sorted(entrypoints)7677glvnd_entrypoints = [x[0] for x in GLVND_ENTRYPOINTS]7879check_glvnd_entrypoints(entrypoints, glvnd_entrypoints)8081if __name__ == '__main__':82main()838485