Skip to content

Commit 9fdd140

Browse files
committed
Build the ctypes extension differently on Windows, add a patch to bring in the latest version of libffi
1 parent b5efad0 commit 9fdd140

File tree

2 files changed

+8556
-16
lines changed

2 files changed

+8556
-16
lines changed

cmake/extensions/CMakeLists.txt

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,6 @@ add_python_extension(cPickle SOURCES cPickle.c)
1313
add_python_extension(crypt SOURCES cryptmodule.c LIBRARIES crypt)
1414
add_python_extension(cStringIO SOURCES cStringIO.c)
1515
add_python_extension(_csv SOURCES _csv.c)
16-
add_python_extension(_ctypes
17-
SOURCES _ctypes/_ctypes.c
18-
_ctypes/callbacks.c
19-
_ctypes/callproc.c
20-
_ctypes/cfield.c
21-
_ctypes/libffi/src/closures.c
22-
_ctypes/libffi/src/dlmalloc.c
23-
_ctypes/libffi/src/x86/ffi.c
24-
_ctypes/libffi/src/x86/ffi64.c
25-
_ctypes/libffi/src/prep_cif.c
26-
_ctypes/stgdict.c
27-
_ctypes/libffi/src/x86/sysv.S
28-
_ctypes/libffi/src/x86/unix64.S
29-
INCLUDEDIRS ${CMAKE_SOURCE_DIR}/Modules/_ctypes/libffi/src/x86
30-
${CMAKE_SOURCE_DIR}/Modules/_ctypes/libffi/include
31-
)
3216
add_python_extension(_ctypes_test SOURCES _ctypes/_ctypes_test.c)
3317
add_python_extension(datetime SOURCES datetimemodule.c timemodule.c LIBRARIES m)
3418
add_python_extension(_functools SOURCES _functoolsmodule.c)
@@ -116,6 +100,43 @@ else(WIN32)
116100
add_python_extension(_socket SOURCES socketmodule.c)
117101
endif(WIN32)
118102

103+
# ctypes is different on Windows
104+
if(WIN32)
105+
add_python_extension(_ctypes
106+
SOURCES _ctypes/_ctypes.c
107+
_ctypes/callbacks.c
108+
_ctypes/callproc.c
109+
_ctypes/cfield.c
110+
_ctypes/libffi_mingw/closures.c
111+
_ctypes/libffi_mingw/debug.c
112+
_ctypes/libffi_mingw/prep_cif.c
113+
_ctypes/libffi_mingw/raw_api.c
114+
_ctypes/libffi_mingw/x86/ffi.c
115+
_ctypes/libffi_mingw/x86/win32.S
116+
_ctypes/stgdict.c
117+
INCLUDEDIRS ${CMAKE_SOURCE_DIR}/Modules/_ctypes/libffi/src/x86
118+
${CMAKE_SOURCE_DIR}/Modules/_ctypes/libffi/include
119+
DEFINITIONS X86_WIN32
120+
)
121+
else(WIN32)
122+
add_python_extension(_ctypes
123+
SOURCES _ctypes/_ctypes.c
124+
_ctypes/callbacks.c
125+
_ctypes/callproc.c
126+
_ctypes/cfield.c
127+
_ctypes/libffi/src/closures.c
128+
_ctypes/libffi/src/dlmalloc.c
129+
_ctypes/libffi/src/x86/ffi.c
130+
_ctypes/libffi/src/x86/ffi64.c
131+
_ctypes/libffi/src/prep_cif.c
132+
_ctypes/stgdict.c
133+
_ctypes/libffi/src/x86/sysv.S
134+
_ctypes/libffi/src/x86/unix64.S
135+
INCLUDEDIRS ${CMAKE_SOURCE_DIR}/Modules/_ctypes/libffi/src/x86
136+
${CMAKE_SOURCE_DIR}/Modules/_ctypes/libffi/include
137+
)
138+
endif(WIN32)
139+
119140

120141
# Build expat using the system expat if it's installed, otherwise use the
121142
# builtin version.

0 commit comments

Comments
 (0)