-
Notifications
You must be signed in to change notification settings - Fork 32
/
clang_check.py
61 lines (48 loc) · 1.17 KB
/
clang_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"Script for checking that headers can be compiled with clang."
from pathlib import Path
import subprocess
import sys
COMMONFLAGS = [
"-c",
"-fshort-wchar",
"-I", "source",
"-I", "source/platform",
"-nostdinc",
"-target", "ppc-none-eabi",
"-Wall",
"-Wno-unused-private-field",
"-Wextra",
"-Wpedantic",
"-Wno-c99-extensions",
"-Wno-gnu-anonymous-struct",
"-Wno-nested-anon-types",
"-Werror",
]
CFLAGS = COMMONFLAGS + [
"-x", "c",
"-std=c18",
]
CXXFLAGS = COMMONFLAGS + [
"-fno-exceptions",
"-x", "c++",
]
if sys.platform == "win32" or sys.platform == "msys":
DEV_NULL = "NUL"
else:
DEV_NULL = "/dev/null"
def check_headers(extension, flags):
source = ""
for path in Path("source").rglob("*." + extension):
source += "#include \""
source += str(path).removeprefix("source/")
source += "\"\n"
process = subprocess.run(
["clang"] + flags + ["-", "-o", DEV_NULL],
text=True,
input=source,
)
return process.returncode
c_ret = check_headers("h", CFLAGS)
cpp_ret = check_headers("hpp", CXXFLAGS)
if c_ret != 0 or cpp_ret != 0:
sys.exit(1)