From 3e0cff2a6142c0f07fea7a84a3ceb9e36d1db5bb Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Fri, 26 Jul 2019 10:19:13 -0700 Subject: [PATCH] [fuchsia] Add support for aot mode in flutter runner (#10171) * [fuchsia] Add support for aot mode in flutter runner * [fuchsia] Bundle observatory with not product runners --- shell/platform/fuchsia/flutter/BUILD.gn | 146 ++++++++++++++--------- tools/fuchsia/build_fuchsia_artifacts.py | 39 ++++-- tools/fuchsia/common_libs.gni | 67 +++++++++++ 3 files changed, 183 insertions(+), 69 deletions(-) create mode 100644 tools/fuchsia/common_libs.gni diff --git a/shell/platform/fuchsia/flutter/BUILD.gn b/shell/platform/fuchsia/flutter/BUILD.gn index b841682cbb..7e275b8635 100644 --- a/shell/platform/fuchsia/flutter/BUILD.gn +++ b/shell/platform/fuchsia/flutter/BUILD.gn @@ -5,8 +5,9 @@ assert(is_fuchsia) import("//build/fuchsia/sdk.gni") +import("$flutter_root/common/config.gni") import("$flutter_root/shell/gpu/gpu.gni") -import("$flutter_root/tools/fuchsia/clang.gni") +import("$flutter_root/tools/fuchsia/common_libs.gni") import("$flutter_root/tools/fuchsia/package_dir.gni") shell_gpu_configuration("fuchsia_gpu_configuration") { @@ -162,6 +163,9 @@ flutter_runner("jit_product") { flutter_runner("jit") { output_name = "flutter_jit_runner" product = false + if (flutter_runtime_mode == "profile") { + extra_defines = [ "FLUTTER_PROFILE" ] + } extra_deps = [ "//third_party/dart/runtime:libdart_jit", @@ -169,6 +173,28 @@ flutter_runner("jit") { ] } +flutter_runner("aot") { + output_name = "flutter_aot_runner" + product = false + if (flutter_runtime_mode == "profile") { + extra_defines = [ "FLUTTER_PROFILE" ] + } + extra_deps = [ + "//third_party/dart/runtime:libdart_precompiled_runtime", + "//third_party/dart/runtime/platform:libdart_platform_precompiled_runtime", + ] +} + +flutter_runner("aot_product") { + output_name = "flutter_aot_product_runner" + product = true + extra_defines = [ "DART_PRODUCT" ] + extra_deps = [ + "//third_party/dart/runtime:libdart_precompiled_runtime_product", + "//third_party/dart/runtime/platform:libdart_platform_precompiled_runtime_product", + ] +} + observatory_target = "//third_party/dart/runtime/observatory:observatory_archive" observatory_archive_dir = get_label_info(observatory_target, "target_gen_dir") @@ -194,6 +220,10 @@ template("jit_runner") { "kernel:kernel_core_snapshot${product_suffix}", ] + if (!product) { + deps += [ observatory_target ] + } + binary = "flutter_jit${product_suffix}_runner" resources = [ @@ -203,6 +233,15 @@ template("jit_runner") { }, ] + if (!product) { + resources += [ + { + path = rebase_path(observatory_archive_file) + dest = "observatory.tar" + }, + ] + } + resources += [ { path = rebase_path( @@ -226,77 +265,70 @@ template("jit_runner") { }, ] - fuchsia_sdk_base = "//fuchsia/sdk/$host_os/arch/$host_cpu" - fuchsia_sdk_lib = "$fuchsia_sdk_base/lib" - sysroot_lib = "$fuchsia_sdk_base/sysroot/lib" - sysroot_dist_lib = "$fuchsia_sdk_base/sysroot/dist/lib" + libraries = common_libs - libraries = [ - { - name = "libasync-default.so" - path = rebase_path("$fuchsia_sdk_lib") - }, - { - name = "libtrace-engine.so" - path = rebase_path("$fuchsia_sdk_lib") - }, - { - name = "libfdio.so" - path = rebase_path("$fuchsia_sdk_lib") - }, - { - name = "libmemfs.so" - path = rebase_path("$fuchsia_sdk_lib") - }, - { - name = "libsyslog.so" - path = rebase_path("$fuchsia_sdk_lib") - }, - { - name = "libvulkan.so" - path = rebase_path("$fuchsia_sdk_lib") - }, - { - name = "libzircon.so" - path = rebase_path("$sysroot_lib") - }, - { - name = "libc.so" - path = rebase_path("$sysroot_lib") - }, + meta = [ { - name = "ld.so.1" - path = rebase_path("$sysroot_dist_lib") + path = rebase_path("meta/flutter_jit${product_suffix}_runner.cmx") + dest = "flutter_jit${product_suffix}_runner.cmx" }, + ] + } +} - # Note, we use the md5 hashes here because of gn limitations of json parsing. - # This is a hack, and we can migrate to a better way soon. - { - name = "libc++.so.2" - path = rebase_path( - "$clang_base/${clang_manifest_json.md5_33bfe15b05ada4ed326fbc33adb39b95}") - }, - { - name = "libc++abi.so.1" - path = rebase_path( - "$clang_base/${clang_manifest_json.md5_916c01a85e3353f124776599819ecb1c}") - }, +template("aot_runner") { + product = defined(invoker.product) && invoker.product + product_suffix = "" + if (product) { + product_suffix = "_product" + } + + package_dir(target_name) { + deps = [ + ":aot${product_suffix}", + ] + + if (!product) { + deps += [ observatory_target ] + } + + binary = "flutter_aot${product_suffix}_runner" + + resources = [ { - name = "libunwind.so.1" - path = rebase_path( - "$clang_base/${clang_manifest_json.md5_beb70f40d525448b39ea87d9f5811e56}") + path = rebase_path("//third_party/icu/common/icudtl.dat") + dest = "icudtl.dat" }, ] + if (!product) { + resources += [ + { + path = rebase_path(observatory_archive_file) + dest = "observatory.tar" + }, + ] + } + + libraries = common_libs + meta = [ { - path = rebase_path("meta/flutter_jit${product_suffix}_runner.cmx") - dest = "flutter_jit${product_suffix}_runner.cmx" + path = rebase_path("meta/flutter_aot${product_suffix}_runner.cmx") + dest = "flutter_aot${product_suffix}_runner.cmx" }, ] } } +aot_runner("flutter_aot_runner") { + product = false +} + +aot_runner("flutter_aot_product_runner") { + product = true +} + jit_runner("flutter_jit_runner") { product = false } diff --git a/tools/fuchsia/build_fuchsia_artifacts.py b/tools/fuchsia/build_fuchsia_artifacts.py index ae8a9ede82..05fd2b4a0e 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 CopyToBucket(source, destination, product=False): - runner_name = 'flutter_jit_runner' - if product: - runner_name = 'flutter_jit_product_runner' +def CopyToBucketWithMode(source, destination, aot, product): + mode = 'aot' if aot else 'jit' + product_suff = '_product' if product else '' + runner_name = 'flutter_%s%s_runner' % (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) @@ -96,11 +96,17 @@ def CopyToBucket(source, destination, product=False): pm_bin = GetPMBinPath() key_path = os.path.join(_script_dir, 'development.key') - destination = os.path.join(_bucket_directory, destination) + destination = os.path.join(_bucket_directory, destination, mode) CreateFarPackage(pm_bin, source, key_path, destination) patched_sdk_dir = os.path.join(source_root, 'flutter_runner_patched_sdk') dest_sdk_path = os.path.join(destination, 'flutter_runner_patched_sdk') - CopyPath(patched_sdk_dir, dest_sdk_path) + if not os.path.exists(dest_sdk_path): + CopyPath(patched_sdk_dir, dest_sdk_path) + + +def CopyToBucket(src, dst, product = False): + CopyToBucketWithMode(src, dst, False, product) + CopyToBucketWithMode(src, dst, True, product) def BuildBucket(): @@ -132,15 +138,24 @@ def ProcessCIPDPakcage(upload, engine_version): subprocess.check_call(command, cwd=_bucket_directory) +def GetRunnerTarget(product, aot): + base = 'flutter/shell/platform/fuchsia/flutter:' + target = 'flutter_' + if aot: + target += 'aot_' + else: + target += 'jit_' + if product: + target += 'product_' + target += 'runner' + return base + target + + def GetTargetsToBuild(product=False): - product_suffix = '_product' - if not product: - product_suffix = '' targets_to_build = [ # The Flutter Runner. - 'flutter/shell/platform/fuchsia/flutter:flutter_jit%s_runner' % - product_suffix, - + GetRunnerTarget(product, False), + GetRunnerTarget(product, True), # The Dart Runner. # 'flutter/shell/platform/fuchsia/dart:dart', ] diff --git a/tools/fuchsia/common_libs.gni b/tools/fuchsia/common_libs.gni new file mode 100644 index 0000000000..c3f88fbb15 --- /dev/null +++ b/tools/fuchsia/common_libs.gni @@ -0,0 +1,67 @@ +# 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("$flutter_root/tools/fuchsia/clang.gni") + +fuchsia_sdk_base = "//fuchsia/sdk/$host_os/arch/$host_cpu" +fuchsia_sdk_lib = "$fuchsia_sdk_base/lib" +sysroot_lib = "$fuchsia_sdk_base/sysroot/lib" +sysroot_dist_lib = "$fuchsia_sdk_base/sysroot/dist/lib" + +common_libs = [ + { + name = "libasync-default.so" + path = rebase_path("$fuchsia_sdk_lib") + }, + { + name = "libtrace-engine.so" + path = rebase_path("$fuchsia_sdk_lib") + }, + { + name = "libfdio.so" + path = rebase_path("$fuchsia_sdk_lib") + }, + { + name = "libmemfs.so" + path = rebase_path("$fuchsia_sdk_lib") + }, + { + name = "libsyslog.so" + path = rebase_path("$fuchsia_sdk_lib") + }, + { + name = "libvulkan.so" + path = rebase_path("$fuchsia_sdk_lib") + }, + { + name = "libzircon.so" + path = rebase_path("$sysroot_lib") + }, + { + name = "libc.so" + path = rebase_path("$sysroot_lib") + }, + { + name = "ld.so.1" + path = rebase_path("$sysroot_dist_lib") + }, + + # Note, we use the md5 hashes here because of gn limitations of json parsing. + # This is a hack, and we can migrate to a better way soon. + { + name = "libc++.so.2" + path = rebase_path( + "$clang_base/${clang_manifest_json.md5_33bfe15b05ada4ed326fbc33adb39b95}") + }, + { + name = "libc++abi.so.1" + path = rebase_path( + "$clang_base/${clang_manifest_json.md5_916c01a85e3353f124776599819ecb1c}") + }, + { + name = "libunwind.so.1" + path = rebase_path( + "$clang_base/${clang_manifest_json.md5_beb70f40d525448b39ea87d9f5811e56}") + }, +] -- GitLab