From 0ae112ea32acfdb2e633bfaf33c7f254a8a678b9 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 29 Jul 2021 13:29:41 -0400 Subject: [PATCH] Win/Mac: Generate build configs for the native host architecture by default (see issue #2773, see issue #2981) When building on an ARM64 host the ARM64 configs (arm64) will be generated by default and the AMD64 configs (x86,x64) will only be generated if the CEF_ENABLE_AMD64=1 env variable is set. When building on an AMD64 host the AMD64 configs (x86,x64) will be generated by default and the ARM64 configs (arm64) will only be generated if the CEF_ENABLE_ARM64=1 env variable is set. --- tools/gn_args.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/gn_args.py b/tools/gn_args.py index d8accc85d..b79354436 100644 --- a/tools/gn_args.py +++ b/tools/gn_args.py @@ -63,6 +63,7 @@ from __future__ import absolute_import from __future__ import print_function import os +import platform as python_platform import shlex import sys @@ -74,8 +75,12 @@ src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir)) # Determine the platform. if sys.platform == 'win32': platform = 'windows' + # Windows machines report 'ARM64' or 'AMD64'. + machine = 'arm64' if python_platform.machine() == 'ARM64' else 'amd64' elif sys.platform == 'darwin': platform = 'mac' + # Mac machines report 'arm64' or 'x86_64'. + machine = 'arm64' if python_platform.machine() == 'arm64' else 'amd64' elif sys.platform.startswith('linux'): platform = 'linux' else: @@ -553,17 +558,19 @@ def GetAllPlatformConfigs(build_args): % cpu) else: supported_cpus = ['x64'] - elif platform == 'windows': - supported_cpus = ['x86', 'x64'] - if os.environ.get('CEF_ENABLE_ARM64', '') == '1': - supported_cpus.append('arm64') - elif platform == 'mac': - supported_cpus = ['x64'] - if os.environ.get('CEF_ENABLE_ARM64', '') == '1': + elif platform in ('windows', 'mac'): + if machine == 'amd64' or os.environ.get('CEF_ENABLE_AMD64', '') == '1': + supported_cpus.append('x64') + if platform == 'windows': + supported_cpus.append('x86') + if machine == 'arm64' or os.environ.get('CEF_ENABLE_ARM64', '') == '1': supported_cpus.append('arm64') else: raise Exception('Unsupported platform') + if len(supported_cpus) == 0: + raise Exception('No supported architectures') + for cpu in supported_cpus: if create_debug: result['Debug_GN_' + cpu] = GetConfigArgs(args, True, cpu)