katie/scripts/genmap.py
Ivailo Monev aacc761fdb oops, use proper comment tag in class map
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2016-06-19 15:11:00 +00:00

54 lines
2 KiB
Python
Executable file

#!/usr/bin/python2
import sys, os, re
components = {
'core': 'Q_CORE_EXPORT',
'gui': 'Q_GUI_EXPORT',
'dbus': 'Q_DBUS_EXPORT',
'declarative': 'Q_DECLARATIVE_EXPORT',
'designer': 'QDESIGNER_COMPONENTS_EXPORT|QDESIGNER_EXTENSION_EXPORT|QT_FORMEDITOR_EXPORT|QT_PROPERTYEDITOR_EXPORT|QT_SIGNALSLOTEDITOR_EXPORT|QT_OBJECTINSPECTOR_EXPORT|QT_WIDGETBOX_EXPORT|QT_BUDDYEDITOR_EXPORT|QT_TABORDEREDITOR_EXPORT|QT_TASKMENU_EXPORT',
'help': 'QHELP_EXPORT',
'multimedia': 'Q_MULTIMEDIA_EXPORT',
'network': 'Q_NETWORK_EXPORT',
'sql': 'Q_SQL_EXPORT',
'svg': 'Q_SVG_EXPORT',
'xml': 'Q_XML_EXPORT',
'xmlpatterns': 'Q_XMLPATTERNS_EXPORT',
'script': 'Q_SCRIPT_EXPORT',
'scripttools': 'Q_SCRIPTTOOLS_EXPORT',
'test': 'Q_TESTLIB_EXPORT',
'uitools': 'QDESIGNER_UILIB_EXPORT',
'opengl': 'Q_OPENGL_EXPORT',
}
mapoutput = 'src/shared/qclass_lib_map.h'
mapdata = '// Automatically generated by genmap.py, DO NOT EDIT!\n'
mapdata += '#ifndef QT_CLASS_MAP_H\n#define QT_CLASS_MAP_H\n\n'
def exportscan(sdir, keyword, component):
dirmap = ''
for sroot, sdir, lfiles in os.walk(sdir):
for sfile in lfiles:
if not sfile.endswith('.h'):
continue
sfull = '%s/%s' % (sroot, sfile)
with open(sfull, 'rb') as f:
scontent = f.read()
scontent = scontent.decode('utf-8')
for match in re.findall('class (?:%s) (\w+)' % keyword, scontent):
dirmap += 'QT_CLASS_LIB(%s, %s, %s)\n' % (match, component, sfile)
return dirmap
for component in components:
keyword = components[component]
mapdata += exportscan('src/%s' % component, keyword, 'Qt%s' % component.capitalize())
mapdata += '\n#endif\n'
with open(mapoutput, 'r+b') as f:
if f.read() != mapdata:
sys.stdout.write('-- Writing: %s\n' % mapoutput)
if sys.version_info[0] == 3:
f.write(bytes(mapdata, 'utf-8'))
else:
f.write(mapdata)