donate-cpu: fixed library detection (#4261)

This commit is contained in:
Oliver Stöneberg 2022-07-12 19:39:07 +02:00 committed by GitHub
parent 381c38b2f5
commit 1d9b6e1aac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 13 deletions

View File

@ -195,7 +195,8 @@ while True:
if package.find('/qtcreator/') > 0:
# macro_pounder_fn.c is a preprocessor torture test that takes time to finish
skip_files = ('macro_pounder_fn.c',)
if not unpack_package(work_path, tgz, skip_files=skip_files):
source_path, source_found = unpack_package(work_path, tgz, skip_files=skip_files)
if not source_found:
print("No files to process")
continue
crash = False
@ -208,7 +209,7 @@ while True:
head_timing_info = ''
old_timing_info = ''
cppcheck_head_info = ''
libraries = get_libraries()
libraries = get_libraries(source_path)
for ver in cppcheck_versions:
tree_path = os.path.join(work_path, 'tree-'+ver)
@ -217,7 +218,7 @@ while True:
tree_path = os.path.join(work_path, 'tree-main')
cppcheck_head_info = get_cppcheck_info(tree_path)
capture_callstack = True
c, errout, info, t, cppcheck_options, timing_info = scan_package(work_path, tree_path, jobs, libraries, capture_callstack)
c, errout, info, t, cppcheck_options, timing_info = scan_package(work_path, tree_path, source_path, jobs, libraries, capture_callstack)
if c < 0:
if c == -101 and 'error: could not find or open any of the paths given.' in errout:
# No sourcefile found (for example only headers present)

View File

@ -15,7 +15,7 @@ import shlex
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
# changes)
CLIENT_VERSION = "1.3.25"
CLIENT_VERSION = "1.3.26"
# Timeout for analysis with Cppcheck in seconds
CPPCHECK_TIMEOUT = 30 * 60
@ -268,7 +268,7 @@ def unpack_package(work_path, tgz, cpp_only=False, skip_files=None):
pass
except AttributeError:
pass
return found
return temp_path, found
def __has_include(path, includes):
@ -325,7 +325,7 @@ def __run_command(cmd, print_cmd=True):
return return_code, stdout, stderr, elapsed_time
def scan_package(work_path, cppcheck_path, jobs, libraries, capture_callstack=True):
def scan_package(work_path, cppcheck_path, source_path, jobs, libraries, capture_callstack=True):
print('Analyze..')
os.chdir(work_path)
libs = ''
@ -333,7 +333,7 @@ def scan_package(work_path, cppcheck_path, jobs, libraries, capture_callstack=Tr
if os.path.exists(os.path.join(cppcheck_path, 'cfg', library + '.cfg')):
libs += '--library=' + library + ' '
dir_to_scan = 'temp'
dir_to_scan = os.path.basename(source_path)
# Reference for GNU C: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
options = libs + ' --showtime=top5 --check-library --inconclusive --enable=style,information --inline-suppr --template=daca2'
@ -542,7 +542,7 @@ def upload_info(package, info_output, server_address):
return False
def get_libraries():
def get_libraries(folder):
libraries = ['posix', 'gnu']
library_includes = {'boost': ['<boost/'],
'bsd': ['<sys/queue.h>', '<sys/tree.h>', '<sys/uio.h>', '<bsd/', '<fts.h>', '<db.h>', '<err.h>', '<vis.h>'],
@ -578,9 +578,11 @@ def get_libraries():
'wxwidgets': ['<wx/', '"wx/'],
'zlib': ['<zlib.h>'],
}
print('Detecting library usage...')
for library, includes in library_includes.items():
if __has_include('temp', includes):
if __has_include(folder, includes):
libraries.append(library)
print('Found libraries: {}'.format(libraries))
return libraries

View File

@ -119,7 +119,8 @@ if __name__ == "__main__":
print("No package downloaded")
continue
if not lib.unpack_package(work_path, tgz, args.cpp_only):
source_path, source_found = lib.unpack_package(work_path, tgz, args.cpp_only)
if not source_found:
print("No files to process")
continue
@ -131,8 +132,8 @@ if __name__ == "__main__":
main_timeout = False
your_timeout = False
libraries = lib.get_libraries()
c, errout, info, time_main, cppcheck_options, timing_info = lib.scan_package(work_path, main_dir, jobs, libraries)
libraries = lib.get_libraries(source_path)
c, errout, info, time_main, cppcheck_options, timing_info = lib.scan_package(work_path, main_dir, source_path, jobs, libraries)
if c < 0:
if c == -101 and 'error: could not find or open any of the paths given.' in errout:
# No sourcefile found (for example only headers present)
@ -145,7 +146,7 @@ if __name__ == "__main__":
main_crashed = True
results_to_diff.append(errout)
c, errout, info, time_your, cppcheck_options, timing_info = lib.scan_package(work_path, your_repo_dir, jobs, libraries)
c, errout, info, time_your, cppcheck_options, timing_info = lib.scan_package(work_path, your_repo_dir, source_path, jobs, libraries)
if c < 0:
if c == -101 and 'error: could not find or open any of the paths given.' in errout:
# No sourcefile found (for example only headers present)