()
| 43 | |
| 44 | |
| 45 | def main(): |
| 46 | cppflags = list(CPPFLAGS) |
| 47 | std = os.environ.get("CPYTHON_TEST_CPP_STD", "") |
| 48 | module_name = os.environ["CPYTHON_TEST_EXT_NAME"] |
| 49 | limited = bool(os.environ.get("CPYTHON_TEST_LIMITED", "")) |
| 50 | internal = bool(int(os.environ.get("TEST_INTERNAL_C_API", "0"))) |
| 51 | |
| 52 | cppflags = list(CPPFLAGS) |
| 53 | cppflags.append(f'-DMODULE_NAME={module_name}') |
| 54 | |
| 55 | # Add -std=STD or /std:STD (MSVC) compiler flag |
| 56 | if std: |
| 57 | if support.MS_WINDOWS: |
| 58 | cppflags.append(f'/std:{std}') |
| 59 | else: |
| 60 | cppflags.append(f'-std={std}') |
| 61 | |
| 62 | if limited or (std != 'c++03') and not internal: |
| 63 | # See CPPFLAGS_PEDANTIC docstring |
| 64 | cppflags.extend(CPPFLAGS_PEDANTIC) |
| 65 | |
| 66 | # gh-105776: When "gcc -std=11" is used as the C++ compiler, -std=c11 |
| 67 | # option emits a C++ compiler warning. Remove "-std11" option from the |
| 68 | # CC command. |
| 69 | cmd = (sysconfig.get_config_var('CC') or '') |
| 70 | if cmd is not None: |
| 71 | if support.MS_WINDOWS: |
| 72 | std_prefix = '/std' |
| 73 | else: |
| 74 | std_prefix = '-std' |
| 75 | cmd = shlex.split(cmd) |
| 76 | cmd = [arg for arg in cmd if not arg.startswith(std_prefix)] |
| 77 | cmd = shlex.join(cmd) |
| 78 | # CC env var overrides sysconfig CC variable in setuptools |
| 79 | os.environ['CC'] = cmd |
| 80 | |
| 81 | # Define Py_LIMITED_API macro |
| 82 | if limited: |
| 83 | version = sys.hexversion |
| 84 | cppflags.append(f'-DPy_LIMITED_API={version:#x}') |
| 85 | |
| 86 | if internal: |
| 87 | cppflags.append('-DTEST_INTERNAL_C_API=1') |
| 88 | |
| 89 | extra_cflags = os.environ.get("CPYTHON_TEST_EXTRA_CFLAGS", "") |
| 90 | if extra_cflags: |
| 91 | cppflags.extend(shlex.split(extra_cflags)) |
| 92 | |
| 93 | # On Windows, add PCbuild\amd64\ to include and library directories |
| 94 | include_dirs = [] |
| 95 | library_dirs = [] |
| 96 | if support.MS_WINDOWS: |
| 97 | srcdir = sysconfig.get_config_var('srcdir') |
| 98 | machine = platform.uname().machine |
| 99 | pcbuild = os.path.join(srcdir, 'PCbuild', machine) |
| 100 | if os.path.exists(pcbuild): |
| 101 | # pyconfig.h is generated in PCbuild\amd64\ |
| 102 | include_dirs.append(pcbuild) |
no test coverage detected
searching dependent graphs…