From: Eric Engestrom Date: Thu, 22 Nov 2018 18:44:29 +0000 (+0000) Subject: egl: rewrite entrypoints check X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=commitdiff_plain;h=ba18b968e8745119f66f293a9366c6708c4ed3b8;ds=sidebyside 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 Reviewed-by Dylan Baker Reviewed-by: Emil Velikov --- 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