summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorNiyas Sait <niyas.sait@linaro.org>2021-07-22 16:28:19 +0100
committerNiyas Sait <niyas.sait@linaro.org>2021-07-22 16:28:19 +0100
commit89ab715851bd3355184e5c4cf39cb38e0dbcf44f (patch)
treea5d45c7d8c2a7f794f63510a61099d7bcb1cfd65 /setup.py
parent43c204e5428986b234718fe4dce10e7cba0d2ed6 (diff)
downloadcffi-89ab715851bd3355184e5c4cf39cb38e0dbcf44f.tar.gz
added support for building cffi on windows on arm machines
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py43
1 files changed, 21 insertions, 22 deletions
diff --git a/setup.py b/setup.py
index 7fd6388..2e7b6cb 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-import sys, os
+import sys, os, platform
import subprocess
import errno
@@ -123,27 +123,26 @@ def use_homebrew_for_libffi():
os.environ['PKG_CONFIG_PATH'] = (
os.environ.get('PKG_CONFIG_PATH', '') + ':' + pkgconfig)
-
-if sys.platform == 'win32' and uses_msvc():
- COMPILE_LIBFFI = 'c/libffi_msvc' # from the CPython distribution
-else:
- COMPILE_LIBFFI = None
-
-if COMPILE_LIBFFI:
- assert os.path.isdir(COMPILE_LIBFFI), "directory not found!"
- include_dirs[:] = [COMPILE_LIBFFI]
- libraries[:] = []
- _filenames = [filename.lower() for filename in os.listdir(COMPILE_LIBFFI)]
- _filenames = [filename for filename in _filenames
- if filename.endswith('.c')]
- if sys.maxsize > 2**32:
- # 64-bit: unlist win32.c, and add instead win64.obj. If the obj
- # happens to get outdated at some point in the future, you need to
- # rebuild it manually from win64.asm.
- _filenames.remove('win32.c')
- extra_link_args.append(os.path.join(COMPILE_LIBFFI, 'win64.obj'))
- sources.extend(os.path.join(COMPILE_LIBFFI, filename)
- for filename in _filenames)
+if sys.platform == "win32" and uses_msvc():
+ if platform.machine() == "ARM64":
+ include_dirs.append(os.path.join("c/libffi_arm64/include"))
+ library_dirs.append(os.path.join("c/libffi_arm64"))
+ else:
+ COMPILE_LIBFFI = 'c/libffi_x86_x64' # from the CPython distribution
+ assert os.path.isdir(COMPILE_LIBFFI), "directory not found!"
+ include_dirs[:] = [COMPILE_LIBFFI]
+ libraries[:] = []
+ _filenames = [filename.lower() for filename in os.listdir(COMPILE_LIBFFI)]
+ _filenames = [filename for filename in _filenames
+ if filename.endswith('.c')]
+ if sys.maxsize > 2**32:
+ # 64-bit: unlist win32.c, and add instead win64.obj. If the obj
+ # happens to get outdated at some point in the future, you need to
+ # rebuild it manually from win64.asm.
+ _filenames.remove('win32.c')
+ extra_link_args.append(os.path.join(COMPILE_LIBFFI, 'win64.obj'))
+ sources.extend(os.path.join(COMPILE_LIBFFI, filename)
+ for filename in _filenames)
else:
use_pkg_config()
ask_supports_thread()