automoc.py: set proper type prefix for match

This commit is contained in:
Ivailo Monev 2015-05-07 14:52:19 +00:00
parent 7e804f81d8
commit 4aa1acb124

View file

@ -21,16 +21,16 @@ for sroot, ldirs, lfiles in os.walk(directory):
for sfile in lfiles: for sfile in lfiles:
sfull = os.path.join(sroot, sfile) sfull = os.path.join(sroot, sfile)
if sfile.endswith(('.h', '.hh', '.hpp', '.c', '.cc', '.cpp')): if sfile.endswith(('.h', '.hh', '.hpp', '.c', '.cc', '.cpp')):
smatch = re.findall('(\n#include (?:"|<)(.*/)?(.*).moc(?:"|>))', fread(sfull)) lmatch = re.findall('(\n#include (?:"|<)(.*/)?(.*).moc(?:"|>))', fread(sfull))
if smatch and not re.findall('Q_OBJECT', fread(sfull)): if lmatch and not re.findall('Q_OBJECT', fread(sfull)):
print('Adjusting moc inclusion of', sfull) print('Adjusting moc inclusion of', sfull)
for match in smatch: for match in lmatch:
fwrite(sfull, fread(sfull).replace(match[0], \ fwrite(sfull, fread(sfull).replace(match[0], \
'\n#include "%smoc_%s.cpp"' % (match[1], match[2]))) '\n#include "%smoc_%s.cpp"' % (match[1], match[2])))
elif sfile.endswith('CMakeLists.txt'): elif sfile.endswith('CMakeLists.txt'):
smatch = re.findall('(automoc4_add_library)', fread(sfull)) lmatch = re.findall('(automoc4_add_library)', fread(sfull))
if smatch: if lmatch:
print('Adjusting automoc4_add_library of', sfull) print('Adjusting automoc4_add_library of', sfull)
fwrite(sfull, fread(sfull).replace('\nautomoc4_add_library', '\nadd_library')) fwrite(sfull, fread(sfull).replace('\nautomoc4_add_library', '\nadd_library'))