From adeaacfa567b32401d3bef848b78d078bf4393ec Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Wed, 24 May 2017 12:49:18 -0700 Subject: allow global suppression of link flags (#3592) CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS will now suppress link flags regardless of platform. Additionally, CRYPTOGRAPHY_WINDOWS_LINK_LEGACY_OPENSSL is now the flag you need if you want to link against < 1.1.0 on windows. --- src/_cffi_src/build_openssl.py | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/_cffi_src/build_openssl.py b/src/_cffi_src/build_openssl.py index 7e8fb34b..853f4488 100644 --- a/src/_cffi_src/build_openssl.py +++ b/src/_cffi_src/build_openssl.py @@ -13,27 +13,22 @@ from _cffi_src.utils import ( def _get_openssl_libraries(platform): + if os.environ.get("CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS", None): + return [] # OpenSSL goes by a different library name on different operating systems. - if platform == "darwin": - return _osx_libraries( - os.environ.get("CRYPTOGRAPHY_OSX_NO_LINK_FLAGS") - ) - elif platform == "win32": - windows_link_openssl110 = os.environ.get( - "CRYPTOGRAPHY_WINDOWS_LINK_OPENSSL110", None + if platform == "win32" and compiler_type() == "msvc": + windows_link_legacy_openssl = os.environ.get( + "CRYPTOGRAPHY_WINDOWS_LINK_LEGACY_OPENSSL", None ) - if compiler_type() == "msvc": - if windows_link_openssl110 is not None: - # Link against the 1.1.0 names - libs = ["libssl", "libcrypto"] - else: - # Link against the 1.0.2 and lower names - libs = ["libeay32", "ssleay32"] + if windows_link_legacy_openssl is None: + # Link against the 1.1.0 names + libs = ["libssl", "libcrypto"] else: - # Support mingw, which behaves unix-like and prefixes "lib" - libs = ["ssl", "crypto"] + # Link against the 1.0.2 and lower names + libs = ["libeay32", "ssleay32"] return libs + ["advapi32", "crypt32", "gdi32", "user32", "ws2_32"] else: + # darwin, linux, mingw all use this path # In some circumstances, the order in which these libs are # specified on the linker command-line is significant; # libssl must come before libcrypto @@ -41,14 +36,6 @@ def _get_openssl_libraries(platform): return ["ssl", "crypto"] -def _osx_libraries(build_static): - # For building statically we don't want to pass the -lssl or -lcrypto flags - if build_static == "1": - return [] - else: - return ["ssl", "crypto"] - - ffi = build_ffi_for_binding( module_name="_openssl", module_prefix="_cffi_src.openssl.", -- cgit v1.2.3