test/data: update host.xkb to match keymap-dump style
[platform/upstream/libxkbcommon.git] / scripts / makeheader
1 #!/usr/bin/env python
2 from __future__ import print_function
3 import re
4 import os
5
6
7 prefix = os.environ.get('X11_HEADERS_PREFIX', '/usr')
8 HEADERS = [
9     prefix + '/include/X11/keysymdef.h',
10     prefix + '/include/X11/XF86keysym.h',
11     prefix + '/include/X11/Sunkeysym.h',
12     prefix + '/include/X11/DECkeysym.h',
13     prefix + '/include/X11/HPkeysym.h',
14 ]
15
16 print('''#ifndef _XKBCOMMON_KEYSYMS_H
17 #define _XKBCOMMON_KEYSYMS_H
18
19 /* This file is autogenerated; please do not commit directly. */
20
21 #define XKB_KEY_NoSymbol                    0x000000  /* Special KeySym */
22 ''')
23 for path in HEADERS:
24     with open(path) as header:
25         for line in header:
26             if '#ifdef' in line or '#ifndef' in line or '#endif' in line:
27                 continue
28
29             # Remove #define _OSF_Keysyms and such.
30             if '#define _' in line:
31                 continue
32
33             # Handle a duplicate definition in HPkeysyms.h which kicks in if
34             # it's not already defined.
35             if 'XK_Ydiaeresis' in line and '0x100000ee' in line:
36                 continue
37
38             line = re.sub(r'#define\s*(\w*)XK_', r'#define XKB_KEY_\1', line)
39
40             print(line, end='')
41 print('\n\n#endif')