From 89ab715851bd3355184e5c4cf39cb38e0dbcf44f Mon Sep 17 00:00:00 2001 From: Niyas Sait Date: Thu, 22 Jul 2021 16:28:19 +0100 Subject: added support for building cffi on windows on arm machines --- setup.py | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'setup.py') 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() -- cgit v1.2.1