2015-07-16 13:31:11 -07:00
|
|
|
#!/usr/bin/env python
|
2018-11-07 12:24:35 -08:00
|
|
|
# Copyright 2013 The Flutter Authors. All rights reserved.
|
2015-07-16 13:31:11 -07:00
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
import subprocess
|
|
|
|
|
import sys
|
|
|
|
|
import os
|
|
|
|
|
|
2016-08-09 14:14:10 -07:00
|
|
|
SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
2015-07-26 16:03:47 -07:00
|
|
|
|
2015-07-16 13:31:11 -07:00
|
|
|
def get_out_dir(args):
|
2016-05-09 14:58:45 -07:00
|
|
|
if args.target_os is not None:
|
|
|
|
|
target_dir = [args.target_os]
|
|
|
|
|
else:
|
|
|
|
|
target_dir = ['host']
|
|
|
|
|
|
2018-08-10 15:34:41 -07:00
|
|
|
runtime_mode = args.runtime_mode
|
2018-06-05 14:52:52 -07:00
|
|
|
|
2016-05-09 14:58:45 -07:00
|
|
|
target_dir.append(args.runtime_mode)
|
2015-07-23 13:11:11 -07:00
|
|
|
|
|
|
|
|
if args.simulator:
|
2016-05-09 14:58:45 -07:00
|
|
|
target_dir.append('sim')
|
2015-07-23 13:11:11 -07:00
|
|
|
|
2016-05-10 10:57:56 -07:00
|
|
|
if args.unoptimized:
|
|
|
|
|
target_dir.append('unopt')
|
2016-04-15 12:18:57 -07:00
|
|
|
|
2018-06-05 14:52:52 -07:00
|
|
|
if args.target_os != 'ios' and args.interpreter:
|
|
|
|
|
target_dir.append('interpreter')
|
|
|
|
|
|
2016-05-05 14:38:42 -07:00
|
|
|
if args.android_cpu != 'arm':
|
2016-05-09 14:58:45 -07:00
|
|
|
target_dir.append(args.android_cpu)
|
2016-04-08 12:47:09 -07:00
|
|
|
|
2017-09-05 14:46:39 -07:00
|
|
|
if args.ios_cpu != 'arm64':
|
|
|
|
|
target_dir.append(args.ios_cpu)
|
|
|
|
|
|
2017-09-19 14:09:35 -07:00
|
|
|
if args.linux_cpu is not None:
|
|
|
|
|
target_dir.append(args.linux_cpu)
|
|
|
|
|
|
2019-07-30 11:43:09 -07:00
|
|
|
if args.target_os == 'fuchsia' and args.fuchsia_cpu is not None:
|
|
|
|
|
target_dir.append(args.fuchsia_cpu)
|
|
|
|
|
|
2017-04-21 17:05:35 -07:00
|
|
|
if args.enable_vulkan:
|
|
|
|
|
target_dir.append('vulkan')
|
|
|
|
|
|
2019-11-22 16:44:21 -08:00
|
|
|
if args.enable_metal and args.target_os == 'ios':
|
2019-05-11 15:21:26 -07:00
|
|
|
target_dir.append('metal')
|
|
|
|
|
|
2019-02-08 15:15:47 -08:00
|
|
|
return os.path.join(args.out_dir, 'out', '_'.join(target_dir))
|
2015-07-16 13:31:11 -07:00
|
|
|
|
|
|
|
|
def to_command_line(gn_args):
|
|
|
|
|
def merge(key, value):
|
|
|
|
|
if type(value) is bool:
|
2015-07-23 13:11:11 -07:00
|
|
|
return '%s=%s' % (key, 'true' if value else 'false')
|
|
|
|
|
return '%s="%s"' % (key, value)
|
2015-07-16 13:31:11 -07:00
|
|
|
return [merge(x, y) for x, y in gn_args.iteritems()]
|
|
|
|
|
|
2017-01-31 12:55:21 -08:00
|
|
|
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'
|
|
|
|
|
|
2015-07-16 13:31:11 -07:00
|
|
|
def to_gn_args(args):
|
2016-05-09 14:58:45 -07:00
|
|
|
if args.simulator:
|
|
|
|
|
if args.target_os == 'android':
|
|
|
|
|
raise Exception('--simulator is not supported on Android')
|
|
|
|
|
elif args.target_os == 'ios':
|
2016-05-10 10:57:56 -07:00
|
|
|
if args.runtime_mode != 'debug':
|
|
|
|
|
raise Exception('iOS simulator only supports the debug runtime mode')
|
2016-05-09 14:58:45 -07:00
|
|
|
|
2017-01-20 14:37:10 -08:00
|
|
|
if args.target_os != 'android' and args.enable_vulkan:
|
|
|
|
|
raise Exception('--enable-vulkan is only supported on Android')
|
|
|
|
|
|
2018-06-05 14:52:52 -07:00
|
|
|
runtime_mode = args.runtime_mode
|
|
|
|
|
|
2015-07-16 13:31:11 -07:00
|
|
|
gn_args = {}
|
|
|
|
|
|
2019-07-15 12:28:10 -07:00
|
|
|
if args.bitcode:
|
|
|
|
|
if args.target_os != 'ios':
|
|
|
|
|
raise Exception('Bitcode is only supported for iOS')
|
2019-08-27 11:25:59 -07:00
|
|
|
if runtime_mode != 'release':
|
2019-08-26 12:58:14 -07:00
|
|
|
gn_args['bitcode_marker'] = True
|
2019-07-15 12:28:10 -07:00
|
|
|
|
|
|
|
|
gn_args['enable_bitcode'] = args.bitcode
|
|
|
|
|
|
2016-11-17 12:36:16 -08:00
|
|
|
# Skia GN args.
|
2017-07-18 09:44:21 -04:00
|
|
|
gn_args['skia_enable_flutter_defines'] = True # Enable Flutter API guards in Skia.
|
2016-11-18 12:52:02 -08:00
|
|
|
gn_args['skia_use_dng_sdk'] = False # RAW image handling.
|
2019-05-25 13:14:46 -07:00
|
|
|
gn_args['skia_use_sfntly'] = False # PDF handling dependency.
|
2018-05-18 12:09:14 -07:00
|
|
|
gn_args['skia_enable_pdf'] = False # PDF handling.
|
2018-09-26 18:15:30 -07:00
|
|
|
gn_args['skia_use_x11'] = False # Never add the X11 dependency (only takes effect on Linux).
|
2019-07-10 14:07:54 -07:00
|
|
|
gn_args['skia_use_wuffs'] = True
|
2018-05-18 12:55:20 -07:00
|
|
|
gn_args['skia_use_expat'] = args.target_os == 'android'
|
2019-05-16 15:22:22 -07:00
|
|
|
gn_args['skia_use_fontconfig'] = args.enable_fontconfig
|
|
|
|
|
gn_args['flutter_use_fontconfig'] = args.enable_fontconfig
|
2019-07-10 14:13:55 -07:00
|
|
|
gn_args['flutter_enable_skshaper'] = args.enable_skshaper
|
2017-09-06 15:55:29 -07:00
|
|
|
gn_args['is_official_build'] = True # Disable Skia test utilities.
|
2019-05-06 18:01:59 -07:00
|
|
|
gn_args['dart_component_kind'] = 'static_library' # Always link Dart in statically.
|
2016-05-10 10:57:56 -07:00
|
|
|
gn_args['is_debug'] = args.unoptimized
|
2016-11-15 17:44:39 -08:00
|
|
|
gn_args['android_full_debug'] = args.target_os == 'android' and args.unoptimized
|
2017-01-23 14:12:26 -08:00
|
|
|
gn_args['is_clang'] = not sys.platform.startswith(('cygwin', 'win'))
|
2018-09-06 15:29:04 -07:00
|
|
|
|
2019-06-12 12:32:09 -07:00
|
|
|
if args.target_os == 'android' or args.target_os == 'ios':
|
|
|
|
|
gn_args['skia_gl_standard'] = 'gles'
|
|
|
|
|
else:
|
|
|
|
|
# We explicitly don't want to pick GL because we run GLES tests using SwiftShader.
|
|
|
|
|
gn_args['skia_gl_standard'] = ''
|
|
|
|
|
|
2019-03-05 17:35:43 -08:00
|
|
|
if not sys.platform.startswith(('cygwin', 'win')):
|
|
|
|
|
gn_args['use_clang_static_analyzer'] = args.clang_static_analyzer
|
|
|
|
|
|
2018-08-22 16:42:47 -07:00
|
|
|
gn_args['embedder_for_target'] = args.embedder_for_target
|
2016-04-22 11:02:41 -07:00
|
|
|
|
2019-01-24 14:03:15 -08:00
|
|
|
gn_args['enable_coverage'] = args.coverage
|
|
|
|
|
|
2019-01-15 16:09:46 +01:00
|
|
|
if args.operator_new_alignment is not None:
|
|
|
|
|
gn_args['operator_new_alignment'] = args.operator_new_alignment
|
|
|
|
|
|
2017-09-05 13:00:27 -07:00
|
|
|
enable_lto = args.lto
|
|
|
|
|
if args.unoptimized:
|
|
|
|
|
# There is no point in enabling LTO in unoptimized builds.
|
|
|
|
|
enable_lto = False
|
|
|
|
|
|
2018-05-24 14:21:42 -07:00
|
|
|
if not sys.platform.startswith('win'):
|
2017-09-05 13:00:27 -07:00
|
|
|
# The GN arg is not available in the windows toolchain.
|
|
|
|
|
gn_args['enable_lto'] = enable_lto
|
2017-08-09 14:29:05 -07:00
|
|
|
|
2015-07-16 13:31:11 -07:00
|
|
|
if args.target_os == 'android':
|
2015-07-23 13:11:11 -07:00
|
|
|
gn_args['target_os'] = 'android'
|
2015-07-16 13:31:11 -07:00
|
|
|
elif args.target_os == 'ios':
|
2015-07-23 13:11:11 -07:00
|
|
|
gn_args['target_os'] = 'ios'
|
2015-11-03 11:54:37 -08:00
|
|
|
gn_args['use_ios_simulator'] = args.simulator
|
2018-10-15 14:18:02 -07:00
|
|
|
elif args.target_os is not None:
|
|
|
|
|
gn_args['target_os'] = args.target_os
|
2015-07-16 13:31:11 -07:00
|
|
|
|
2018-09-27 18:19:22 +02:00
|
|
|
gn_args['dart_lib_export_symbols'] = False
|
|
|
|
|
|
2018-06-05 14:52:52 -07:00
|
|
|
if runtime_mode == 'debug':
|
2016-05-10 10:57:56 -07:00
|
|
|
gn_args['dart_runtime_mode'] = 'develop'
|
2019-09-27 11:20:54 -07:00
|
|
|
elif runtime_mode == 'jit_release':
|
|
|
|
|
gn_args['dart_runtime_mode'] = 'release';
|
2016-05-10 10:57:56 -07:00
|
|
|
else:
|
2018-06-05 14:52:52 -07:00
|
|
|
gn_args['dart_runtime_mode'] = runtime_mode
|
2016-05-10 10:57:56 -07:00
|
|
|
|
2018-08-21 08:42:13 -07:00
|
|
|
if args.dart_debug:
|
|
|
|
|
gn_args['dart_debug'] = True
|
|
|
|
|
|
2019-03-13 12:54:57 -07:00
|
|
|
if args.full_dart_debug:
|
|
|
|
|
gn_args['dart_debug'] = True
|
|
|
|
|
gn_args['dart_debug_optimization_level'] = '0'
|
|
|
|
|
|
2016-05-05 14:38:42 -07:00
|
|
|
if args.target_os == 'android':
|
|
|
|
|
gn_args['target_cpu'] = args.android_cpu
|
|
|
|
|
elif args.target_os == 'ios':
|
|
|
|
|
if args.simulator:
|
|
|
|
|
gn_args['target_cpu'] = 'x64'
|
|
|
|
|
else:
|
2017-09-05 14:46:39 -07:00
|
|
|
gn_args['target_cpu'] = args.ios_cpu
|
2017-09-19 14:09:35 -07:00
|
|
|
elif args.target_os == 'linux':
|
|
|
|
|
gn_args['target_cpu'] = args.linux_cpu
|
2019-07-30 11:43:09 -07:00
|
|
|
elif args.target_os == 'fuchsia':
|
|
|
|
|
gn_args['target_cpu'] = args.fuchsia_cpu
|
2017-07-17 09:45:10 -07:00
|
|
|
else:
|
|
|
|
|
# Building host artifacts
|
|
|
|
|
gn_args['target_cpu'] = 'x64'
|
2016-04-22 16:31:32 -07:00
|
|
|
|
2019-08-06 01:17:06 +02:00
|
|
|
# DBC is not supported anymore.
|
|
|
|
|
if args.interpreter:
|
|
|
|
|
raise Exception('--interpreter is no longer needed on any supported platform.')
|
|
|
|
|
gn_args['dart_target_arch'] = gn_args['target_cpu']
|
2017-07-17 13:33:33 -07:00
|
|
|
|
|
|
|
|
if sys.platform.startswith(('cygwin', 'win')):
|
|
|
|
|
if 'target_cpu' in gn_args:
|
|
|
|
|
gn_args['target_cpu'] = cpu_for_target_arch(gn_args['target_cpu'])
|
2016-05-06 15:37:59 -07:00
|
|
|
|
2018-02-12 22:37:34 -08:00
|
|
|
if args.target_os is None:
|
|
|
|
|
if sys.platform.startswith(('cygwin', 'win')):
|
|
|
|
|
gn_args['dart_use_fallback_root_certificates'] = True
|
|
|
|
|
|
|
|
|
|
|
2018-02-16 14:59:21 -08:00
|
|
|
gn_args['dart_custom_version_for_pub'] = 'flutter'
|
|
|
|
|
|
2019-08-01 10:58:12 -07:00
|
|
|
# Make sure host_cpu matches the bit width of target_cpu on x86.
|
|
|
|
|
if gn_args['target_cpu'] == 'x86':
|
|
|
|
|
gn_args['host_cpu'] = 'x86'
|
2017-06-27 02:44:04 +00:00
|
|
|
|
2018-06-05 14:52:52 -07:00
|
|
|
gn_args['flutter_runtime_mode'] = runtime_mode
|
2016-04-25 10:45:23 -07:00
|
|
|
|
2015-11-16 13:27:56 -08:00
|
|
|
if args.target_sysroot:
|
|
|
|
|
gn_args['target_sysroot'] = args.target_sysroot
|
2018-10-15 14:18:02 -07:00
|
|
|
gn_args['custom_sysroot'] = args.target_sysroot
|
|
|
|
|
|
|
|
|
|
if args.target_toolchain:
|
|
|
|
|
gn_args['custom_toolchain'] = args.target_toolchain
|
|
|
|
|
|
|
|
|
|
if args.target_triple:
|
|
|
|
|
gn_args['custom_target_triple'] = args.target_triple
|
2015-11-16 13:27:56 -08:00
|
|
|
|
2015-07-16 16:38:12 -07:00
|
|
|
goma_dir = os.environ.get('GOMA_DIR')
|
|
|
|
|
goma_home_dir = os.path.join(os.getenv('HOME', ''), 'goma')
|
2019-01-30 13:00:34 -08:00
|
|
|
|
|
|
|
|
# GOMA has a different default (home) path on gWindows.
|
|
|
|
|
if not os.path.exists(goma_home_dir) and sys.platform.startswith(('cygwin', 'win')):
|
|
|
|
|
goma_home_dir = os.path.join('c:\\', 'src', 'goma', 'goma-win64')
|
|
|
|
|
|
2015-07-16 16:38:12 -07:00
|
|
|
if args.goma and goma_dir:
|
|
|
|
|
gn_args['use_goma'] = True
|
|
|
|
|
gn_args['goma_dir'] = goma_dir
|
|
|
|
|
elif args.goma and os.path.exists(goma_home_dir):
|
|
|
|
|
gn_args['use_goma'] = True
|
|
|
|
|
gn_args['goma_dir'] = goma_home_dir
|
|
|
|
|
else:
|
|
|
|
|
gn_args['use_goma'] = False
|
|
|
|
|
gn_args['goma_dir'] = None
|
|
|
|
|
|
2019-05-11 15:21:26 -07:00
|
|
|
if args.enable_metal:
|
|
|
|
|
gn_args['skia_use_metal'] = True
|
|
|
|
|
gn_args['shell_enable_metal'] = True
|
2019-06-19 15:24:26 -07:00
|
|
|
gn_args['allow_deprecated_api_calls'] = True
|
2019-05-11 15:21:26 -07:00
|
|
|
|
2017-01-20 14:37:10 -08:00
|
|
|
if args.enable_vulkan:
|
|
|
|
|
# Enable vulkan in the Flutter shell.
|
|
|
|
|
gn_args['shell_enable_vulkan'] = True
|
|
|
|
|
# Configure Skia for Vulkan support.
|
|
|
|
|
gn_args['skia_use_vulkan'] = True
|
|
|
|
|
|
2019-08-14 15:52:52 -07:00
|
|
|
# The buildroot currently isn't set up to support Vulkan in the
|
|
|
|
|
# Windows ANGLE build, so disable it regardless of enable_vulkan's value.
|
|
|
|
|
if sys.platform.startswith(('cygwin', 'win')):
|
|
|
|
|
gn_args['angle_enable_vulkan'] = False
|
|
|
|
|
|
2017-07-06 14:40:34 -07:00
|
|
|
# We should not need a special case for x86, but this seems to introduce text relocations
|
|
|
|
|
# even with -fPIC everywhere.
|
2017-07-19 12:52:53 -07:00
|
|
|
# gn_args['enable_profiling'] = args.runtime_mode != 'release' and args.android_cpu != 'x86'
|
2017-07-06 09:40:23 -07:00
|
|
|
|
2018-10-15 14:18:02 -07:00
|
|
|
if args.arm_float_abi:
|
|
|
|
|
gn_args['arm_float_abi'] = args.arm_float_abi
|
|
|
|
|
|
2019-03-18 11:58:35 -07:00
|
|
|
# Whether to build trained Dart SDK snapshots of dart2js and dartdevc,
|
|
|
|
|
# including the web sdk kernel and source files.
|
2019-03-19 09:43:17 -07:00
|
|
|
if args.target_os is None:
|
|
|
|
|
# dart_platform_sdk is not declared for Android targets.
|
|
|
|
|
gn_args['dart_platform_sdk'] = not args.full_dart_sdk
|
2019-03-18 11:58:35 -07:00
|
|
|
gn_args['full_dart_sdk'] = args.full_dart_sdk
|
2019-02-26 14:49:09 -08:00
|
|
|
|
2019-03-21 15:46:29 -07:00
|
|
|
if sys.platform == 'darwin':
|
2019-07-01 16:58:00 -07:00
|
|
|
if args.build_glfw_shell:
|
|
|
|
|
gn_args['build_glfw_shell'] = True
|
2019-03-21 15:46:29 -07:00
|
|
|
|
2019-08-26 16:53:00 -07:00
|
|
|
gn_args['stripped_symbols'] = args.stripped
|
|
|
|
|
|
2019-10-04 17:32:00 -07:00
|
|
|
if args.msan:
|
|
|
|
|
gn_args['is_msan'] = True
|
|
|
|
|
|
|
|
|
|
if args.asan:
|
|
|
|
|
gn_args['is_asan'] = True
|
|
|
|
|
|
|
|
|
|
if args.tsan:
|
|
|
|
|
gn_args['is_tsan'] = True
|
|
|
|
|
|
|
|
|
|
if args.lsan:
|
|
|
|
|
gn_args['is_lsan'] = True
|
|
|
|
|
|
2019-10-05 19:55:07 -07:00
|
|
|
if args.ubsan:
|
|
|
|
|
gn_args['is_ubsan'] = True
|
|
|
|
|
|
2019-11-25 16:09:56 -08:00
|
|
|
if args.enable_vulkan_validation_layers:
|
|
|
|
|
if args.target_os is not 'fuchsia':
|
|
|
|
|
print('Vulkan validation layers are currently only supported on Fuchsia targets.')
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
gn_args['enable_vulkan_validation_layers'] = True
|
|
|
|
|
|
2015-07-16 13:31:11 -07:00
|
|
|
return gn_args
|
|
|
|
|
|
2015-07-23 13:11:11 -07:00
|
|
|
def parse_args(args):
|
2015-07-23 13:20:42 -07:00
|
|
|
args = args[1:]
|
2015-07-16 13:31:11 -07:00
|
|
|
parser = argparse.ArgumentParser(description='A script run` gn gen`.')
|
2015-07-16 16:38:12 -07:00
|
|
|
|
2016-05-10 10:57:56 -07:00
|
|
|
parser.add_argument('--unoptimized', default=False, action='store_true')
|
2016-05-09 14:58:45 -07:00
|
|
|
|
2019-09-27 11:20:54 -07:00
|
|
|
parser.add_argument('--runtime-mode', type=str, choices=['debug', 'profile', 'release', 'jit_release'], default='debug')
|
2018-06-05 14:52:52 -07:00
|
|
|
parser.add_argument('--interpreter', default=False, action='store_true')
|
2019-10-10 14:03:42 +02:00
|
|
|
parser.add_argument('--dart-debug', default=False, action='store_true', help='Enables assertions in the Dart VM. ' +
|
2019-05-29 03:33:30 +08:00
|
|
|
'Does not affect optimization levels. If you need to disable optimizations in Dart, use --full-dart-debug')
|
2019-03-13 12:54:57 -07:00
|
|
|
parser.add_argument('--full-dart-debug', default=False, action='store_true', help='Implies --dart-debug ' +
|
|
|
|
|
'and also disables optimizations in the Dart VM making it easier to step through VM code in the debugger.')
|
2015-07-16 16:38:12 -07:00
|
|
|
|
2019-05-06 18:01:59 -07:00
|
|
|
parser.add_argument('--target-os', type=str, choices=['android', 'ios', 'linux', 'fuchsia'])
|
2015-07-16 13:31:11 -07:00
|
|
|
parser.add_argument('--android', dest='target_os', action='store_const', const='android')
|
2016-11-15 14:56:08 -08:00
|
|
|
parser.add_argument('--android-cpu', type=str, choices=['arm', 'x64', 'x86', 'arm64'], default='arm')
|
2015-07-16 13:31:11 -07:00
|
|
|
parser.add_argument('--ios', dest='target_os', action='store_const', const='ios')
|
2017-09-05 14:46:39 -07:00
|
|
|
parser.add_argument('--ios-cpu', type=str, choices=['arm', 'arm64'], default='arm64')
|
2015-07-23 12:23:20 -07:00
|
|
|
parser.add_argument('--simulator', action='store_true', default=False)
|
2019-05-06 18:01:59 -07:00
|
|
|
parser.add_argument('--fuchsia', dest='target_os', action='store_const', const='fuchsia')
|
2018-10-15 14:18:02 -07:00
|
|
|
parser.add_argument('--linux-cpu', type=str, choices=['x64', 'x86', 'arm64', 'arm'])
|
2019-07-30 11:43:09 -07:00
|
|
|
parser.add_argument('--fuchsia-cpu', type=str, choices=['x64', 'arm64'], default = 'x64')
|
2018-10-15 14:18:02 -07:00
|
|
|
parser.add_argument('--arm-float-abi', type=str, choices=['hard', 'soft', 'softfp'])
|
2015-07-16 16:38:12 -07:00
|
|
|
|
|
|
|
|
parser.add_argument('--goma', default=True, action='store_true')
|
|
|
|
|
parser.add_argument('--no-goma', dest='goma', action='store_false')
|
|
|
|
|
|
2017-09-05 13:00:27 -07:00
|
|
|
parser.add_argument('--lto', default=True, action='store_true')
|
|
|
|
|
parser.add_argument('--no-lto', dest='lto', action='store_false')
|
|
|
|
|
|
2015-07-17 23:34:38 -07:00
|
|
|
parser.add_argument('--clang', default=True, action='store_true')
|
|
|
|
|
parser.add_argument('--no-clang', dest='clang', action='store_false')
|
|
|
|
|
|
2019-03-05 17:35:43 -08:00
|
|
|
parser.add_argument('--clang-static-analyzer', default=False, action='store_true')
|
|
|
|
|
parser.add_argument('--no-clang-static-analyzer', dest='clang_static_analyzer', action='store_false')
|
|
|
|
|
|
2015-11-16 13:27:56 -08:00
|
|
|
parser.add_argument('--target-sysroot', type=str)
|
2018-10-15 14:18:02 -07:00
|
|
|
parser.add_argument('--target-toolchain', type=str)
|
|
|
|
|
parser.add_argument('--target-triple', type=str)
|
2019-01-15 16:09:46 +01:00
|
|
|
parser.add_argument('--operator-new-alignment', dest='operator_new_alignment', type=str, default=None)
|
2015-11-16 13:27:56 -08:00
|
|
|
|
2017-01-20 14:37:10 -08:00
|
|
|
parser.add_argument('--enable-vulkan', action='store_true', default=False)
|
2019-05-11 15:21:26 -07:00
|
|
|
parser.add_argument('--enable-metal', action='store_true', default=False)
|
2016-01-22 14:57:45 -08:00
|
|
|
|
2019-05-16 15:22:22 -07:00
|
|
|
parser.add_argument('--enable-fontconfig', action='store_true', default=False)
|
2019-07-10 14:13:55 -07:00
|
|
|
parser.add_argument('--enable-skshaper', action='store_true', default=False)
|
2019-11-25 16:09:56 -08:00
|
|
|
parser.add_argument('--enable-vulkan-validation-layers', action='store_true', default=False)
|
2019-05-16 15:22:22 -07:00
|
|
|
|
2018-08-22 16:42:47 -07:00
|
|
|
parser.add_argument('--embedder-for-target', dest='embedder_for_target', action='store_true', default=False)
|
|
|
|
|
|
2019-01-24 14:03:15 -08:00
|
|
|
parser.add_argument('--coverage', default=False, action='store_true')
|
|
|
|
|
|
2019-02-08 15:15:47 -08:00
|
|
|
parser.add_argument('--out-dir', default='', type=str)
|
|
|
|
|
|
2019-03-17 15:52:41 -07:00
|
|
|
parser.add_argument('--full-dart-sdk', default=False, action='store_true',
|
|
|
|
|
help='include trained dart2js and dartdevc snapshots. Enable only on steps that create an SDK')
|
|
|
|
|
parser.add_argument('--no-full-dart-sdk', dest='full_dart_sdk', action='store_false')
|
2019-03-15 13:13:44 -07:00
|
|
|
|
2019-05-28 12:21:58 -07:00
|
|
|
parser.add_argument('--ide', default='', type=str,
|
|
|
|
|
help='The IDE files to generate using GN. Use `gn gen help` and look for the --ide flag to' +
|
|
|
|
|
' see supported IDEs. If this flag is not specified, a platform specific default is selected.')
|
|
|
|
|
|
2019-06-29 19:35:22 -07:00
|
|
|
parser.add_argument('--build-glfw-shell', dest='build_glfw_shell', default=False, action='store_true',
|
|
|
|
|
help='Force building the GLFW shell on desktop platforms where it is not built by default.')
|
|
|
|
|
|
2019-07-15 12:28:10 -07:00
|
|
|
parser.add_argument('--bitcode', default=False, action='store_true',
|
2019-08-26 12:58:14 -07:00
|
|
|
help='Enable bitcode for iOS targets. On debug runtime modes, this will be a marker only.')
|
2019-07-15 12:28:10 -07:00
|
|
|
|
2019-08-26 16:53:00 -07:00
|
|
|
parser.add_argument('--stripped', default=True, action='store_true',
|
|
|
|
|
help='Strip debug symbols from the output. This defaults to true and has no effect on iOS.')
|
|
|
|
|
parser.add_argument('--no-stripped', dest='stripped', action='store_false')
|
|
|
|
|
|
2019-10-04 17:32:00 -07:00
|
|
|
# Sanitizers.
|
|
|
|
|
parser.add_argument('--asan', default=False, action='store_true')
|
|
|
|
|
parser.add_argument('--lsan', default=False, action='store_true')
|
|
|
|
|
parser.add_argument('--msan', default=False, action='store_true')
|
|
|
|
|
parser.add_argument('--tsan', default=False, action='store_true')
|
2019-10-05 19:55:07 -07:00
|
|
|
parser.add_argument('--ubsan', default=False, action='store_true')
|
2019-10-04 17:32:00 -07:00
|
|
|
|
2015-07-23 13:11:11 -07:00
|
|
|
return parser.parse_args(args)
|
2015-07-16 13:31:11 -07:00
|
|
|
|
2015-07-23 13:11:11 -07:00
|
|
|
def main(argv):
|
|
|
|
|
args = parse_args(argv)
|
2016-08-09 12:48:29 -07:00
|
|
|
|
2019-07-17 11:35:58 -07:00
|
|
|
exe = '.exe' if sys.platform.startswith(('cygwin', 'win')) else ''
|
2016-08-09 12:48:29 -07:00
|
|
|
|
|
|
|
|
command = [
|
2019-07-17 11:35:58 -07:00
|
|
|
'%s/flutter/third_party/gn/gn%s' % (SRC_ROOT, exe),
|
2016-08-09 12:48:29 -07:00
|
|
|
'gen',
|
2017-01-03 16:40:15 -08:00
|
|
|
'--check',
|
2016-08-09 12:48:29 -07:00
|
|
|
]
|
2017-01-03 16:40:15 -08:00
|
|
|
|
2019-05-28 12:21:58 -07:00
|
|
|
if args.ide != '':
|
|
|
|
|
command.append('--ide=%s' % args.ide)
|
|
|
|
|
elif sys.platform == 'darwin':
|
|
|
|
|
# On the Mac, generate an Xcode project by default.
|
2017-01-03 16:40:15 -08:00
|
|
|
command.append('--ide=xcode')
|
2019-05-28 12:21:58 -07:00
|
|
|
elif sys.platform.startswith('win'):
|
|
|
|
|
# On Windows, generate a Visual Studio project.
|
2018-04-13 13:48:15 -07:00
|
|
|
command.append('--ide=vs')
|
|
|
|
|
|
2015-07-16 13:31:11 -07:00
|
|
|
gn_args = to_command_line(to_gn_args(args))
|
|
|
|
|
out_dir = get_out_dir(args)
|
|
|
|
|
command.append(out_dir)
|
|
|
|
|
command.append('--args=%s' % ' '.join(gn_args))
|
2019-05-28 12:21:58 -07:00
|
|
|
print "Generating GN files in: %s" % out_dir
|
2019-07-22 13:59:46 -07:00
|
|
|
try:
|
|
|
|
|
gn_call_result = subprocess.call(command, cwd=SRC_ROOT)
|
|
|
|
|
except subprocess.CalledProcessError as exc:
|
|
|
|
|
print "Failed to generate gn files: ", exc.returncode, exc.output
|
|
|
|
|
sys.exit(1)
|
2015-07-16 13:31:11 -07:00
|
|
|
|
2016-10-26 15:31:19 -07:00
|
|
|
if gn_call_result == 0:
|
|
|
|
|
# Generate/Replace the compile commands database in out.
|
|
|
|
|
compile_cmd_gen_cmd = [
|
2017-01-23 14:12:26 -08:00
|
|
|
'ninja',
|
2016-10-26 15:31:19 -07:00
|
|
|
'-C',
|
|
|
|
|
out_dir,
|
|
|
|
|
'-t',
|
|
|
|
|
'compdb',
|
|
|
|
|
'cc',
|
2016-10-27 16:58:04 -07:00
|
|
|
'cxx',
|
|
|
|
|
'objc',
|
|
|
|
|
'objcxx',
|
|
|
|
|
'asm',
|
2016-10-26 15:31:19 -07:00
|
|
|
]
|
|
|
|
|
|
2019-07-18 14:50:27 -07:00
|
|
|
try:
|
|
|
|
|
contents = subprocess.check_output(compile_cmd_gen_cmd, cwd=SRC_ROOT)
|
|
|
|
|
except subprocess.CalledProcessError as exc:
|
|
|
|
|
print "Failed to run ninja: ", exc.returncode, exc.output
|
|
|
|
|
sys.exit(1)
|
2016-10-26 15:31:19 -07:00
|
|
|
compile_commands = open('%s/out/compile_commands.json' % SRC_ROOT, 'w+')
|
|
|
|
|
compile_commands.write(contents)
|
|
|
|
|
compile_commands.close()
|
|
|
|
|
|
|
|
|
|
return gn_call_result
|
2015-07-16 13:31:11 -07:00
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2015-07-23 13:11:11 -07:00
|
|
|
sys.exit(main(sys.argv))
|