From 1066ef87e591e66ba16a261edb2322a446c897c2 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 25 Jan 2019 21:41:28 +0100 Subject: [PATCH] donate-cpu.py: Enhance library configuration detection (#1625) Optimize checking of different includes for the same library by using a `list` instead of calling `hasInclude()` several times. Add includes for gtk and qt library detection that were found missing when looking at several daca@home packages. --- tools/donate-cpu.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index c5e808eaf..43f218fb2 100644 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -196,7 +196,7 @@ def unpackPackage(workPath, tgz): os.chdir(workPath) -def hasInclude(path, inc): +def hasInclude(path, includes): for root, _, files in os.walk(path): for name in files: filename = os.path.join(root, name) @@ -210,8 +210,9 @@ def hasInclude(path, inc): # Python3 directly reads the data into a string object that has no decode() pass f.close() - if filedata.find('\n#include ' + inc) >= 0: - return True + for inc in includes: + if filedata.find('\n#include ' + inc) >= 0: + return True except IOError: pass return False @@ -221,15 +222,15 @@ def scanPackage(workPath, cppcheck, jobs): print('Analyze..') os.chdir(workPath) libraries = ' --library=posix' - if hasInclude('temp', ''): + if hasInclude('temp', ['', '', ''): + if hasInclude('temp', ['']): libraries += ' --library=zlib' - if hasInclude('temp', ''): + if hasInclude('temp', ['', '', '