mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
As of the migration to Dart 2, it has been necessary to compile Dart to kernel prior to execution. The embedder currently requires that the resulting kernel file be named `kernel_blob.bin` and be located at the root of the assets directory passed to the embedder API. This patch updates the test_fixtures build rule to perform a kernel compile using frontend_server, outputting `kernel_blob.bin` to `fixtures/test_target_name` directory, and updates the embedder unittests to specify the kernel file rather than the Dart source file. Since the kernel compiler requires a `main()` function to be defined, it also updates `simple_main.dart` from runtime_unittests to define `main()` rather than `simple_main()`. This also updates all existing sub-targets to be testonly. This relands commit ac9e521a1ddbb99816a93d92ce9fb70e950b3763, which was reverted in commit 494112582932af98b282617d7a34b1fbb8c90307. Rather than running as prebuilt_dart_action, we use dart_action to ensure the frontend snapshot it compatible with the VM on which it's executed.
77 lines
2.1 KiB
Plaintext
77 lines
2.1 KiB
Plaintext
# 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("//third_party/dart/build/dart/dart_action.gni")
|
|
|
|
# Builds test fixtures for a unit test.
|
|
#
|
|
# Generates a directory structure containing an assets directory and the Dart
|
|
# code to execute compiled to kernel, emitted to assets/kernel_blob.bin.
|
|
template("test_fixtures") {
|
|
testonly = true
|
|
|
|
assert(defined(invoker.fixtures), "Test fixtures must be specified.")
|
|
|
|
fixtures_location = "$target_gen_dir/$target_name/assets"
|
|
fixtures_location_file = "$target_gen_dir/$target_name/test_fixtures_location.cc"
|
|
|
|
fixtures_name_target_name = target_name + "_gen_fixtures_name"
|
|
action(fixtures_name_target_name) {
|
|
script = "$flutter_root/testing/build/gen_fixtures_location_symbol.py"
|
|
|
|
outputs = [
|
|
fixtures_location_file,
|
|
]
|
|
|
|
args = [
|
|
"--fixtures_location_file",
|
|
rebase_path(fixtures_location_file),
|
|
"--fixtures_location",
|
|
rebase_path(fixtures_location),
|
|
]
|
|
}
|
|
|
|
fixtures_source_set_target_name = target_name + "_gen_fixtures_source_set"
|
|
source_set(fixtures_source_set_target_name) {
|
|
testonly = true
|
|
sources = [
|
|
fixtures_location_file,
|
|
]
|
|
|
|
deps = [
|
|
":$fixtures_name_target_name",
|
|
]
|
|
}
|
|
|
|
fixtures_kernel_target_name = target_name + "_kernel"
|
|
dart_action(fixtures_kernel_target_name) {
|
|
testonly = true
|
|
script = "$root_out_dir/frontend_server.dart.snapshot"
|
|
|
|
fixture_paths = []
|
|
foreach(fixture, invoker.fixtures) {
|
|
fixture_paths += [ rebase_path(fixture) ]
|
|
}
|
|
inputs = fixture_paths
|
|
outputs = ["$fixtures_location/kernel_blob.bin"]
|
|
|
|
args = [
|
|
"--sdk-root", rebase_path("$root_out_dir/flutter_patched_sdk"),
|
|
"--target", "flutter",
|
|
"--output-dill", rebase_path("$fixtures_location/kernel_blob.bin"),
|
|
] + fixture_paths
|
|
deps = [
|
|
"//third_party/dart/utils/kernel-service:frontend_server"
|
|
]
|
|
}
|
|
|
|
group(target_name) {
|
|
testonly = true
|
|
deps = [
|
|
":$fixtures_kernel_target_name",
|
|
":$fixtures_source_set_target_name",
|
|
]
|
|
}
|
|
}
|