diff options
author | Eric Engestrom <[email protected]> | 2018-11-22 18:44:29 +0000 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2019-07-10 11:27:51 +0000 |
commit | ba18b968e8745119f66f293a9366c6708c4ed3b8 (patch) | |
tree | 710952bb25e0c5539b20d17599347f979b3eb979 /src/egl | |
parent | b619f89e238f0b4b101d9f57a3005f7ec7e70123 (diff) |
egl: rewrite entrypoints check
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]>
Diffstat (limited to 'src/egl')
-rwxr-xr-x | src/egl/egl-entrypoint-check | 11 | ||||
-rw-r--r-- | src/egl/egl-entrypoint-check.py | 36 | ||||
-rw-r--r-- | src/egl/meson.build | 4 |
3 files changed, 38 insertions, 13 deletions
diff --git a/src/egl/egl-entrypoint-check b/src/egl/egl-entrypoint-check deleted file mode 100755 index d6a42722a44..00000000000 --- a/src/egl/egl-entrypoint-check +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -e - -if [ -z "$srcdir" ] -then - srcdir=$(dirname "$0") -fi - -entrypoints=$(grep EGL_ENTRYPOINT "$srcdir"/main/eglentrypoint.h) -sorted=$(LC_ALL=C sort <<< "$entrypoints") -test "$entrypoints" = "$sorted" diff --git a/src/egl/egl-entrypoint-check.py b/src/egl/egl-entrypoint-check.py new file mode 100644 index 00000000000..1e876615028 --- /dev/null +++ b/src/egl/egl-entrypoint-check.py @@ -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() diff --git a/src/egl/meson.build b/src/egl/meson.build index a6b66a06857..019f79ee212 100644 --- a/src/egl/meson.build +++ b/src/egl/meson.build @@ -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 |