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