diff --git a/DEPS b/DEPS index 9130e78e8ab6243819a81c09dd94efc94a39b4d9..94d94fc5b3a77ea4d68e04e7ad7c518057438a3f 100644 --- a/DEPS +++ b/DEPS @@ -116,7 +116,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'c82412bcdcd593f1385a478ae2c4b8eb9814f3b8', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + '4d5aa40f7424aa6bfbe0b27af1067ffd2e6ec25a', # Fuchsia compatibility # diff --git a/shell/platform/embedder/BUILD.gn b/shell/platform/embedder/BUILD.gn index 042d3ceced5ccca8f40b7baf1f971293a22ebbcf..0d4aedb0ddecda0f6b1c3a1ca08f8dc29bd3f495 100644 --- a/shell/platform/embedder/BUILD.gn +++ b/shell/platform/embedder/BUILD.gn @@ -38,7 +38,6 @@ source_set("embedder") { "$flutter_root/common", "$flutter_root/flow", "$flutter_root/fml", - "$flutter_root/lib/snapshot", "$flutter_root/shell/common", "//third_party/dart/runtime/bin:dart_io_api", "//third_party/skia", @@ -48,7 +47,10 @@ source_set("embedder") { if (flutter_runtime_mode == "profile" || flutter_runtime_mode == "release") { deps += [ "//third_party/dart/runtime:libdart_precompiled_runtime" ] } else { - deps += [ "//third_party/dart/runtime:libdart_jit" ] + deps += [ + "$flutter_root/lib/snapshot", + "//third_party/dart/runtime:libdart_jit", + ] } public_configs = [ "$flutter_root:config" ] diff --git a/shell/platform/embedder/tests/embedder_unittests.cc b/shell/platform/embedder/tests/embedder_unittests.cc index 7ddff1e96aafda8e5bf7219d4362bea2bbe037dc..f1345227c3aa85916f4731fed8a4f8d7dbaf5697 100644 --- a/shell/platform/embedder/tests/embedder_unittests.cc +++ b/shell/platform/embedder/tests/embedder_unittests.cc @@ -4,8 +4,38 @@ #include #include "embedder.h" +#include "flutter/fml/file.h" +#include "flutter/fml/mapping.h" #include "flutter/testing/testing.h" +namespace { + +void MapAOTAsset(std::vector>& aot_mappings, + const fml::UniqueFD& fixtures_dir, + const char* path, + bool executable, + const uint8_t** data, + size_t* size) { + fml::UniqueFD file = + fml::OpenFile(fixtures_dir, path, false, fml::FilePermission::kRead); + std::unique_ptr mapping; + if (executable) { + mapping = std::make_unique( + file, std::initializer_list{ + fml::FileMapping::Protection::kRead, + fml::FileMapping::Protection::kExecute}); + } else { + mapping = std::make_unique( + file, std::initializer_list{ + fml::FileMapping::Protection::kRead}); + } + *data = mapping->GetMapping(); + *size = mapping->GetSize(); + aot_mappings.emplace_back(std::move(mapping)); +} + +} // anonymous namespace + TEST(EmbedderTest, MustNotRunWithInvalidArgs) { FlutterEngine engine = nullptr; FlutterRendererConfig config = {}; @@ -34,6 +64,22 @@ TEST(EmbedderTest, CanLaunchAndShutdownWithValidProjectArgs) { ASSERT_EQ(str_data, "Data"); }; + fml::UniqueFD fixtures_dir = fml::OpenDirectory( + testing::GetFixturesPath(), false, fml::FilePermission::kRead); + std::vector> aot_mappings; + if (fml::FileExists(fixtures_dir, "vm_snapshot_data")) { + MapAOTAsset(aot_mappings, fixtures_dir, "vm_snapshot_data", false, + &args.vm_snapshot_data, &args.vm_snapshot_data_size); + MapAOTAsset(aot_mappings, fixtures_dir, "vm_snapshot_instr", true, + &args.vm_snapshot_instructions, + &args.vm_snapshot_instructions_size); + MapAOTAsset(aot_mappings, fixtures_dir, "isolate_snapshot_data", false, + &args.isolate_snapshot_data, &args.isolate_snapshot_data_size); + MapAOTAsset(aot_mappings, fixtures_dir, "isolate_snapshot_instr", true, + &args.isolate_snapshot_instructions, + &args.isolate_snapshot_instructions_size); + } + std::string str_data = "Data"; void* user_data = const_cast(str_data.c_str()); FlutterEngine engine = nullptr; diff --git a/testing/testing.gni b/testing/testing.gni index 1bb519b9993302b0e514271c2948c3312c499990..8d01b6810c044f88b75042aaacd57770cddd7b0f 100644 --- a/testing/testing.gni +++ b/testing/testing.gni @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("$flutter_root/common/config.gni") +import("//build/compiled_action.gni") import("//third_party/dart/build/dart/dart_action.gni") # Builds test fixtures for a unit test. @@ -21,7 +23,11 @@ template("test_fixtures") { testonly = true assert(defined(invoker.fixtures), "Test fixtures must be specified.") - kernel_out = "kernel_blob.bin" + if (flutter_runtime_mode == "profile" || flutter_runtime_mode == "release") { + kernel_out = "kernel_snapshot.dill" + } else { + kernel_out = "kernel_blob.bin" + } if (defined(invoker.kernel_out)) { kernel_out = invoker.kernel_out } @@ -69,21 +75,72 @@ template("test_fixtures") { inputs = fixture_paths outputs = ["$fixtures_location/$kernel_out"] - args = [ - "--sdk-root", rebase_path("$root_out_dir/flutter_patched_sdk"), - "--target", "flutter", - "--output-dill", rebase_path("$fixtures_location/$kernel_out"), - ] + fixture_paths deps = [ "//third_party/dart/utils/kernel-service:frontend_server" ] + + if (flutter_runtime_mode == "profile" || flutter_runtime_mode == "release") { + args = [ + "--sdk-root", rebase_path("$root_out_dir/flutter_patched_sdk"), + "--strong", + "--target=flutter", + "--aot", + "--tfa", + "-Ddart.vm.product=true", + "--output-dill", rebase_path("$fixtures_location/$kernel_out"), + ] + fixture_paths + + deps += [ "//flutter/lib/snapshot:strong_platform" ] + } else { + args = [ + "--sdk-root", rebase_path("$root_out_dir/flutter_patched_sdk"), + "--target", "flutter", + "--output-dill", rebase_path("$fixtures_location/$kernel_out"), + ] + fixture_paths + } } - group(target_name) { + fixtures_aot_target_name = target_name + "_aot" + compiled_action(fixtures_aot_target_name) { testonly = true + tool = "//third_party/dart/runtime/bin:gen_snapshot" + + inputs = [ + "$fixtures_location/$kernel_out" + ] + + outputs = [ + "$fixtures_location/vm_snapshot_data", + "$fixtures_location/vm_snapshot_instr", + "$fixtures_location/isolate_snapshot_data", + "$fixtures_location/isolate_snapshot_instr", + ] + + args = [ + "--causal_async_stacks", + "--deterministic", + "--snapshot_kind=app-aot-blobs", + "--vm_snapshot_data=" + rebase_path("$fixtures_location/vm_snapshot_data"), + "--vm_snapshot_instructions=" + rebase_path("$fixtures_location/vm_snapshot_instr"), + "--isolate_snapshot_data=" + rebase_path("$fixtures_location/isolate_snapshot_data"), + "--isolate_snapshot_instructions=" + rebase_path("$fixtures_location/isolate_snapshot_instr"), + rebase_path("$fixtures_location/$kernel_out") + ] + deps = [ ":$fixtures_kernel_target_name", + ] + } + + group(target_name) { + testonly = true + deps = [ ":$fixtures_source_set_target_name", ] + if (flutter_runtime_mode == "profile" || flutter_runtime_mode == "release") { + deps += [ ":$fixtures_aot_target_name" ] + } else { + deps += [ ":$fixtures_kernel_target_name" ] + } } }