MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / compile_cppcheck

Function compile_cppcheck

tools/donate_cpu_lib.py:203–246  ·  view source on GitHub ↗
(cppcheck_path)

Source from the content-addressed store, hash-verified

201
202
203def compile_cppcheck(cppcheck_path):
204 print('Compiling {}'.format(os.path.basename(cppcheck_path)))
205
206 cppcheck_bin = __get_cppcheck_binary(cppcheck_path)
207 # remove file so interrupted "main" branch compilation is being resumed
208 if os.path.isfile(cppcheck_bin):
209 os.remove(cppcheck_bin)
210
211 try:
212 if __make_cmd == 'msbuild.exe':
213 subprocess.check_call(['python3', os.path.join('tools', 'matchcompiler.py'), '--write-dir', 'lib'], cwd=cppcheck_path)
214 build_env = os.environ
215 # append to cl.exe options - need to omit dash or slash since a dash is being prepended
216 build_env["_CL_"] = __jobs.replace('j', 'MP', 1)
217 # TODO: processes still exhaust all threads of the system
218 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)
219 else:
220 # TODO: use CXXOPTS instead
221 build_cmd = [__make_cmd, __jobs, 'MATCHCOMPILER=yes', 'CXXFLAGS=-O2 -g -w']
222 build_env = os.environ
223 if __make_cmd == 'mingw32-make':
224 # TODO: MinGW will always link even if no changes are present
225 # assume Python is in PATH for now
226 build_env['PYTHON_INTERPRETER'] = 'python3'
227 # TODO: MinGW is not detected by Makefile - so work around it for now
228 build_cmd.append('RDYNAMIC=-lshlwapi')
229 subprocess.check_call(build_cmd, cwd=cppcheck_path, env=build_env)
230 except Exception as e:
231 print('Compilation failed: {}'.format(e))
232 return False
233
234 try:
235 if __make_cmd == 'msbuild.exe':
236 subprocess.check_call([os.path.join(cppcheck_path, 'bin', 'cppcheck.exe'), '--version'], cwd=os.path.join(cppcheck_path, 'bin'))
237 else:
238 subprocess.check_call([os.path.join(cppcheck_path, 'cppcheck'), '--version'], cwd=cppcheck_path)
239 except Exception as e:
240 print('Running Cppcheck failed: {}'.format(e))
241 # remove faulty binary
242 if os.path.isfile(cppcheck_bin):
243 os.remove(cppcheck_bin)
244 return False
245
246 return True
247
248
249def get_cppcheck_versions():

Callers 1

compile_versionFunction · 0.85

Calls 4

__get_cppcheck_binaryFunction · 0.85
formatMethod · 0.80
joinMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected