donate-cpu: fixed library detection (#4261)
This commit is contained in:
parent
381c38b2f5
commit
1d9b6e1aac
|
@ -195,7 +195,8 @@ while True:
|
||||||
if package.find('/qtcreator/') > 0:
|
if package.find('/qtcreator/') > 0:
|
||||||
# macro_pounder_fn.c is a preprocessor torture test that takes time to finish
|
# macro_pounder_fn.c is a preprocessor torture test that takes time to finish
|
||||||
skip_files = ('macro_pounder_fn.c',)
|
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")
|
print("No files to process")
|
||||||
continue
|
continue
|
||||||
crash = False
|
crash = False
|
||||||
|
@ -208,7 +209,7 @@ while True:
|
||||||
head_timing_info = ''
|
head_timing_info = ''
|
||||||
old_timing_info = ''
|
old_timing_info = ''
|
||||||
cppcheck_head_info = ''
|
cppcheck_head_info = ''
|
||||||
libraries = get_libraries()
|
libraries = get_libraries(source_path)
|
||||||
|
|
||||||
for ver in cppcheck_versions:
|
for ver in cppcheck_versions:
|
||||||
tree_path = os.path.join(work_path, 'tree-'+ver)
|
tree_path = os.path.join(work_path, 'tree-'+ver)
|
||||||
|
@ -217,7 +218,7 @@ while True:
|
||||||
tree_path = os.path.join(work_path, 'tree-main')
|
tree_path = os.path.join(work_path, 'tree-main')
|
||||||
cppcheck_head_info = get_cppcheck_info(tree_path)
|
cppcheck_head_info = get_cppcheck_info(tree_path)
|
||||||
capture_callstack = True
|
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 < 0:
|
||||||
if c == -101 and 'error: could not find or open any of the paths given.' in errout:
|
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)
|
# No sourcefile found (for example only headers present)
|
||||||
|
|
|
@ -15,7 +15,7 @@ import shlex
|
||||||
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
|
# 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
|
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
|
||||||
# changes)
|
# changes)
|
||||||
CLIENT_VERSION = "1.3.25"
|
CLIENT_VERSION = "1.3.26"
|
||||||
|
|
||||||
# Timeout for analysis with Cppcheck in seconds
|
# Timeout for analysis with Cppcheck in seconds
|
||||||
CPPCHECK_TIMEOUT = 30 * 60
|
CPPCHECK_TIMEOUT = 30 * 60
|
||||||
|
@ -268,7 +268,7 @@ def unpack_package(work_path, tgz, cpp_only=False, skip_files=None):
|
||||||
pass
|
pass
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
return found
|
return temp_path, found
|
||||||
|
|
||||||
|
|
||||||
def __has_include(path, includes):
|
def __has_include(path, includes):
|
||||||
|
@ -325,7 +325,7 @@ def __run_command(cmd, print_cmd=True):
|
||||||
return return_code, stdout, stderr, elapsed_time
|
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..')
|
print('Analyze..')
|
||||||
os.chdir(work_path)
|
os.chdir(work_path)
|
||||||
libs = ''
|
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')):
|
if os.path.exists(os.path.join(cppcheck_path, 'cfg', library + '.cfg')):
|
||||||
libs += '--library=' + library + ' '
|
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
|
# 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'
|
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
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_libraries():
|
def get_libraries(folder):
|
||||||
libraries = ['posix', 'gnu']
|
libraries = ['posix', 'gnu']
|
||||||
library_includes = {'boost': ['<boost/'],
|
library_includes = {'boost': ['<boost/'],
|
||||||
'bsd': ['<sys/queue.h>', '<sys/tree.h>', '<sys/uio.h>', '<bsd/', '<fts.h>', '<db.h>', '<err.h>', '<vis.h>'],
|
'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/'],
|
'wxwidgets': ['<wx/', '"wx/'],
|
||||||
'zlib': ['<zlib.h>'],
|
'zlib': ['<zlib.h>'],
|
||||||
}
|
}
|
||||||
|
print('Detecting library usage...')
|
||||||
for library, includes in library_includes.items():
|
for library, includes in library_includes.items():
|
||||||
if __has_include('temp', includes):
|
if __has_include(folder, includes):
|
||||||
libraries.append(library)
|
libraries.append(library)
|
||||||
|
print('Found libraries: {}'.format(libraries))
|
||||||
return libraries
|
return libraries
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,8 @@ if __name__ == "__main__":
|
||||||
print("No package downloaded")
|
print("No package downloaded")
|
||||||
continue
|
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")
|
print("No files to process")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -131,8 +132,8 @@ if __name__ == "__main__":
|
||||||
main_timeout = False
|
main_timeout = False
|
||||||
your_timeout = False
|
your_timeout = False
|
||||||
|
|
||||||
libraries = lib.get_libraries()
|
libraries = lib.get_libraries(source_path)
|
||||||
c, errout, info, time_main, cppcheck_options, timing_info = lib.scan_package(work_path, main_dir, jobs, libraries)
|
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 < 0:
|
||||||
if c == -101 and 'error: could not find or open any of the paths given.' in errout:
|
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)
|
# No sourcefile found (for example only headers present)
|
||||||
|
@ -145,7 +146,7 @@ if __name__ == "__main__":
|
||||||
main_crashed = True
|
main_crashed = True
|
||||||
results_to_diff.append(errout)
|
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 < 0:
|
||||||
if c == -101 and 'error: could not find or open any of the paths given.' in errout:
|
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)
|
# No sourcefile found (for example only headers present)
|
||||||
|
|
Loading…
Reference in New Issue