diff options
| author | Haibo Huang <hhb@google.com> | 2020-09-08 17:10:03 -0700 |
|---|---|---|
| committer | Haibo Huang <hhb@google.com> | 2020-09-10 22:20:42 +0000 |
| commit | bffa8499cb8ce3cc4366055be8fe62d501d6a8e5 (patch) | |
| tree | 648dfaada5799a6227dd5f1af43d89ed8d71d96d /scripts | |
| parent | e4e474780d90ed6166f7113a7464371baa275007 (diff) | |
| download | platform_external_libxkbcommon-master.tar.gz platform_external_libxkbcommon-master.tar.bz2 platform_external_libxkbcommon-master.zip | |
1. Run meson build locally:
meson config -Denable-x11=false -Denable-wayland=false -Denable-docs=false
2. Copy over generated parser.h / parser.c
3. Copy over config.h, and remove defines for not supported functions.
Change-Id: Id7f3c822c1d958fa541685344961507bcfa03b17
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/doxygen-wrapper | 8 | ||||
| -rwxr-xr-x | scripts/makeheader | 41 | ||||
| -rwxr-xr-x | scripts/makekeys | 55 | ||||
| -rw-r--r-- | scripts/meson-junit-report.py | 92 | ||||
| -rwxr-xr-x | scripts/update-keysyms | 6 | ||||
| -rwxr-xr-x | scripts/update-keywords | 4 |
6 files changed, 206 insertions, 0 deletions
diff --git a/scripts/doxygen-wrapper b/scripts/doxygen-wrapper new file mode 100755 index 0000000..baa7b26 --- /dev/null +++ b/scripts/doxygen-wrapper @@ -0,0 +1,8 @@ +#!/bin/sh +# Run doxygen such that the working directory is the source root. +# This is needed for various reasons (e.g. relative references in md files). +# Do not use directly. +DOXYGEN="$1" +DOXYFILE="$2" +ABS_TOP_SRCDIR="$3" +cd "$ABS_TOP_SRCDIR" && exec "$DOXYGEN" "$DOXYFILE" diff --git a/scripts/makeheader b/scripts/makeheader new file mode 100755 index 0000000..600b565 --- /dev/null +++ b/scripts/makeheader @@ -0,0 +1,41 @@ +#!/usr/bin/env python +from __future__ import print_function +import re +import os + + +prefix = os.environ.get('X11_HEADERS_PREFIX', '/usr') +HEADERS = [ + prefix + '/include/X11/keysymdef.h', + prefix + '/include/X11/XF86keysym.h', + prefix + '/include/X11/Sunkeysym.h', + prefix + '/include/X11/DECkeysym.h', + prefix + '/include/X11/HPkeysym.h', +] + +print('''#ifndef _XKBCOMMON_KEYSYMS_H +#define _XKBCOMMON_KEYSYMS_H + +/* This file is autogenerated; please do not commit directly. */ + +#define XKB_KEY_NoSymbol 0x000000 /* Special KeySym */ +''') +for path in HEADERS: + with open(path) as header: + for line in header: + if '#ifdef' in line or '#ifndef' in line or '#endif' in line: + continue + + # Remove #define _OSF_Keysyms and such. + if '#define _' in line: + continue + + # Handle a duplicate definition in HPkeysyms.h which kicks in if + # it's not already defined. + if 'XK_Ydiaeresis' in line and '0x100000ee' in line: + continue + + line = re.sub(r'#define\s*(\w*)XK_', r'#define XKB_KEY_\1', line) + + print(line, end='') +print('\n\n#endif') diff --git a/scripts/makekeys b/scripts/makekeys new file mode 100755 index 0000000..f6a0280 --- /dev/null +++ b/scripts/makekeys @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +import re, sys, itertools + +pattern = re.compile(r'^#define\s+XKB_KEY_(?P<name>\w+)\s+(?P<value>0x[0-9a-fA-F]+)\s') +matches = [pattern.match(line) for line in open(sys.argv[1])] +entries = [(m.group("name"), int(m.group("value"), 16)) for m in matches if m] + +print(''' +/** + * This file comes from libxkbcommon and was generated by makekeys.py + * You can always fetch the latest version from: + * https://raw.github.com/xkbcommon/libxkbcommon/master/src/ks_tables.h + */ +''') + +entry_offsets = {} + +print(''' +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Woverlength-strings" +#endif +static const char *keysym_names = +'''.strip()) +offs = 0 +for (name, _) in sorted(entries, key=lambda e: e[0].lower()): + entry_offsets[name] = offs + print(' "{name}\\0"'.format(name=name)) + offs += len(name) + 1 +print(''' +; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif +'''.strip()) + +print(''' +struct name_keysym { + xkb_keysym_t keysym; + uint32_t offset; +};\n''') + +def print_entries(x): + for (name, value) in x: + print(' {{ 0x{value:08x}, {offs} }}, /* {name} */'.format(offs=entry_offsets[name], value=value, name=name)) + +print('static const struct name_keysym name_to_keysym[] = {') +print_entries(sorted(entries, key=lambda e: e[0].lower())) +print('};\n') + +# *.sort() is stable so we always get the first keysym for duplicate +print('static const struct name_keysym keysym_to_name[] = {') +print_entries(next(g[1]) for g in itertools.groupby(sorted(entries, key=lambda e: e[1]), key=lambda e: e[1])) +print('};') diff --git a/scripts/meson-junit-report.py b/scripts/meson-junit-report.py new file mode 100644 index 0000000..a6cbb0b --- /dev/null +++ b/scripts/meson-junit-report.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 + +import argparse +import json +import sys +import unicodedata +import xml.etree.ElementTree as ET +from datetime import datetime + + +aparser = argparse.ArgumentParser( + description='Convert Meson test log into JUnit report') +aparser.add_argument('--project-name', metavar='NAME', + help='The project name', + default='unknown') +aparser.add_argument('--job-id', metavar='ID', + help='The job ID for the report', + default='Unknown') +aparser.add_argument('--branch', metavar='NAME', + help='Branch of the project being tested', + default='master') +aparser.add_argument('--output', metavar='FILE', + help='The output file, stdout by default', + type=argparse.FileType('w', encoding='UTF-8'), + default=sys.stdout) +aparser.add_argument('infile', metavar='FILE', + help='The input testlog.json, stdin by default', + type=argparse.FileType('r', encoding='UTF-8'), + default=sys.stdin) +args = aparser.parse_args() + +outfile = args.output + +testsuites = ET.Element('testsuites') +testsuites.set('id', '{}/{}'.format(args.job_id, args.branch)) +testsuites.set('package', args.project_name) +testsuites.set('timestamp', datetime.utcnow().isoformat(timespec='minutes')) + +testsuite = ET.SubElement(testsuites, 'testsuite') +testsuite.set('name', args.project_name) + +successes = 0 +failures = 0 +skips = 0 + + +def escape_control_chars(text): + return "".join(c if unicodedata.category(c)[0] != "C" else + "<{:02x}>".format(ord(c)) for c in text) + + +for line in args.infile: + unit = json.loads(line) + + testcase = ET.SubElement(testsuite, 'testcase') + testcase.set('classname', '{}/{}'.format(args.project_name, unit['name'])) + testcase.set('name', unit['name']) + testcase.set('time', str(unit['duration'])) + + stdout = escape_control_chars(unit.get('stdout', '')) + stderr = escape_control_chars(unit.get('stderr', '')) + if stdout: + ET.SubElement(testcase, 'system-out').text = stdout + if stderr: + ET.SubElement(testcase, 'system-out').text = stderr + + result = unit['result'].lower() + if result == 'skip': + skips += 1 + ET.SubElement(testcase, 'skipped') + elif result == 'fail': + failures += 1 + failure = ET.SubElement(testcase, 'failure') + failure.set('message', "{} failed".format(unit['name'])) + failure.text = "### stdout\n{}\n### stderr\n{}\n".format(stdout, + stderr) + else: + successes += 1 + assert unit['returncode'] == 0 + +testsuite.set('tests', str(successes + failures + skips)) +testsuite.set('skipped', str(skips)) +testsuite.set('errors', str(failures)) +testsuite.set('failures', str(failures)) + +print('{}: {} pass, {} fail, {} skip'.format(args.project_name, + successes, + failures, + skips)) + +output = ET.tostring(testsuites, encoding='unicode') +outfile.write(output) diff --git a/scripts/update-keysyms b/scripts/update-keysyms new file mode 100755 index 0000000..3356a35 --- /dev/null +++ b/scripts/update-keysyms @@ -0,0 +1,6 @@ +#!/bin/sh +# Run this to regenerate xkbcommon-keysyms.h from the X11 headers +# defining the keysyms and update the name <-> keysym mapping. +export LC_CTYPE=C +scripts/makeheader > xkbcommon/xkbcommon-keysyms.h +scripts/makekeys xkbcommon/xkbcommon-keysyms.h > src/ks_tables.h diff --git a/scripts/update-keywords b/scripts/update-keywords new file mode 100755 index 0000000..65f0d1f --- /dev/null +++ b/scripts/update-keywords @@ -0,0 +1,4 @@ +#!/bin/sh +# Run this if you add/remove a new keyword to the xkbcomp scanner, +# or just want to regenerate the gperf file. +gperf < src/xkbcomp/keywords.gperf > src/xkbcomp/keywords.c |
