Skip to content

Commit e5010da

Browse files
committed
Donate CPU: include wxwidgets/qt if we detect that the project uses those headers
1 parent ccbaad3 commit e5010da

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

tools/donate-cpu.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,29 @@ def unpackPackage(workPath, tgz):
190190
os.chdir(workPath)
191191

192192

193+
def hasInclude(path,inc):
194+
for g in glob.glob(path + '/*'):
195+
if os.path.isfile(g):
196+
f = open(g,'rt')
197+
filedata = f.read()
198+
f.close()
199+
if filedata.find('\n#include ' + inc) >= 0:
200+
return True
201+
elif os.path.isdir(g) and not g.startswith('.'):
202+
if hasInclude(g, inc) is True:
203+
return True
204+
return False
205+
206+
193207
def scanPackage(workPath, cppcheck, jobs):
194208
print('Analyze..')
195209
os.chdir(workPath)
196-
cmd = 'nice ' + cppcheck + ' ' + jobs + ' -D__GCC__ --inconclusive --enable=style --library=posix --platform=unix64 --template=daca2 -rp=temp temp'
210+
libraries = ' --library=posix'
211+
if hasInclude('<wx/string.h>'):
212+
libraries += ' --library=wxwidgets'
213+
if hasInclude('<QString>'):
214+
libraries += ' --library=qt'
215+
cmd = 'nice ' + cppcheck + ' ' + jobs + libraries + ' -D__GCC__ --inconclusive --enable=style --platform=unix64 --template=daca2 -rp=temp temp'
197216
print(cmd)
198217
startTime = time.time()
199218
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)

0 commit comments

Comments
 (0)