From f71b32eb8a5c173fc5733847437b9485d75bb2e5 Mon Sep 17 00:00:00 2001
From: Leon Anavi <leon.anavi@konsulko.com>
Date: Fri, 9 Apr 2021 14:06:36 +0300
Subject: [PATCH] setup.py: Fix determining target platform

Do not poke at the build machine to determine target platform or architecture
pass it from environment instead for cross compiling to work

Upstream-Status: Inappropriate [OE-Specific]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
---
 setup.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/setup.py b/setup.py
index c93d419f32..71a944a9d0 100644
--- a/setup.py
+++ b/setup.py
@@ -116,6 +116,9 @@ def _env_bool_value(env_name, default):
 BUILD_WITH_BORING_SSL_ASM = _env_bool_value('GRPC_BUILD_WITH_BORING_SSL_ASM',
                                             'True')
 
+BORING_SSL_PLATFORM = os.environ.get('GRPC_BORING_SSL_PLATFORM',
+                                           'True')
+
 # Export this environment variable to override the platform variant that will
 # be chosen for boringssl assembly optimizations. This option is useful when
 # crosscompiling and the host platform as obtained by distutils.utils.get_platform()
@@ -336,13 +339,13 @@ if BUILD_WITH_BORING_SSL_ASM and not BUILD_WITH_SYSTEM_OPENSSL:
     LINUX_X86_64 = 'linux-x86_64'
     LINUX_ARM = 'linux-arm'
     LINUX_AARCH64 = 'linux-aarch64'
-    if LINUX_X86_64 == boringssl_asm_platform:
+    if LINUX_X86_64 == BORING_SSL_PLATFORM:
         asm_key = 'crypto_linux_x86_64'
-    elif LINUX_ARM == boringssl_asm_platform:
+    elif LINUX_ARM == BORING_SSL_PLATFORM:
         asm_key = 'crypto_linux_arm'
-    elif LINUX_AARCH64 == boringssl_asm_platform:
+    elif LINUX_AARCH64 == BORING_SSL_PLATFORM:
         asm_key = 'crypto_linux_aarch64'
-    elif "mac" in boringssl_asm_platform and "x86_64" in boringssl_asm_platform:
+    elif "mac" in boringssl_asm_platform and "x86_64" in BORING_SSL_PLATFORM:
         asm_key = 'crypto_mac_x86_64'
     else:
         print("ASM Builds for BoringSSL currently not supported on:",
-- 
2.17.1

