Commit f8fef6e2 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

[ios] Add support for "catalyst" environment to setup-gn.py

Building for "catalyst" environment requires some specific gn settings,
so to facilitate the developers' job, add support for this environment
to //ios/build/tools/setup-gn.py.

Remove support for "fat" build as it is unsupported (since deployment
target was bumped to 11.0+).

Bug: 1138425
Change-Id: Ia40cb9a7b72a70e46b1a938285c0a020ea95f619
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517732
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824378}
parent cceca087
...@@ -24,7 +24,7 @@ except ImportError: ...@@ -24,7 +24,7 @@ except ImportError:
import io import io
SUPPORTED_TARGETS = ('iphoneos', 'iphonesimulator') SUPPORTED_TARGETS = ('iphoneos', 'iphonesimulator', 'maccatalyst')
SUPPORTED_CONFIGS = ('Debug', 'Release', 'Profile', 'Official', 'Coverage') SUPPORTED_CONFIGS = ('Debug', 'Release', 'Profile', 'Official', 'Coverage')
...@@ -62,19 +62,15 @@ class GnGenerator(object): ...@@ -62,19 +62,15 @@ class GnGenerator(object):
FAT_BUILD_DEFAULT_ARCH = '64-bit' FAT_BUILD_DEFAULT_ARCH = '64-bit'
TARGET_CPU_VALUES = { TARGET_CPU_VALUES = {
'iphoneos': { 'iphoneos': '"arm64"',
'32-bit': '"arm"', 'iphonesimulator': '"x64"',
'64-bit': '"arm64"', 'maccatalyst': '"x64"',
},
'iphonesimulator': {
'32-bit': '"x86"',
'64-bit': '"x64"',
}
} }
TARGET_ENVIRONMENT_VALUES = { TARGET_ENVIRONMENT_VALUES = {
'iphoneos': '"device"', 'iphoneos': '"device"',
'iphonesimulator': '"simulator"', 'iphonesimulator': '"simulator"',
'maccatalyst': '"catalyst"'
} }
def __init__(self, settings, config, target): def __init__(self, settings, config, target):
...@@ -103,32 +99,36 @@ class GnGenerator(object): ...@@ -103,32 +99,36 @@ class GnGenerator(object):
if goma_dir: if goma_dir:
args.append(('goma_dir', '"%s"' % os.path.expanduser(goma_dir))) args.append(('goma_dir', '"%s"' % os.path.expanduser(goma_dir)))
args.append(('target_os', '"ios"'))
args.append(('is_debug', self._config in ('Debug', 'Coverage'))) args.append(('is_debug', self._config in ('Debug', 'Coverage')))
args.append(('enable_dsyms', self._config in ('Profile', 'Official'))) args.append(('enable_dsyms', self._config in ('Profile', 'Official')))
args.append(('enable_stripping', 'enable_dsyms')) args.append(('enable_stripping', 'enable_dsyms'))
args.append(('is_official_build', self._config == 'Official')) args.append(('is_official_build', self._config == 'Official'))
args.append(('is_chrome_branded', 'is_official_build')) args.append(('is_chrome_branded', 'is_official_build'))
args.append(('use_xcode_clang', False))
args.append(('use_clang_coverage', self._config == 'Coverage')) args.append(('use_clang_coverage', self._config == 'Coverage'))
args.append(('is_component_build', False)) args.append(('is_component_build', False))
if os.environ.get('FORCE_MAC_TOOLCHAIN', '0') == '1': if os.environ.get('FORCE_MAC_TOOLCHAIN', '0') == '1':
args.append(('use_system_xcode', False)) args.append(('use_system_xcode', False))
cpu_values = self.TARGET_CPU_VALUES[self._target] args.append(('target_cpu', self.TARGET_CPU_VALUES[self._target]))
build_arch = self._settings.getstring('build', 'arch')
if build_arch == 'fat':
target_cpu = cpu_values[self.FAT_BUILD_DEFAULT_ARCH]
args.append(('target_cpu', target_cpu))
args.append(('additional_target_cpus',
[cpu for cpu in cpu_values.itervalues() if cpu != target_cpu]))
else:
args.append(('target_cpu', cpu_values[build_arch]))
args.append(( args.append((
'target_environment', 'target_environment',
self.TARGET_ENVIRONMENT_VALUES[self._target])) self.TARGET_ENVIRONMENT_VALUES[self._target]))
if self._target == 'maccatalyst':
# Building for "catalyst" environment has not been open-sourced thus can't
# use ToT clang and need to use Xcode's version instead. This version of
# clang does not generate the same warning as ToT clang, so do not treat
# warnings as errors.
# TODO(crbug.com/1145947): remove once clang ToT supports "macabi".
args.append(('use_xcode_clang', True))
args.append(('treat_warnings_as_errors', False))
# The "catalyst" environment is only supported from iOS 13.0 SDK. Until
# Chrome uses this SDK, it needs to be overridden for "catalyst" builds.
args.append(('ios_deployment_target', '"13.0"'))
# Add user overrides after the other configurations so that they can # Add user overrides after the other configurations so that they can
# refer to them and override them. # refer to them and override them.
args.extend(self._settings.items('gn_args')) args.extend(self._settings.items('gn_args'))
...@@ -153,10 +153,11 @@ class GnGenerator(object): ...@@ -153,10 +153,11 @@ class GnGenerator(object):
stream.write('# to configure settings.\n') stream.write('# to configure settings.\n')
stream.write('\n') stream.write('\n')
if self._settings.has_section('$imports$'): if self._target != 'maccatalyst':
for import_rule in self._settings.values('$imports$'): if self._settings.has_section('$imports$'):
stream.write('import("%s")\n' % import_rule) for import_rule in self._settings.values('$imports$'):
stream.write('\n') stream.write('import("%s")\n' % import_rule)
stream.write('\n')
gn_args = self._GetGnArgs() gn_args = self._GetGnArgs()
for name, value in gn_args: for name, value in gn_args:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment