forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.gni
146 lines (126 loc) · 4.5 KB
/
testing.gni
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# 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/common/config.gni")
import("//build/compiled_action.gni")
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. Generates:
# * an asserts directory at `$target_name/assets`.
# * a C++ implementation for `flutter/testing/testing.h`, defining
# `testing::GetFixturesPath()`, which returns the assets path.
# * a kernel snapshot at `$target_name/assets/$kernel_out`.
#
# Rule attributes:
# * fixtures: list of Dart files, including a main entrypoint.
# * kernel_out: the output path, relative to the assets directory, of the
# generated kernel snapshot. By default, `kernel_blob.bin`.
template("test_fixtures") {
testonly = true
assert(defined(invoker.fixtures), "Test fixtures must be specified.")
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
}
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_out"]
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
}
}
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" ]
}
}
}