From 3e3efe4c6c6ef569ae3e66dc453564d5ae8d6666 Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Fri, 26 Jul 2019 13:29:46 -0700 Subject: [PATCH] [dart_runner] dart jit runner and dart jit product runner (#10179) We now build dart runner as well --- common/fuchsia_config.gni | 12 ++ shell/platform/fuchsia/BUILD.gn | 3 +- shell/platform/fuchsia/dart_runner/BUILD.gn | 165 ++++++++++++++++---- shell/platform/fuchsia/flutter/BUILD.gn | 12 +- tools/fuchsia/build_fuchsia_artifacts.py | 28 ++-- tools/fuchsia/dart.gni | 7 + tools/fuchsia/package_dir.gni | 6 +- 7 files changed, 180 insertions(+), 53 deletions(-) create mode 100644 common/fuchsia_config.gni diff --git a/common/fuchsia_config.gni b/common/fuchsia_config.gni new file mode 100644 index 0000000000000..c8c55b59c5cf2 --- /dev/null +++ b/common/fuchsia_config.gni @@ -0,0 +1,12 @@ +# Copyright 2013 The Flutter 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("config.gni") + +if (is_fuchsia && using_fuchsia_sdk) { + dart_tools_root = "//flutter/tools/fuchsia/dart" + fuchsia_base = "//flutter/shell/platform/fuchsia" + flutter_runner_base = "$fuchsia_base/flutter/" + dart_runner_base = "$fuchsia_base/dart_runner/" +} diff --git a/shell/platform/fuchsia/BUILD.gn b/shell/platform/fuchsia/BUILD.gn index ce42f3308f736..3ca5996fb048a 100644 --- a/shell/platform/fuchsia/BUILD.gn +++ b/shell/platform/fuchsia/BUILD.gn @@ -13,10 +13,11 @@ if (using_fuchsia_sdk) { } flutter_runner_target = "flutter_jit_${product_suffix}runner" + dart_runner_target = "dart_jit_${product_suffix}runner" group("fuchsia") { deps = [ - # "dart", + "dart_runner:$dart_runner_target", "flutter:$flutter_runner_target", ] } diff --git a/shell/platform/fuchsia/dart_runner/BUILD.gn b/shell/platform/fuchsia/dart_runner/BUILD.gn index 137b40b0dde08..7887883090886 100644 --- a/shell/platform/fuchsia/dart_runner/BUILD.gn +++ b/shell/platform/fuchsia/dart_runner/BUILD.gn @@ -5,25 +5,22 @@ assert(is_fuchsia) import("//build/fuchsia/sdk.gni") +import("$flutter_root/common/fuchsia_config.gni") +import("$flutter_root/tools/fuchsia/common_libs.gni") +import("$flutter_root/tools/fuchsia/dart.gni") +import("$flutter_root/tools/fuchsia/package_dir.gni") -if (using_fuchsia_sdk) { - import("//flutter/common/config.gni") +template("runner") { + assert(defined(invoker.product), "The parameter 'product' must be defined") + assert(defined(invoker.output_name), + "The parameter 'output_name' must be defined") - group("dart_io_api") { - visibility = [ ":*" ] - public_deps = [] + invoker_output_name = invoker.output_name + extra_defines = invoker.extra_defines + extra_deps = invoker.extra_deps - if (flutter_runtime_mode == "debug") { - public_deps += [ "//third_party/dart/runtime/bin:dart_io_api" ] - } else { - public_deps += [ "//third_party/dart/runtime/bin:dart_io_api_product" ] - } - } - - executable("dart") { - output_name = "dart_runner" - - public = [] + executable(target_name) { + output_name = invoker_output_name sources = [ "builtin_libraries.cc", @@ -40,22 +37,128 @@ if (using_fuchsia_sdk) { "service_isolate.h", ] + defines = extra_defines + + dart_deps = [] + if (!invoker.product) { + dart_deps += [ "//third_party/dart/runtime/bin:dart_io_api" ] + } else { + dart_deps += [ "//third_party/dart/runtime/bin:dart_io_api_product" ] + } + + deps = [ + "$flutter_root/common", + "$flutter_root/fml", + "$flutter_root/runtime:libdart", + "$flutter_root/shell/platform/fuchsia/dart-pkg/fuchsia", + "$flutter_root/shell/platform/fuchsia/dart-pkg/zircon", + "$flutter_root/shell/platform/fuchsia/runtime/dart/utils", + "$fuchsia_sdk_root/pkg:async-cpp", + "$fuchsia_sdk_root/pkg:async-loop", + "$fuchsia_sdk_root/pkg:async-loop-cpp", + "$fuchsia_sdk_root/pkg:fidl_cpp", + "$fuchsia_sdk_root/pkg:syslog", + "$fuchsia_sdk_root/pkg/lib/sys/cpp", + "$fuchsia_sdk_root/pkg/lib/vfs/cpp", + "//third_party/tonic", + ] + dart_deps + extra_deps + } +} + +runner("dart_jit_runner_bin") { + output_name = "dart_jit_runner" + product = false + extra_defines = [] + if (flutter_runtime_mode == "profile") { + extra_defines += [ "FLUTTER_PROFILE" ] + } + extra_deps = [ + "//third_party/dart/runtime:libdart_jit", + "//third_party/dart/runtime/platform:libdart_platform_jit", + ] +} + +runner("dart_jit_product_runner_bin") { + output_name = "dart_jit_product_runner" + product = true + extra_defines = [ "DART_PRODUCT" ] + extra_deps = [ + "//third_party/dart/runtime:libdart_jit_product", + "//third_party/dart/runtime/platform:libdart_platform_jit_product", + ] +} + +template("jit_runner_package") { + assert(defined(invoker.product), "The parameter 'product' must be defined") + product_suffix = "" + if (invoker.product) { + product_suffix = "_product" + } + + package_dir(target_name) { deps = [ - ":dart_io_api", - "$flutter_root/common", - "$flutter_root/fml", - "$flutter_root/runtime:libdart", - "$flutter_root/shell/platform/fuchsia/dart-pkg/fuchsia", - "$flutter_root/shell/platform/fuchsia/dart-pkg/zircon", - "$flutter_root/shell/platform/fuchsia/runtime/dart/utils", - "$fuchsia_sdk_root/pkg:async-cpp", - "$fuchsia_sdk_root/pkg:async-loop", - "$fuchsia_sdk_root/pkg:async-loop-cpp", - "$fuchsia_sdk_root/pkg:fidl_cpp", - "$fuchsia_sdk_root/pkg:syslog", - "$fuchsia_sdk_root/pkg/lib/sys/cpp", - "$fuchsia_sdk_root/pkg/lib/vfs/cpp", - "//third_party/tonic", + ":dart_jit${product_suffix}_runner_bin", + "$flutter_runner_base/kernel:kernel_core_snapshot${product_suffix}", + ] + + if (!invoker.product) { + deps += [ observatory_target ] + } + + binary = "dart_jit${product_suffix}_runner" + + meta_dir = "$flutter_root/shell/platform/fuchsia/dart_runner/meta" + + snapshot_gen_dir = + "$root_build_dir/gen/flutter/shell/platform/fuchsia/flutter/kernel" + + libraries = common_libs + + resources = [ + { + path = rebase_path( + "$snapshot_gen_dir/vm_isolate_snapshot${product_suffix}.bin") + dest = "vm_snapshot_data.bin" + }, + { + path = rebase_path( + "$snapshot_gen_dir/vm_snapshot_instructions${product_suffix}.bin") + dest = "vm_snapshot_instructions.bin" + }, + { + path = rebase_path( + "$snapshot_gen_dir/isolate_snapshot${product_suffix}.bin") + dest = "isolate_core_snapshot_data.bin" + }, + { + path = rebase_path( + "$snapshot_gen_dir/isolate_snapshot_instructions${product_suffix}.bin") + dest = "isolate_core_snapshot_instructions.bin" + }, + ] + + if (!invoker.product) { + resources += [ + { + path = rebase_path(observatory_archive_file) + dest = "observatory.tar" + }, + ] + } + + meta = [ + { + path = rebase_path("meta/dart_jit${product_suffix}_runner.cmx") + dest = "dart_jit${product_suffix}_runner.cmx" + }, ] } } + +jit_runner_package("dart_jit_runner") { + product = false +} + +jit_runner_package("dart_jit_product_runner") { + product = true +} diff --git a/shell/platform/fuchsia/flutter/BUILD.gn b/shell/platform/fuchsia/flutter/BUILD.gn index 7e275b8635085..c0ee0e0ab5b81 100644 --- a/shell/platform/fuchsia/flutter/BUILD.gn +++ b/shell/platform/fuchsia/flutter/BUILD.gn @@ -8,6 +8,7 @@ import("//build/fuchsia/sdk.gni") import("$flutter_root/common/config.gni") import("$flutter_root/shell/gpu/gpu.gni") import("$flutter_root/tools/fuchsia/common_libs.gni") +import("$flutter_root/tools/fuchsia/dart.gni") import("$flutter_root/tools/fuchsia/package_dir.gni") shell_gpu_configuration("fuchsia_gpu_configuration") { @@ -195,13 +196,6 @@ flutter_runner("aot_product") { ] } -observatory_target = - "//third_party/dart/runtime/observatory:observatory_archive" -observatory_archive_dir = get_label_info(observatory_target, "target_gen_dir") -observatory_archive_name = get_label_info(observatory_target, "name") -observatory_archive_file = - "${observatory_archive_dir}/${observatory_archive_name}.tar" - template("jit_runner") { product = defined(invoker.product) && invoker.product @@ -226,6 +220,8 @@ template("jit_runner") { binary = "flutter_jit${product_suffix}_runner" + meta_dir = "$flutter_root/shell/platform/fuchsia/flutter/meta" + resources = [ { path = rebase_path("//third_party/icu/common/icudtl.dat") @@ -292,6 +288,8 @@ template("aot_runner") { deps += [ observatory_target ] } + meta_dir = "$flutter_root/shell/platform/fuchsia/flutter/meta" + binary = "flutter_aot${product_suffix}_runner" resources = [ diff --git a/tools/fuchsia/build_fuchsia_artifacts.py b/tools/fuchsia/build_fuchsia_artifacts.py index 05fd2b4a0e870..518050bbf2c2c 100755 --- a/tools/fuchsia/build_fuchsia_artifacts.py +++ b/tools/fuchsia/build_fuchsia_artifacts.py @@ -85,10 +85,10 @@ def CopyFiles(source, destination): raise -def CopyToBucketWithMode(source, destination, aot, product): +def CopyToBucketWithMode(source, destination, aot, product, runner_type): mode = 'aot' if aot else 'jit' product_suff = '_product' if product else '' - runner_name = 'flutter_%s%s_runner' % (mode, product_suff) + runner_name = '%s_%s%s_runner' % (runner_type, mode, product_suff) far_dir = '%s_far' % runner_name source_root = os.path.join(_out_dir, source) source = os.path.join(source_root, far_dir) @@ -104,9 +104,10 @@ def CopyToBucketWithMode(source, destination, aot, product): CopyPath(patched_sdk_dir, dest_sdk_path) -def CopyToBucket(src, dst, product = False): - CopyToBucketWithMode(src, dst, False, product) - CopyToBucketWithMode(src, dst, True, product) +def CopyToBucket(src, dst, product=False): + CopyToBucketWithMode(src, dst, False, product, 'flutter') + CopyToBucketWithMode(src, dst, True, product, 'flutter') + CopyToBucketWithMode(src, dst, False, product, 'dart') def BuildBucket(): @@ -138,9 +139,12 @@ def ProcessCIPDPakcage(upload, engine_version): subprocess.check_call(command, cwd=_bucket_directory) -def GetRunnerTarget(product, aot): - base = 'flutter/shell/platform/fuchsia/flutter:' - target = 'flutter_' +def GetRunnerTarget(runner_type, product, aot): + base = 'flutter/shell/platform/fuchsia/%s:' % runner_type + if 'dart' in runner_type: + target = 'dart_' + else: + target = 'flutter_' if aot: target += 'aot_' else: @@ -154,10 +158,10 @@ def GetRunnerTarget(product, aot): def GetTargetsToBuild(product=False): targets_to_build = [ # The Flutter Runner. - GetRunnerTarget(product, False), - GetRunnerTarget(product, True), + GetRunnerTarget('flutter', product, False), + GetRunnerTarget('flutter', product, True), # The Dart Runner. - # 'flutter/shell/platform/fuchsia/dart:dart', + GetRunnerTarget('dart_runner', product, False), ] return targets_to_build @@ -196,7 +200,7 @@ def main(): BuildBucket() - ProcessCIPDPakcage(args.upload, args.engine_version) + # ProcessCIPDPakcage(args.upload, args.engine_version) if __name__ == '__main__': diff --git a/tools/fuchsia/dart.gni b/tools/fuchsia/dart.gni index 5a0a2ee4845bc..2455974a76f7a 100644 --- a/tools/fuchsia/dart.gni +++ b/tools/fuchsia/dart.gni @@ -4,3 +4,10 @@ gen_snapshot = "//third_party/dart/runtime/bin:gen_snapshot" gen_snapshot_product = "//third_party/dart/runtime/bin:gen_snapshot_product" + +observatory_target = + "//third_party/dart/runtime/observatory:observatory_archive" +observatory_archive_dir = get_label_info(observatory_target, "target_gen_dir") +observatory_archive_name = get_label_info(observatory_target, "name") +observatory_archive_file = + "${observatory_archive_dir}/${observatory_archive_name}.tar" diff --git a/tools/fuchsia/package_dir.gni b/tools/fuchsia/package_dir.gni index 4373f87993358..93006f2ecd8cb 100644 --- a/tools/fuchsia/package_dir.gni +++ b/tools/fuchsia/package_dir.gni @@ -7,6 +7,7 @@ # This currently ignores the CMX files and does minimal validation. template("package_dir") { assert(defined(invoker.binary), "package must define binary") + assert(defined(invoker.meta_dir), "package must define meta_dir") pkg_target_name = target_name pkg = { @@ -18,6 +19,7 @@ template("package_dir") { "meta", "resources", "libraries", + "meta_dir", ]) if (!defined(package_name)) { package_name = pkg_target_name @@ -51,13 +53,13 @@ template("package_dir") { copy_outputs += [ "$far_base_dir/lib/${lib.name}" ] } - flutter_meta_dir = "$flutter_root/shell/platform/fuchsia/flutter/meta" + meta_dir = pkg.meta_dir cmx_target = "$pkg_target_name.copy_cmx" copy("$cmx_target") { sources = [ - "${flutter_meta_dir}/${pkg_target_name}.cmx", + "${meta_dir}/${pkg_target_name}.cmx", ] outputs = [ "$far_base_dir/meta/{{source_file_part}}",