From e68386fee634ca02ebb3b927f05481d59685ddee Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Tue, 27 Jun 2017 02:44:04 +0000 Subject: [PATCH] Generate flutter-flavoured dart patched sdk and platform.dill (flutter/engine#3814) * Build Flutter patched-sdk with kernel artifacts * Switch to new dart_host_toolchain argument mechanism to let dart patch_sdk know of host_toolchain. * Update dart dependency * Updated licenses * Rename dart dependencies tag so they have just 'dart_'-prefixed dart's names. * Fix indentation and line breaks for newly added deps. * Add toolchain for windows host * Update dart revision * Licenses * Update licenses * Revert changes to licenses_third_party --- DEPS | 121 ++++++++++++++--- engine/src/flutter/BUILD.gn | 1 + engine/src/flutter/lib/snapshot/BUILD.gn | 124 +++++++++++++++++- engine/src/flutter/lib/snapshot/toolchain.gni | 35 ----- engine/src/flutter/sky/BUILD.gn | 2 - engine/src/flutter/tools/gn | 14 ++ 6 files changed, 240 insertions(+), 57 deletions(-) delete mode 100644 engine/src/flutter/lib/snapshot/toolchain.gni diff --git a/DEPS b/DEPS index 58e88c9ba96..0bcee6ddd1e 100644 --- a/DEPS +++ b/DEPS @@ -27,16 +27,37 @@ vars = { # When updating the Dart revision, ensure that all entries that are # dependencies of Dart are also updated to match the entries in the # Dart SDK's DEPS file for that revision of Dart. The DEPS file for - # Dart is: https://github.com/dart-lang/sdk/blob/master/DEPS + # Dart is: https://github.com/dart-lang/sdk/blob/master/DEPS. + # You can use //dart/tools/create_updated_fluter_deps.py to produce + # updated revision list of existing dependencies. 'dart_revision': '3c543bb210711dd6761d592a863fd6f32e1f1279', - # Dart calls the next one "boringssl_gen_rev" - 'dart_boringssl_gen_revision': '753224969dbe43dad29343146529727b5066c0f3', - # Dart calls the next one "boringssl_rev" - 'dart_boringssl_revision': 'd519bf6be0b447fb80fbc539d4bff4479b5482a2', - # Dart calls the next one "observatory_pub_packages_rev" - 'dart_observatory_packages_revision': '26aad88f1c1915d39bbcbff3cad589e2402fdcf1', - # Dart calls the next one "root_certificates_rev" - 'dart_root_certificates_revision': 'a4c7c6f23a664a37bc1b6f15a819e3f2a292791a', + + 'dart_args_tag': '0.13.7', + 'dart_async_tag': 'daf66909019d2aaec1721fc39d94ea648a9fdc1d', + 'dart_boringssl_gen_rev': '753224969dbe43dad29343146529727b5066c0f3', + 'dart_boringssl_rev': 'd519bf6be0b447fb80fbc539d4bff4479b5482a2', + 'dart_charcode_tag': 'v1.1.1', + 'dart_collection_tag': '1.13.0', + 'dart_convert_tag': '2.0.1', + 'dart_crypto_tag': '2.0.1', + 'dart_csslib_tag': '0.13.3+1', + 'dart_dart2js_info_tag': '0.5.4+2', + 'dart_glob_tag': '1.1.3', + 'dart_html_tag': '0.13.1', + 'dart_isolate_tag': '1.0.0', + 'dart_logging_tag': '0.11.3+1', + 'dart_observatory_pub_packages_rev': '26aad88f1c1915d39bbcbff3cad589e2402fdcf1', + 'dart_package_config_tag': '1.0.0', + 'dart_path_tag': '1.4.1', + 'dart_plugin_tag': '0.2.0', + 'dart_pub_semver_tag': '1.3.2', + 'dart_root_certificates_rev': 'a4c7c6f23a664a37bc1b6f15a819e3f2a292791a', + 'dart_source_span_tag': '1.4.0', + 'dart_string_scanner_tag': '1.0.1', + 'dart_typed_data_tag': '1.1.3', + 'dart_utf_tag': '0.9.0+3', + 'dart_watcher_tag': '0.9.7+3', + 'dart_yaml_tag': '2.1.12', # Build bot tooling for iOS 'ios_tools_revision': '69b7c1b160e7107a6a98d948363772dc9caea46f', @@ -85,30 +106,92 @@ deps = { 'src/buildtools': Var('fuchsia_git') + '/buildtools' + '@' + Var('buildtools_revision'), - 'src/ios_tools': + 'src/ios_tools': Var('chromium_git') + '/chromium/src/ios.git' + '@' + Var('ios_tools_revision'), 'src/third_party/icu': Var('chromium_git') + '/chromium/deps/icu.git' + '@' + 'c3f79166089e5360c09e3053fce50e6e296c3204', 'src/dart': - Var('chromium_git') + '/external/github.com/dart-lang/sdk.git' + '@' + Var('dart_revision'), + Var('chromium_git') + '/external/github.com/dart-lang/sdk.git' + '@' + Var('dart_revision'), 'src/third_party/boringssl': - Var('github_git') + '/dart-lang/boringssl_gen.git' + '@' + Var('dart_boringssl_gen_revision'), + Var('github_git') + '/dart-lang/boringssl_gen.git' + '@' + Var('dart_boringssl_gen_rev'), 'src/third_party/boringssl/src': - 'https://boringssl.googlesource.com/boringssl.git' + '@' + Var('dart_boringssl_revision'), + 'https://boringssl.googlesource.com/boringssl.git' + '@' + Var('dart_boringssl_rev'), 'src/dart/third_party/observatory_pub_packages': - Var('chromium_git') + - '/external/github.com/dart-lang/observatory_pub_packages' + '@' + - Var('dart_observatory_packages_revision'), + Var('chromium_git') + '/external/github.com/dart-lang/observatory_pub_packages' + '@' + Var('dart_observatory_pub_packages_rev'), + + 'src/dart/third_party/pkg/args': + Var('chromium_git') + '/external/github.com/dart-lang/args' + '@' + Var('dart_args_tag'), + + 'src/dart/third_party/pkg/async': + Var('chromium_git') + '/external/github.com/dart-lang/async' + '@' + Var('dart_async_tag'), + + 'src/dart/third_party/pkg/charcode': + Var('chromium_git') + '/external/github.com/dart-lang/charcode' + '@' + Var('dart_charcode_tag'), + + 'src/dart/third_party/pkg/collection': + Var('chromium_git') + '/external/github.com/dart-lang/collection' + '@' + Var('dart_collection_tag'), + + 'src/dart/third_party/pkg/convert': + Var('chromium_git') + '/external/github.com/dart-lang/convert' + '@' + Var('dart_convert_tag'), + + 'src/dart/third_party/pkg/crypto': + Var('chromium_git') + '/external/github.com/dart-lang/crypto' + '@' + Var('dart_crypto_tag'), + + 'src/dart/third_party/pkg/csslib': + Var('chromium_git') + '/external/github.com/dart-lang/csslib' + '@' + Var('dart_csslib_tag'), + + 'src/dart/third_party/pkg/dart2js_info': + Var('chromium_git') + '/external/github.com/dart-lang/dart2js_info' + '@' + Var('dart_dart2js_info_tag'), + + 'src/dart/third_party/pkg/isolate': + Var('chromium_git') + '/external/github.com/dart-lang/isolate' + '@' + Var('dart_isolate_tag'), + + 'src/dart/third_party/pkg/glob': + Var('chromium_git') + '/external/github.com/dart-lang/glob' + '@' + Var('dart_glob_tag'), + + 'src/dart/third_party/pkg/html': + Var('chromium_git') + '/external/github.com/dart-lang/html' + '@' + Var('dart_html_tag'), + + 'src/dart/third_party/pkg/logging': + Var('chromium_git') + '/external/github.com/dart-lang/logging' + '@' + Var('dart_logging_tag'), + + 'src/dart/third_party/pkg_tested/package_config': + Var('chromium_git') + '/external/github.com/dart-lang/package_config' + '@' + Var('dart_package_config_tag'), + + 'src/dart/third_party/pkg/path': + Var('chromium_git') + '/external/github.com/dart-lang/path' + '@' + Var('dart_path_tag'), + + 'src/dart/third_party/pkg/plugin': + Var('chromium_git') + '/external/github.com/dart-lang/plugin' + '@' + Var('dart_plugin_tag'), + + 'src/dart/third_party/pkg/pub_semver': + Var('chromium_git') + '/external/github.com/dart-lang/pub_semver' + '@' + Var('dart_pub_semver_tag'), + + 'src/dart/third_party/pkg/source_span': + Var('chromium_git') + '/external/github.com/dart-lang/source_span' + '@' + Var('dart_source_span_tag'), + + 'src/dart/third_party/pkg/string_scanner': + Var('chromium_git') + '/external/github.com/dart-lang/string_scanner' + '@' + Var('dart_string_scanner_tag'), + + 'src/dart/third_party/pkg/typed_data': + Var('chromium_git') + '/external/github.com/dart-lang/typed_data' + '@' + Var('dart_typed_data_tag'), + + 'src/dart/third_party/pkg/utf': + Var('chromium_git') + '/external/github.com/dart-lang/utf' + '@' + Var('dart_utf_tag'), + + 'src/dart/third_party/pkg/watcher': + Var('chromium_git') + '/external/github.com/dart-lang/watcher' + '@' + Var('dart_watcher_tag'), + + 'src/dart/third_party/pkg/yaml': + Var('chromium_git') + '/external/github.com/dart-lang/yaml' + '@' + Var('dart_yaml_tag'), 'src/third_party/root_certificates': - Var('chromium_git') + - '/external/github.com/dart-lang/root_certificates' + '@' + - Var('dart_root_certificates_revision'), + Var('chromium_git') + '/external/github.com/dart-lang/root_certificates' + '@' + Var('dart_root_certificates_rev'), 'src/third_party/skia': Var('skia_git') + '/skia.git' + '@' + Var('skia_revision'), diff --git a/engine/src/flutter/BUILD.gn b/engine/src/flutter/BUILD.gn index 936c8cb4079..869d1e22f22 100644 --- a/engine/src/flutter/BUILD.gn +++ b/engine/src/flutter/BUILD.gn @@ -7,6 +7,7 @@ group("flutter") { deps = [ "//flutter/lib/snapshot:generate_snapshot_bin", + "//flutter/lib/snapshot:patched_sdk", "//flutter/sky", ] diff --git a/engine/src/flutter/lib/snapshot/BUILD.gn b/engine/src/flutter/lib/snapshot/BUILD.gn index 39b7ed7a05f..d3b0430b5cf 100644 --- a/engine/src/flutter/lib/snapshot/BUILD.gn +++ b/engine/src/flutter/lib/snapshot/BUILD.gn @@ -2,9 +2,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import("//flutter/lib/snapshot/toolchain.gni") import("//flutter/lib/ui/dart_ui.gni") +import("//dart/runtime/vm/gypi_contents.gni") +import("//dart/utils/generate_patch_sdk.gni") + if (is_fuchsia) { import("//apps/mozart/lib/flutter/sdk_ext/sdk_ext.gni") import("//lib/fidl/dart/sdk_ext/sdk_ext.gni") @@ -245,3 +247,123 @@ source_set("snapshot") { "$target_gen_dir/vm_snapshot_instructions.S", ] } + +# Generate flutter_patched_sdk + +template("process_library_source") { + assert(defined(invoker.libsources), "Need libsources in $target_name") + assert(defined(invoker.output), "Need output in $target_name") + action(target_name) { + deps = [ + ":generate_dart_ui", + ] + + visibility = [ ":*" ] # Only targets in this file can see this. + libsources = invoker.libsources + + script = invoker.script + inputs = invoker.inputs + libsources + outputs = [ + invoker.output, + ] + args = invoker.args + rebase_path(libsources, root_build_dir) + } +} + +template("concatenate_patch") { + assert(defined(invoker.libsources), "Need a sources in $target_name") + assert(defined(invoker.output), "Need an output in $target_name") + + process_library_source(target_name) { + libsources = invoker.libsources + inputs = [] + output = invoker.output + script = "//dart/runtime/tools/concatenate_patches.py" + args = [ + "--output", + rebase_path(output, root_build_dir), + ] + } +} + +template("generate_vm_patched_sdk") { + assert(defined(invoker.libraries), "Need libraries in $target_name") + + concatenation_target_names = [] + + # Concatenate vm library patches. + foreach(library, invoker.libraries) { + name = library[0] + + target_output = "$target_gen_dir/patches/${name}_patch.dart" + concatenate_patch("concatenate_${name}_patch") { + libsources = rebase_path(library[1], ".", library[2]) + output = target_output + } + concatenation_target_names += [ ":concatenate_${name}_patch" ] + } + + # Build the patched sdk out of the concatenated patches and the special + # libraries. + generate_patched_sdk(target_name) { + mode = "flutter" + deps = concatenation_target_names + ["//dart/runtime/vm:patched_sdk"] + input_patches_dir = "$target_gen_dir/patches" + patched_sdk_dir = "flutter_patched_sdk" + } +} + +generate_vm_patched_sdk("patched_sdk") { + libraries = [ + [ + "async", + processed_gypis.async_runtime_sources, + "//dart/runtime/lib", + ], + [ + "collection", + processed_gypis.collection_runtime_sources, + "//dart/runtime/lib", + ], + [ + "convert", + processed_gypis.convert_runtime_sources, + "//dart/runtime/lib", + ], + [ + "core", + processed_gypis.core_runtime_sources, + "//dart/runtime/lib", + ], + [ + "developer", + processed_gypis.developer_runtime_sources, + "//dart/runtime/lib", + ], + [ + "internal", + processed_gypis.internal_runtime_sources, + "//dart/runtime/lib", + ], + [ + "io", + processed_gypis.bin_io_sources, + "//dart/runtime/bin", + ], + [ + "isolate", + processed_gypis.isolate_runtime_sources, + "//dart/runtime/lib", + ], + [ + "math", + processed_gypis.math_runtime_sources, + "//dart/runtime/lib", + ], + [ + "typed_data", + processed_gypis.typed_data_runtime_sources, + "//dart/runtime/lib", + ], + ] +} diff --git a/engine/src/flutter/lib/snapshot/toolchain.gni b/engine/src/flutter/lib/snapshot/toolchain.gni deleted file mode 100644 index 89c6857d193..00000000000 --- a/engine/src/flutter/lib/snapshot/toolchain.gni +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2015 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//flutter/common/config.gni") # for flutter_aot - -if (target_os == "ios") { - import("//build/config/ios/ios_sdk.gni") # For use_ios_simulator -} - -dart_host_toolchain = host_toolchain - -# During precompilation, a 64 bit Dart VM cannot generate code for a 32 bit -# architecture (and vice-versa). The snapshotter that is running on the host -# needs to know about the target architecture and built accordingly. -if (target_os == "ios" && !use_ios_simulator) { - if (target_cpu == "arm") { - dart_host_toolchain = "//build/toolchain/mac:clang_i386" - } else if (target_cpu == "arm64") { - dart_host_toolchain = "//build/toolchain/mac:clang_x64" - } else { - assert(false, "Unknown active architecture on iOS") - } -} - -if (target_os == "android" && flutter_aot) { - if (target_cpu == "arm") { - if (host_os == "linux") { - dart_host_toolchain = "//build/toolchain/linux:clang_x86" - } - if (host_os == "mac") { - dart_host_toolchain = "//build/toolchain/mac:clang_i386" - } - } -} diff --git a/engine/src/flutter/sky/BUILD.gn b/engine/src/flutter/sky/BUILD.gn index c78c168f3ac..ab016ebf339 100644 --- a/engine/src/flutter/sky/BUILD.gn +++ b/engine/src/flutter/sky/BUILD.gn @@ -2,8 +2,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import("//flutter/lib/snapshot/toolchain.gni") - group("sky") { testonly = true diff --git a/engine/src/flutter/tools/gn b/engine/src/flutter/tools/gn index 6c49d1beb5b..9ecb40ce334 100755 --- a/engine/src/flutter/tools/gn +++ b/engine/src/flutter/tools/gn @@ -113,6 +113,20 @@ def to_gn_args(args): if use_dbc: gn_args['dart_target_arch'] = 'dbc' + # Modify host_toolchain into dart_host_toolchain so it matches word size of target_cpu + if args.target_os == 'android' and aot and gn_args['target_cpu'] == 'arm': + if sys.platform.startswith('linux'): + gn_args['dart_host_toolchain'] = "//build/toolchain/linux:clang_x86" + elif sys.platform.startswith('darwin'): + gn_args['dart_host_toolchain'] = "//build/toolchain/mac:clang_i386" + elif sys.platform.startswith('win'): + gn_args['dart_host_toolchain'] = "//build/toolchain/win:x86" + elif args.target_os == "ios" and not args.simulator: + if gn_args['target_cpu'] == 'arm': + gn_args['dart_host_toolchain'] = '//build/toolchain/mac:clang_i386' + elif gn_args['target_cpu'] == 'arm64': + gn_args['dart_host_toolchain'] = '//build/toolchain/mac:clang_x64' + gn_args['flutter_runtime_mode'] = args.runtime_mode if args.target_sysroot: