summaryrefslogtreecommitdiff
path: root/net-libs/grpc/files/0006-grpc-1.12.1-allow-system-openssl.patch
blob: 61fd830d64d4d5215a48e1484256f1dfa71bdfd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From 30ce693621d61efb8596503a0da212077a8c4daa Mon Sep 17 00:00:00 2001
From: Thomas Bechtold <tbechtold@suse.com>
Date: Thu, 24 May 2018 17:12:13 +0200
Subject: [PATCH] Allow building the python module with system openssl

When building the python module and using the new
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL env variable, the third party
boringssl code is not compiled. Instead, the openssl shared library
installed on the system is used during runtime.
This is useful for distributions who don't want to include code copies
but use shared libraries instead.
---
 setup.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index 99d1a1c504e..3a5ed56c641 100644
--- a/setup.py
+++ b/setup.py
@@ -35,7 +35,7 @@
 PY3 = sys.version_info.major == 3
 PYTHON_STEM = os.path.join('src', 'python', 'grpcio')
 CORE_INCLUDE = ('include', '.',)
-BORINGSSL_INCLUDE = (os.path.join('third_party', 'boringssl', 'include'),)
+SSL_INCLUDE = (os.path.join('third_party', 'boringssl', 'include'),)
 ZLIB_INCLUDE = (os.path.join('third_party', 'zlib'),)
 CARES_INCLUDE = (
     os.path.join('third_party', 'cares'),
@@ -84,6 +84,12 @@
 # present, then it will still attempt to use Cython.
 BUILD_WITH_CYTHON = os.environ.get('GRPC_PYTHON_BUILD_WITH_CYTHON', False)
 
+# Export this variable to use the system installation of openssl. You need to
+# have the header files installed (in /usr/include/openssl) and during
+# runtime, the shared libary must be installed
+BUILD_WITH_SYSTEM_OPENSSL = os.environ.get('GRPC_PYTHON_BUILD_SYSTEM_OPENSSL',
+                                           False)
+
 # Environment variable to determine whether or not to enable coverage analysis
 # in Cython modules.
 ENABLE_CYTHON_TRACING = os.environ.get(
@@ -148,8 +154,13 @@
 if "win32" in sys.platform:
   CORE_C_FILES = filter(lambda x: 'third_party/cares' not in x, CORE_C_FILES)
 
+if BUILD_WITH_SYSTEM_OPENSSL:
+  CORE_C_FILES = filter(lambda x: 'third_party/boringssl' not in x, CORE_C_FILES)
+  CORE_C_FILES = filter(lambda x: 'src/boringssl' not in x, CORE_C_FILES)
+  SSL_INCLUDE = (os.path.join('/usr', 'include', 'openssl'),)
+
 EXTENSION_INCLUDE_DIRECTORIES = (
-    (PYTHON_STEM,) + CORE_INCLUDE + BORINGSSL_INCLUDE + ZLIB_INCLUDE +
+    (PYTHON_STEM,) + CORE_INCLUDE + SSL_INCLUDE + ZLIB_INCLUDE +
     CARES_INCLUDE + ADDRESS_SORTING_INCLUDE)
 
 EXTENSION_LIBRARIES = ()
@@ -159,6 +170,8 @@
   EXTENSION_LIBRARIES += ('m',)
 if "win32" in sys.platform:
   EXTENSION_LIBRARIES += ('advapi32', 'ws2_32',)
+if BUILD_WITH_SYSTEM_OPENSSL:
+  EXTENSION_LIBRARIES += ('ssl', 'crypto',)
 
 DEFINE_MACROS = (
     ('OPENSSL_NO_ASM', 1), ('_WIN32_WINNT', 0x600),