diff options
| author | van Hauser <vh@thc.org> | 2022-07-08 18:46:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-08 18:46:21 +0200 |
| commit | 9abae56a3729ee4c02ab2db4247df19203fcbe96 (patch) | |
| tree | 7c3bcc90b3d4a27a443b8bc965e56f5a6e6bc7dd /.custom-format.py | |
| parent | b1e0d6e6403c6f7f4796af9603e2b528b9776865 (diff) | |
| parent | 1f17aa082d4ee75c5a034a1ec32025fb828357d2 (diff) | |
| download | afl++-9abae56a3729ee4c02ab2db4247df19203fcbe96.tar.gz | |
Merge pull request #1453 from rhtenhove/dev
improve CI and container image build
Diffstat (limited to '.custom-format.py')
| -rwxr-xr-x | .custom-format.py | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/.custom-format.py b/.custom-format.py index 7ac63396..428d7b0d 100755 --- a/.custom-format.py +++ b/.custom-format.py @@ -19,40 +19,22 @@ import subprocess import sys import os import re +import shutil # string_re = re.compile('(\\"(\\\\.|[^"\\\\])*\\")') # future use with open(".clang-format") as f: fmt = f.read() -CLANG_FORMAT_BIN = os.getenv("CLANG_FORMAT_BIN") -if CLANG_FORMAT_BIN is None: - o = 0 - try: - p = subprocess.Popen(["clang-format-11", "--version"], stdout=subprocess.PIPE) - o, _ = p.communicate() - o = str(o, "utf-8") - o = re.sub(r".*ersion ", "", o) - # o = o[len("clang-format version "):].strip() - o = o[: o.find(".")] - o = int(o) - except: - print("clang-format-11 is needed. Aborted.") - exit(1) - # if o < 7: - # if subprocess.call(['which', 'clang-format-7'], stdout=subprocess.PIPE) == 0: - # CLANG_FORMAT_BIN = 'clang-format-7' - # elif subprocess.call(['which', 'clang-format-8'], stdout=subprocess.PIPE) == 0: - # CLANG_FORMAT_BIN = 'clang-format-8' - # elif subprocess.call(['which', 'clang-format-9'], stdout=subprocess.PIPE) == 0: - # CLANG_FORMAT_BIN = 'clang-format-9' - # elif subprocess.call(['which', 'clang-format-11'], stdout=subprocess.PIPE) == 0: - # CLANG_FORMAT_BIN = 'clang-format-11' - # else: - # print ("clang-format 7 or above is needed. Aborted.") - # exit(1) - else: - CLANG_FORMAT_BIN = "clang-format-11" +CURRENT_LLVM = os.getenv('LLVM_VERSION', 14) +CLANG_FORMAT_BIN = os.getenv("CLANG_FORMAT_BIN", "") + +if shutil.which(CLANG_FORMAT_BIN) is None: + CLANG_FORMAT_BIN = f"clang-format-{CURRENT_LLVM}" + +if shutil.which(CLANG_FORMAT_BIN) is None: + print(f"[!] clang-format-{CURRENT_LLVM} is needed. Aborted.") + exit(1) COLUMN_LIMIT = 80 for line in fmt.split("\n"): |
