summaryrefslogtreecommitdiffstats
path: root/src/egl/egl-entrypoint-check.py
blob: 1e876615028aff0dc80c60ff049d5552b6ca4fe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python

import argparse

PREFIX = 'EGL_ENTRYPOINT('
SUFFIX = ')'

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('header')
    args = parser.parse_args()

    with open(args.header) as header:
        lines = header.readlines()

    entrypoints = []
    for line in lines:
        line = line.strip()
        if line.startswith(PREFIX):
            assert line.endswith(SUFFIX)
            entrypoints.append(line[len(PREFIX):-len(SUFFIX)])

    print('Checking EGL API entrypoints are sorted')

    for i, _ in enumerate(entrypoints):
        # Can't compare the first one with the previous
        if i == 0:
            continue
        if entrypoints[i - 1] > entrypoints[i]:
            print('ERROR: ' + entrypoints[i] + ' should come before ' + entrypoints[i - 1])
            exit(1)

    print('All good :)')

if __name__ == '__main__':
    main()