gentoo/dev-python/tpm2-pytss/files/tpm2-pytss-2.3.0-use-CC-enviromental-variable.patch
Christopher Byrne a9f8de59d1
dev-python/tpm2-pytss: Respect CC when preprocessing
Closes: https://bugs.gentoo.org/902001
Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
Closes: https://github.com/gentoo/gentoo/pull/40902
Signed-off-by: Nowa Ammerlaan <nowa@gentoo.org>
2025-04-18 16:16:04 +02:00

55 lines
1.8 KiB
Diff

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")