| 1 | |
| 2 | |
| 3 | import Builder |
| 4 | import glob |
| 5 | import os |
| 6 | import sys |
| 7 | |
| 8 | |
| 9 | def run_clang_tidy(env): |
| 10 | sh = env.shell |
| 11 | toolchain = env.toolchain |
| 12 | clang_tidy = Builder.Util.where('clang-tidy') |
| 13 | if not clang_tidy: |
| 14 | clang_tidy = toolchain.find_llvm_tool('clang-tidy')[0] |
| 15 | if not clang_tidy: |
| 16 | print("No clang-tidy executable could be found") |
| 17 | sys.exit(1) |
| 18 | |
| 19 | sources = [os.path.join(env.source_dir, file) |
| 20 | for file in glob.glob('source/**/*.c') + glob.glob('source/*.c') |
| 21 | if not ('windows' in file or 'android' in file)] |
| 22 | |
| 23 | return Builder.Script([ |
| 24 | [clang_tidy, '-p', |
| 25 | os.path.join(env.build_dir, env.project.name)] + sources |
| 26 | ]) |
| 27 | |
| 28 | |
| 29 | class ClangTidy(Builder.Action): |
| 30 | def is_main(self): |
| 31 | return True |
| 32 | |
| 33 | def run(self, env): |
| 34 | return Builder.Script([ |
| 35 | Builder.InstallPackages(['clang-tidy']), |
| 36 | Builder.DownloadDependencies(), |
| 37 | Builder.CMakeBuild(env.project), |
| 38 | run_clang_tidy, |
| 39 | ]) |