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
|
diff --git a/setup.py b/setup.py
index 0e6208f..eec85ad 100644
--- a/setup.py
+++ b/setup.py
@@ -20,6 +20,14 @@ from textwrap import dedent
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]
+def cpp_path():
+ return os.environ.get("CC", "cc")
+
+
+def cpp_args(args=[]):
+ return ["-E"] + args
+
+
class type_generator(build_ext):
cares = set(
(
@@ -184,7 +192,9 @@ class type_generator(build_ext):
f"unable to find tss2_tpm2_types.h in {pk['include_dirs']}"
)
pdata = preprocess_file(
- header_path, cpp_args=["-std=c99", "-D__extension__=", "-D__attribute__(x)="]
+ header_path,
+ cpp_path=cpp_path(),
+ cpp_args=cpp_args(["-std=c99", "-D__extension__=", "-D__attribute__(x)="]),
)
parser = c_parser.CParser()
ast = parser.parse(pdata, "tss2_tpm2_types.h")
@@ -204,13 +214,16 @@ class type_generator(build_ext):
if policy_header_path:
pdata = preprocess_file(
policy_header_path,
- cpp_args=[
- "-std=c99",
- "-D__extension__=",
- "-D__attribute__(x)=",
- "-D__float128=long double",
- "-D_FORTIFY_SOURCE=0",
- ],
+ cpp_path=cpp_path(),
+ cpp_args=cpp_args(
+ [
+ "-std=c99",
+ "-D__extension__=",
+ "-D__attribute__(x)=",
+ "-D__float128=long double",
+ "-D_FORTIFY_SOURCE=0",
+ ]
+ ),
)
parser = c_parser.CParser()
past = parser.parse(pdata, "tss2_policy.h")
|