From 236893ea2814526dc903c3fbba8d4bcc4afe62bc Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 24 Apr 2014 19:31:46 -0500 Subject: expand build_ffi helper function --- cryptography/hazmat/bindings/commoncrypto/binding.py | 11 +++++++++-- cryptography/hazmat/bindings/openssl/binding.py | 12 +++++++++--- cryptography/hazmat/bindings/utils.py | 5 ++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cryptography/hazmat/bindings/commoncrypto/binding.py b/cryptography/hazmat/bindings/commoncrypto/binding.py index 3673ea36..ec98b339 100644 --- a/cryptography/hazmat/bindings/commoncrypto/binding.py +++ b/cryptography/hazmat/bindings/commoncrypto/binding.py @@ -42,8 +42,15 @@ class Binding(object): if cls.ffi is not None and cls.lib is not None: return - cls.ffi, cls.lib = build_ffi(cls._module_prefix, cls._modules, - "", "", []) + cls.ffi, cls.lib = build_ffi( + module_prefix=cls._module_prefix, + modules=cls._modules, + pre_include="", + post_include="", + libraries=[], + extra_compile_args=[], + extra_link_args=[] + ) @classmethod def is_available(cls): diff --git a/cryptography/hazmat/bindings/openssl/binding.py b/cryptography/hazmat/bindings/openssl/binding.py index cc40a108..fab66c7c 100644 --- a/cryptography/hazmat/bindings/openssl/binding.py +++ b/cryptography/hazmat/bindings/openssl/binding.py @@ -97,9 +97,15 @@ class Binding(object): else: # pragma: no cover libraries = ["libeay32", "ssleay32", "advapi32"] - cls.ffi, cls.lib = build_ffi(cls._module_prefix, cls._modules, - _OSX_PRE_INCLUDE, _OSX_POST_INCLUDE, - libraries) + cls.ffi, cls.lib = build_ffi( + module_prefix=cls._module_prefix, + modules=cls._modules, + pre_include=_OSX_PRE_INCLUDE, + post_include=_OSX_POST_INCLUDE, + libraries=libraries, + extra_compile_args=[], + extra_link_args=[] + ) res = cls.lib.Cryptography_add_osrandom_engine() assert res != 0 diff --git a/cryptography/hazmat/bindings/utils.py b/cryptography/hazmat/bindings/utils.py index 318b82bb..9d6956fb 100644 --- a/cryptography/hazmat/bindings/utils.py +++ b/cryptography/hazmat/bindings/utils.py @@ -20,7 +20,8 @@ import sys import cffi -def build_ffi(module_prefix, modules, pre_include, post_include, libraries): +def build_ffi(module_prefix, modules, pre_include, post_include, libraries, + extra_compile_args, extra_link_args): """ Modules listed in ``modules`` should have the following attributes: @@ -75,6 +76,8 @@ def build_ffi(module_prefix, modules, pre_include, post_include, libraries): modulename=_create_modulename(cdef_sources, source, sys.version), libraries=libraries, ext_package="cryptography", + extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, ) for name in modules: -- cgit v1.2.3 From 1f2cf3dac34eb719b83fbe6ce267a3a08369cd64 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 24 Apr 2014 20:27:18 -0500 Subject: set defaults on build_ffi --- cryptography/hazmat/bindings/commoncrypto/binding.py | 5 ----- cryptography/hazmat/bindings/openssl/binding.py | 2 -- cryptography/hazmat/bindings/utils.py | 4 ++-- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/cryptography/hazmat/bindings/commoncrypto/binding.py b/cryptography/hazmat/bindings/commoncrypto/binding.py index ec98b339..144bb099 100644 --- a/cryptography/hazmat/bindings/commoncrypto/binding.py +++ b/cryptography/hazmat/bindings/commoncrypto/binding.py @@ -45,11 +45,6 @@ class Binding(object): cls.ffi, cls.lib = build_ffi( module_prefix=cls._module_prefix, modules=cls._modules, - pre_include="", - post_include="", - libraries=[], - extra_compile_args=[], - extra_link_args=[] ) @classmethod diff --git a/cryptography/hazmat/bindings/openssl/binding.py b/cryptography/hazmat/bindings/openssl/binding.py index fab66c7c..f0ff3275 100644 --- a/cryptography/hazmat/bindings/openssl/binding.py +++ b/cryptography/hazmat/bindings/openssl/binding.py @@ -103,8 +103,6 @@ class Binding(object): pre_include=_OSX_PRE_INCLUDE, post_include=_OSX_POST_INCLUDE, libraries=libraries, - extra_compile_args=[], - extra_link_args=[] ) res = cls.lib.Cryptography_add_osrandom_engine() assert res != 0 diff --git a/cryptography/hazmat/bindings/utils.py b/cryptography/hazmat/bindings/utils.py index 9d6956fb..1c48116e 100644 --- a/cryptography/hazmat/bindings/utils.py +++ b/cryptography/hazmat/bindings/utils.py @@ -20,8 +20,8 @@ import sys import cffi -def build_ffi(module_prefix, modules, pre_include, post_include, libraries, - extra_compile_args, extra_link_args): +def build_ffi(module_prefix, modules, pre_include="", post_include="", + libraries=[], extra_compile_args=[], extra_link_args=[]): """ Modules listed in ``modules`` should have the following attributes: -- cgit v1.2.3