Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
- Added keyword arguments based on C# syntax for calling CPython methods (#461)

### Changed
- geninterop.py uses MSVC on Windows, gcc on Linux and CLang in other cases

### Fixed

Expand Down
2 changes: 2 additions & 0 deletions tools/geninterop/fake_libc_include/basetsd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// for windows
#define __declspec(x)
32 changes: 23 additions & 9 deletions tools/geninterop/geninterop.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,22 @@ def preprocess_python_headers():
include_dirs = [fake_libc_include]

include_py = sysconfig.get_config_var("INCLUDEPY")
if (not (include_py == None)) and sys.platform.startswith('win32'):
include_dirs.append("-I")
include_dirs.append(include_py)

defines = [
"-D", "__attribute__(x)=",
"-D", "__inline__=inline",
"-D", "__asm__=;#pragma asm",
"-D", "__int64=long long"
]

if sys.platform.startswith('win32'):
defines = [
"-D", "__cdecl=",
"-D", "__int64=long long"
]
else:
defines = [
"-D", "__attribute__(x)=",
"-D", "__inline__=inline",
"-D", "__asm__=;#pragma asm",
"-D", "__int64=long long"
]

if hasattr(sys, "abiflags"):
if "d" in sys.abiflags:
Expand All @@ -185,8 +193,14 @@ def preprocess_python_headers():
defines.extend(("-D", "PYTHON_WITH_WIDE_UNICODE"))

python_h = os.path.join(include_py, "Python.h")
cmd = ["clang", "-I"] + include_dirs + defines + ["-E", python_h]

if sys.platform.startswith('linux'):
compiler = "gcc"
elif sys.platform.startswith('win32'):
compiler = "cl.exe"
else:
compiler = "clang"
cmd = [compiler, "-I"] + include_dirs + defines + ["-E", python_h]

# normalize as the parser doesn't like windows line endings.
lines = []
for line in _check_output(cmd).splitlines():
Expand Down