| 1 | |
| 2 | import Builder |
| 3 | import glob, os, sys |
| 4 | |
| 5 | class ClangTidy(Builder.Action): |
| 6 | def run(self, env): |
| 7 | sh = env.shell |
| 8 | clang_tidy = env.find_llvm_tool('clang-tidy')[0] |
| 9 | if not clang_tidy: |
| 10 | print("No clang-tidy executable could be found, installing...") |
| 11 | sh.exec("sudo", "apt", "install", "-y", "clang-tidy-9") |
| 12 | clang_tidy = env.find_llvm_tool('clang-tidy')[0] |
| 13 | if not clang_tidy: |
| 14 | print("No clang-tidy executable could be found") |
| 15 | sys.exit(1) |
| 16 | |
| 17 | source_dir = sh.cwd() |
| 18 | build_dir = os.path.join(source_dir, 'build') |
| 19 | sources = [os.path.join(source_dir, file) for file in glob.glob( |
| 20 | 'source/**/*.c') if not ('windows' in file or 'android' in file)] |
| 21 | |
| 22 | return [ |
| 23 | Builder.DownloadDependencies(), |
| 24 | Builder.CMakeBuild(), |
| 25 | Builder.Script([ |
| 26 | [clang_tidy, '-p', build_dir] + sources |
| 27 | ]) |
| 28 | ] |
| 29 |