1616# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
1717# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
1818# changes)
19- CLIENT_VERSION = "1.3.49 "
19+ CLIENT_VERSION = "1.4.0 "
2020
2121# Timeout for analysis with Cppcheck in seconds
2222CPPCHECK_TIMEOUT = 30 * 60
@@ -179,11 +179,11 @@ def has_binary(cppcheck_path):
179179 return False
180180
181181
182- def compile_version (cppcheck_path ):
182+ def compile_version (cppcheck_path , build_opts ):
183183 if has_binary (cppcheck_path ):
184184 return True
185185 # Build
186- ret = compile_cppcheck (cppcheck_path )
186+ ret = compile_cppcheck (cppcheck_path , build_opts )
187187 # Clean intermediate build files
188188 if __make_cmd == "msbuild.exe" :
189189 exclude_bin = 'bin'
@@ -196,7 +196,7 @@ def compile_version(cppcheck_path):
196196 return ret
197197
198198
199- def compile_cppcheck (cppcheck_path ):
199+ def compile_cppcheck (cppcheck_path , build_opts ):
200200 print ('Compiling {}' .format (os .path .basename (cppcheck_path )))
201201
202202 cppcheck_bin = __get_cppcheck_binary (cppcheck_path )
@@ -211,9 +211,10 @@ def compile_cppcheck(cppcheck_path):
211211 # append to cl.exe options - need to omit dash or slash since a dash is being prepended
212212 build_env ["_CL_" ] = __jobs .replace ('j' , 'MP' , 1 )
213213 # TODO: processes still exhaust all threads of the system
214- subprocess .check_call ([__make_cmd , '-t:cli' , os .path .join (cppcheck_path , 'cppcheck.sln' ), '/property:Configuration=Release;Platform=x64' ], cwd = cppcheck_path , env = build_env )
214+ build_cmd = [__make_cmd , '-t:cli' , os .path .join (cppcheck_path , 'cppcheck.sln' ), build_opts [__make_cmd ]]
215+ subprocess .check_call (build_cmd , cwd = cppcheck_path , env = build_env )
215216 else :
216- build_cmd = [__make_cmd , __jobs , 'MATCHCOMPILER=yes' , 'CXXFLAGS=-O2 -g -w' ]
217+ build_cmd = [__make_cmd , __jobs , 'MATCHCOMPILER=yes' , 'CXXFLAGS=-O2 -g -w' , build_opts [ __make_cmd ] ]
217218 build_env = os .environ
218219 if __make_cmd == 'mingw32-make' :
219220 # TODO: MinGW will always link even if no changes are present
@@ -241,6 +242,7 @@ def compile_cppcheck(cppcheck_path):
241242 return True
242243
243244
245+ # TODO: deprecate
244246def get_cppcheck_versions ():
245247 print ('Connecting to server to get Cppcheck versions..' )
246248 with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as sock :
@@ -253,6 +255,27 @@ def get_cppcheck_versions():
253255 return versions .decode ('utf-8' ).split ()
254256
255257
258+ def get_cppcheck_options ():
259+ print ('Connecting to server to get Cppcheck options..' )
260+ with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as sock :
261+ sock .connect (__server_address )
262+ sock .send (b'GetCppcheckData\n ' ) # TODO: send version
263+ options = sock .recv (1024 ) # TODO: increase
264+ # TODO: sock.recv() sometimes hangs and returns b'' afterwards
265+ if not options :
266+ raise Exception ('received empty response' )
267+ import json
268+ options_obj = json .loads (options .decode ('utf-8' ))
269+ if not options_obj .v or options_obj .v != 1 :
270+ raise Exception ("received invalid version '{}'" .format (options_obj .v ))
271+ # v1
272+ if options_obj .err is not None :
273+ raise Exception ('server provided error: {}' .format (options_obj .err ))
274+ if options_obj .note is not None :
275+ print ('server provided notice: {}' .format (options_obj .note ))
276+ return options_obj .versions , options_obj .build_opts , options_obj .cppcheck_opts
277+
278+
256279def get_packages_count ():
257280 def __get_packages_count ():
258281 print ('Connecting to server to get count of packages..' )
@@ -431,7 +454,7 @@ def __run_command(cmd, print_cmd=True):
431454 return return_code , stdout , stderr , elapsed_time
432455
433456
434- def scan_package (cppcheck_path , source_path , libraries , capture_callstack = True ):
457+ def scan_package (cppcheck_path , source_path , libraries , cppcheck_opts , capture_callstack = True ):
435458 print ('Analyze..' )
436459 libs = ''
437460 for library in libraries :
@@ -440,12 +463,8 @@ def scan_package(cppcheck_path, source_path, libraries, capture_callstack=True):
440463
441464 dir_to_scan = source_path
442465
443- # TODO: temporarily disabled timing information - use --showtime=top5_summary when next version is released
444- # TODO: remove missingInclude disabling when it no longer is implied by --enable=information
445466 # Reference for GNU C: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
446- options = libs + ' --showtime=none --check-library --inconclusive --enable=style,information --inline-suppr --disable=missingInclude --suppress=unmatchedSuppression --template=daca2'
447- options += ' --debug-warnings --suppress=autoNoType --suppress=valueFlowBailout --suppress=bailoutUninitVar --suppress=symbolDatabaseWarning'
448- options += ' -D__GNUC__ --platform=unix64'
467+ options = libs + cppcheck_opts
449468 options_rp = options + ' -rp={}' .format (dir_to_scan )
450469 if __make_cmd == 'msbuild.exe' :
451470 cppcheck_cmd = os .path .join (cppcheck_path , 'bin' , 'cppcheck.exe' ) + ' ' + options_rp
0 commit comments