17ec681f3Smrg#!/usr/bin/env python3
27ec681f3Smrg
37ec681f3Smrgimport argparse
47ec681f3Smrgfrom generate.eglFunctionList import EGL_FUNCTIONS as GLVND_ENTRYPOINTS
57ec681f3Smrg
67ec681f3Smrg
77ec681f3SmrgPREFIX = 'EGL_ENTRYPOINT('
87ec681f3SmrgSUFFIX = ')'
97ec681f3Smrg
107ec681f3Smrg
117ec681f3Smrg# These entrypoints should *not* be in the GLVND entrypoints
127ec681f3SmrgGLVND_EXCLUDED_ENTRYPOINTS = [
137ec681f3Smrg        # EGL_KHR_debug
147ec681f3Smrg        'eglDebugMessageControlKHR',
157ec681f3Smrg        'eglQueryDebugKHR',
167ec681f3Smrg        'eglLabelObjectKHR',
177ec681f3Smrg    ]
187ec681f3Smrg
197ec681f3Smrg
207ec681f3Smrgdef check_entrypoint_sorted(entrypoints):
217ec681f3Smrg    print('Checking that EGL API entrypoints are sorted...')
227ec681f3Smrg
237ec681f3Smrg    for i, _ in enumerate(entrypoints):
247ec681f3Smrg        # Can't compare the first one with the previous
257ec681f3Smrg        if i == 0:
267ec681f3Smrg            continue
277ec681f3Smrg        if entrypoints[i - 1] > entrypoints[i]:
287ec681f3Smrg            print('ERROR: ' + entrypoints[i] + ' should come before ' + entrypoints[i - 1])
297ec681f3Smrg            exit(1)
307ec681f3Smrg
317ec681f3Smrg    print('All good :)')
327ec681f3Smrg
337ec681f3Smrg
347ec681f3Smrgdef check_glvnd_entrypoints(egl_entrypoints, glvnd_entrypoints):
357ec681f3Smrg    print('Checking the GLVND entrypoints against the plain EGL ones...')
367ec681f3Smrg    success = True
377ec681f3Smrg
387ec681f3Smrg    for egl_entrypoint in egl_entrypoints:
397ec681f3Smrg        if egl_entrypoint in GLVND_EXCLUDED_ENTRYPOINTS:
407ec681f3Smrg            continue
417ec681f3Smrg        if egl_entrypoint not in glvnd_entrypoints:
427ec681f3Smrg            print('ERROR: ' + egl_entrypoint + ' is missing from the GLVND entrypoints (src/egl/generate/eglFunctionList.py)')
437ec681f3Smrg            success = False
447ec681f3Smrg
457ec681f3Smrg    for glvnd_entrypoint in glvnd_entrypoints:
467ec681f3Smrg        if glvnd_entrypoint not in egl_entrypoints:
477ec681f3Smrg            print('ERROR: ' + glvnd_entrypoint + ' is missing from the plain EGL entrypoints (src/egl/main/eglentrypoint.h)')
487ec681f3Smrg            success = False
497ec681f3Smrg
507ec681f3Smrg    for glvnd_entrypoint in GLVND_EXCLUDED_ENTRYPOINTS:
517ec681f3Smrg        if glvnd_entrypoint in glvnd_entrypoints:
527ec681f3Smrg            print('ERROR: ' + glvnd_entrypoint + ' is should *not* be in the GLVND entrypoints (src/egl/generate/eglFunctionList.py)')
537ec681f3Smrg            success = False
547ec681f3Smrg
557ec681f3Smrg    if success:
567ec681f3Smrg        print('All good :)')
577ec681f3Smrg    else:
587ec681f3Smrg        exit(1)
597ec681f3Smrg
607ec681f3Smrg
617ec681f3Smrgdef main():
627ec681f3Smrg    parser = argparse.ArgumentParser()
637ec681f3Smrg    parser.add_argument('header')
647ec681f3Smrg    args = parser.parse_args()
657ec681f3Smrg
667ec681f3Smrg    with open(args.header) as header:
677ec681f3Smrg        lines = header.readlines()
687ec681f3Smrg
697ec681f3Smrg    entrypoints = []
707ec681f3Smrg    for line in lines:
717ec681f3Smrg        line = line.strip()
727ec681f3Smrg        if line.startswith(PREFIX):
737ec681f3Smrg            assert line.endswith(SUFFIX)
747ec681f3Smrg            entrypoints.append(line[len(PREFIX):-len(SUFFIX)])
757ec681f3Smrg
767ec681f3Smrg    check_entrypoint_sorted(entrypoints)
777ec681f3Smrg
787ec681f3Smrg    glvnd_entrypoints = [x[0] for x in GLVND_ENTRYPOINTS]
797ec681f3Smrg
807ec681f3Smrg    check_glvnd_entrypoints(entrypoints, glvnd_entrypoints)
817ec681f3Smrg
827ec681f3Smrgif __name__ == '__main__':
837ec681f3Smrg    main()
84