Skip to content

Commit

Permalink
egl: rewrite entrypoints check
Browse files Browse the repository at this point in the history
Part of the effort to replace shell scripts with portable python scripts.
I could've used a trivial `assert lines == sorted(lines)`, but this way
the caller is shown which entrypoint is out of order.

Signed-off-by: Eric Engestrom <[email protected]>
Reviewed-by Dylan Baker <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
  • Loading branch information
1ace committed Jul 10, 2019
1 parent b619f89 commit ba18b96
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
11 changes: 0 additions & 11 deletions src/egl/egl-entrypoint-check

This file was deleted.

36 changes: 36 additions & 0 deletions src/egl/egl-entrypoint-check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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()
4 changes: 2 additions & 2 deletions src/egl/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ if with_tests and prog_nm.found()
suite : ['egl'],
)
test('egl-entrypoint-check',
find_program('egl-entrypoint-check'),
env : ['srcdir=' + meson.current_source_dir()],
prog_python,
args : files('egl-entrypoint-check.py', 'main/eglentrypoint.h'),
suite : ['egl'],
)
endif

0 comments on commit ba18b96

Please sign in to comment.