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

Function build_cppcheck

tools/bisect/bisect_common.py:10–52  ·  view source on GitHub ↗
(bisect_path)

Source from the content-addressed store, hash-verified

8EC_SKIP = 125 # tells bisect to skip this commit since it cannot be tested
9
10def build_cppcheck(bisect_path):
11 commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
12 install_path = os.path.join(bisect_path, commit_hash)
13 cppcheck_path = os.path.join(install_path, 'cppcheck')
14 if os.path.exists(install_path):
15 print('binary for {} already exists'.format(commit_hash))
16 return cppcheck_path
17
18 bisect_repo_dir = os.path.join(bisect_path, 'cppcheck')
19
20 if os.path.exists(os.path.join(bisect_repo_dir, 'cppcheck')):
21 os.remove(os.path.join(bisect_repo_dir, 'cppcheck'))
22
23 # for versions 1.88 and 1.89
24 print('patching Makefile')
25 subprocess.check_call(['sed', '-i', 's/shell python /shell python3 /g', os.path.join(bisect_repo_dir, 'Makefile')])
26
27 # for versions between 2.0 and 2.2
28 print('patching cli/cppcheckexecutor.cpp')
29 subprocess.check_call(['sed', '-i', 's/SIGSTKSZ/32768/g', os.path.join(bisect_repo_dir, 'cli', 'cppcheckexecutor.cpp')])
30
31 # TODO: older versions do not build because of include changes in libstdc++ - check compiler version and try to use an earlier one
32 # TODO: make jobs configurable
33 # TODO: use "make install"?
34 # TODO: use CXXOPTS overrides to workaround compiling issues in older versions
35 print('building {}'.format(commit_hash))
36 # we always need to use CXXFLAGS because we need to support older versions
37 subprocess.check_call(['make', '-C', bisect_repo_dir, '-j6', 'MATCHCOMPILER=yes', 'CXXFLAGS=-O2 -w -pipe', '-s'])
38
39 # TODO: remove folder if installation failed
40 print('installing {}'.format(commit_hash))
41 os.mkdir(install_path)
42 if os.path.exists(os.path.join(bisect_repo_dir, 'cfg')):
43 shutil.copytree(os.path.join(bisect_repo_dir, 'cfg'), os.path.join(install_path, 'cfg'))
44 if os.path.exists(os.path.join(bisect_repo_dir, 'platforms')):
45 shutil.copytree(os.path.join(bisect_repo_dir, 'platforms'), os.path.join(install_path, 'platforms'))
46 shutil.copy(os.path.join(bisect_repo_dir, 'cppcheck'), cppcheck_path)
47
48 # reset the patches so the subsequent checkout works
49 print('resetting repo')
50 subprocess.check_call(['git', 'reset', '--hard'])
51
52 return cppcheck_path

Callers 2

bisect_res.pyFile · 0.85
bisect_hang.pyFile · 0.85

Calls 4

formatMethod · 0.80
joinMethod · 0.45
existsMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected