(version)
| 37 | |
| 38 | |
| 39 | def find_clang_format(version): |
| 40 | for binary in ( |
| 41 | "clang-format", |
| 42 | f"clang-format-{version}", |
| 43 | f"/opt/clang-format-static/clang-format-{version}", |
| 44 | ): |
| 45 | try: |
| 46 | out = subprocess.check_output([binary, "--version"]) |
| 47 | except FileNotFoundError: |
| 48 | continue |
| 49 | if f"clang-format version {version}." in out.decode("utf-8"): |
| 50 | return binary |
| 51 | print(f"Found no clang-format {version}") |
| 52 | sys.exit(-1) |
| 53 | |
| 54 | |
| 55 | clang_format_bin = find_clang_format(20) |