Edit

kc3-lang/libxkbcommon/scripts/makeheader

Branch :

  • Show log

    Commit

  • Author : Ran Benita
    Date : 2017-07-29 14:37:23
    Hash : 0a19267f
    Message : build: move custom targets to scripts/ and remove from makefile These scripts generate source code that is committed to git and hence do not really belong in the build system. A maintainer runs them as needed. Signed-off-by: Ran Benita <ran234@gmail.com>

  • scripts/makeheader
  • #!/usr/bin/env python
    
    from __future__ import print_function
    import re
    
    
    HEADERS = [
        '/usr/include/X11/keysymdef.h',
        '/usr/include/X11/XF86keysym.h',
        '/usr/include/X11/Sunkeysym.h',
        '/usr/include/X11/DECkeysym.h',
        '/usr/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')