From 9ca3d938f723997b5fc97a5f63c6de17fa439434 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Tue, 31 Jan 2017 12:55:21 -0800 Subject: [PATCH] Option to compile gen_snapshot.exe on Windows to target android. (flutter/engine#3379) --- engine/src/flutter/tools/gn | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/tools/gn b/engine/src/flutter/tools/gn index 7984b78fd8..a9178439e6 100755 --- a/engine/src/flutter/tools/gn +++ b/engine/src/flutter/tools/gn @@ -36,6 +36,14 @@ def to_command_line(gn_args): return '%s="%s"' % (key, value) return [merge(x, y) for x, y in gn_args.iteritems()] +def cpu_for_target_arch(arch): + if arch in ['ia32', 'arm', 'armv6', 'armv5te', 'mips', + 'simarm', 'simarmv6', 'simarmv5te', 'simmips', 'simdbc', + 'armsimdbc']: + return 'x86' + if arch in ['x64', 'arm64', 'simarm64', 'simdbc64', 'armsimdbc64']: + return 'x64' + def to_gn_args(args): if args.simulator: if args.target_os == 'android': @@ -59,8 +67,6 @@ def to_gn_args(args): gn_args['android_full_debug'] = args.target_os == 'android' and args.unoptimized gn_args['is_clang'] = not sys.platform.startswith(('cygwin', 'win')) - ios_target_cpu = 'arm64' - aot = args.runtime_mode != 'debug' if args.target_os == 'android': gn_args['target_os'] = 'android' @@ -91,6 +97,13 @@ def to_gn_args(args): if aot: gn_args['dart_target_arch'] = gn_args['target_cpu'] + # No cross-compilation on Windows (for now). + if sys.platform.startswith(('cygwin', 'win')): + if 'target_os' in gn_args: + gn_args['target_os'] = 'win' + if 'target_cpu' in gn_args: + gn_args['target_cpu'] = cpu_for_target_arch(gn_args['target_cpu']) + # On iOS Devices, use the Dart bytecode interpreter so we don't incur # snapshotting and linking costs of the precompiler during development. # We can still use the JIT on the simulator though.