2017-11-16 12:18:17 +00:00
|
|
|
#!/usr/bin/python
|
2015-12-10 05:06:13 +02:00
|
|
|
|
2020-08-15 02:50:34 +03:00
|
|
|
import os, re
|
2019-11-26 09:34:53 +00:00
|
|
|
from collections import OrderedDict
|
2015-12-10 05:06:13 +02:00
|
|
|
|
2016-06-18 12:54:10 +00:00
|
|
|
components = {
|
2016-06-27 22:34:42 +00:00
|
|
|
'Core': 'Q_CORE_EXPORT',
|
|
|
|
'Gui': 'Q_GUI_EXPORT',
|
|
|
|
'DBus': 'Q_DBUS_EXPORT',
|
|
|
|
'Network': 'Q_NETWORK_EXPORT',
|
|
|
|
'Svg': 'Q_SVG_EXPORT',
|
|
|
|
'Xml': 'Q_XML_EXPORT',
|
2016-07-17 03:52:15 +00:00
|
|
|
'Test': 'Q_TEST_EXPORT',
|
2016-10-26 15:49:56 +00:00
|
|
|
'UiTools': 'Q_UITOOLS_EXPORT',
|
2016-06-18 12:54:10 +00:00
|
|
|
}
|
2019-11-26 09:34:53 +00:00
|
|
|
classesmap = OrderedDict()
|
2015-12-10 05:06:13 +02:00
|
|
|
|
2017-04-26 13:10:13 +00:00
|
|
|
def exportscan(sdir, pattern, component):
|
2017-04-27 14:53:38 +00:00
|
|
|
regex = re.compile('(?:class|struct) (?:%s) (\w+)' % pattern)
|
2015-12-10 05:06:13 +02:00
|
|
|
for sroot, sdir, lfiles in os.walk(sdir):
|
2019-12-23 01:34:24 +00:00
|
|
|
for sfile in lfiles:
|
2020-01-03 04:24:32 +00:00
|
|
|
if not sfile.endswith('.h') or sfile.endswith('_p.h'):
|
2015-12-10 05:06:13 +02:00
|
|
|
continue
|
|
|
|
sfull = '%s/%s' % (sroot, sfile)
|
|
|
|
with open(sfull, 'rb') as f:
|
|
|
|
scontent = f.read()
|
|
|
|
scontent = scontent.decode('utf-8')
|
2017-04-27 14:53:38 +00:00
|
|
|
for match in regex.findall(scontent):
|
2019-11-26 09:34:53 +00:00
|
|
|
if match in classesmap:
|
2016-08-07 12:20:43 +00:00
|
|
|
continue
|
2019-11-26 09:34:53 +00:00
|
|
|
classesmap[match] = '%s/%s' % (component, sfile)
|
2015-12-10 05:06:13 +02:00
|
|
|
|
2016-06-18 12:54:10 +00:00
|
|
|
for component in components:
|
2019-11-26 09:34:53 +00:00
|
|
|
exportscan('src/%s' % component.lower(), components[component], 'Qt%s' % component)
|
|
|
|
|
|
|
|
print('''static const struct ClassTblData {
|
|
|
|
const QLatin1String klass;
|
|
|
|
const QLatin1String header;
|
|
|
|
} ClassTbl[] = {''')
|
|
|
|
|
|
|
|
for klass in sorted(classesmap.keys()):
|
|
|
|
print(' { QLatin1String("%s"), QLatin1String("%s") },' % (klass, classesmap[klass]))
|
|
|
|
|
|
|
|
|
|
|
|
print('''};
|
|
|
|
static const qint16 ClassTblSize = sizeof(ClassTbl) / sizeof(ClassTblData);''')
|