Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Revert "[gn] Extract target_os, target_cpu resolution" #33231

Merged
merged 1 commit into from
May 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -120,37 +120,6 @@ def can_use_prebuilt_dart(args):
prebuilts_dir = os.path.join(SRC_ROOT, 'flutter', 'prebuilts', prebuilt)
return prebuilts_dir != None and os.path.isdir(prebuilts_dir)


def get_target_cpu(args):
if args.target_os == 'android':
target_cpu = args.android_cpu
elif args.target_os == 'ios':
if args.simulator:
target_cpu = args.simulator_cpu
else:
target_cpu = args.ios_cpu
elif args.target_os == 'mac':
target_cpu = args.mac_cpu
elif args.target_os == 'linux':
target_cpu = args.linux_cpu
elif args.target_os == 'fuchsia':
target_cpu = args.fuchsia_cpu
elif args.target_os == 'wasm':
target_cpu = 'wasm'
elif args.target_os == 'win':
target_cpu = args.windows_cpu
else:
# Building host artifacts
target_cpu = 'x64'

# No cross-compilation on Windows (for now).
# See: https://github.com/flutter/engine/pull/3883
if sys.platform.startswith(('cygwin', 'win')) and args.target_os != 'win':
target_cpu = cpu_for_target_arch(target_cpu)

return target_cpu


def to_gn_args(args):
if args.simulator:
if args.target_os != 'ios':
Expand Down Expand Up @@ -220,14 +189,20 @@ def to_gn_args(args):
# The GN arg is not available in the windows toolchain.
gn_args['enable_lto'] = enable_lto

if args.target_os:
gn_args['target_os'] = args.target_os
gn_args['target_cpu'] = get_target_cpu(args)

if args.target_os == 'ios':
gn_args['use_ios_simulator'] = args.simulator
if args.target_os == 'android':
gn_args['target_os'] = 'android'
elif args.target_os == 'ios':
gn_args['target_os'] = 'ios'
gn_args['use_ios_simulator'] = args.simulator
elif args.target_os == 'mac':
gn_args['use_ios_simulator'] = False
gn_args['target_os'] = 'mac'
gn_args['use_ios_simulator'] = False
elif args.target_os == 'fuchsia':
gn_args['target_os'] = 'fuchsia'
elif args.target_os == 'wasm':
gn_args['target_os'] = 'wasm'
elif args.target_os is not None:
gn_args['target_os'] = args.target_os

if args.dart_debug:
gn_args['dart_debug'] = True
Expand All @@ -236,6 +211,27 @@ def to_gn_args(args):
gn_args['dart_debug'] = True
gn_args['dart_debug_optimization_level'] = '0'

if args.target_os == 'android':
gn_args['target_cpu'] = args.android_cpu
elif args.target_os == 'ios':
if args.simulator:
gn_args['target_cpu'] = args.simulator_cpu
else:
gn_args['target_cpu'] = args.ios_cpu
elif args.target_os == 'mac':
gn_args['target_cpu'] = args.mac_cpu
elif args.target_os == 'linux':
gn_args['target_cpu'] = args.linux_cpu
elif args.target_os == 'fuchsia':
gn_args['target_cpu'] = args.fuchsia_cpu
elif args.target_os == 'wasm':
gn_args['target_cpu'] = 'wasm'
elif args.target_os == 'win':
gn_args['target_cpu'] = args.windows_cpu
else:
# Building host artifacts
gn_args['target_cpu'] = 'x64'

# Flutter-specific arguments which don't apply for a CanvasKit build.
if args.target_os != 'wasm':
gn_args['flutter_use_fontconfig'] = args.enable_fontconfig
Expand Down Expand Up @@ -274,6 +270,10 @@ def to_gn_args(args):
if args.interpreter:
raise Exception('--interpreter is no longer needed on any supported platform.')

if sys.platform.startswith(('cygwin', 'win')) and args.target_os != 'win':
if 'target_cpu' in gn_args:
gn_args['target_cpu'] = cpu_for_target_arch(gn_args['target_cpu'])

if args.target_os is None:
if sys.platform.startswith(('cygwin', 'win')):
gn_args['dart_use_fallback_root_certificates'] = True
Expand Down