FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use gcc on Linux, VS on Windows and CLang in other cases for geninterop by testrunner123 · Pull Request #510 · pythonnet/pythonnet · GitHub

Repository navigation

Closed
1 change: 1 addition & 0 deletions CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL