Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 2455f20

Browse files
[fuchsia] Make it easy to flip the whole system between flutter_jit_app and flutter_aot_app. (#3873)
1 parent 316fa7e commit 2455f20

File tree

2 files changed

+62
-28
lines changed

2 files changed

+62
-28
lines changed

build/flutter_app.gni

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import("//flutter/lib/ui/dart_ui.gni")
1010
import("//apps/mozart/lib/flutter/sdk_ext/sdk_ext.gni")
1111
import("//lib/fidl/dart/sdk_ext/sdk_ext.gni")
1212

13+
declare_args() {
14+
flutter_app_default_is_jit = true
15+
}
16+
1317
gen_snapshot_label = "//dart/runtime/bin:gen_snapshot($host_toolchain)"
1418
gen_snapshot_dir = get_label_info(gen_snapshot_label, "root_out_dir")
1519
gen_snapshot = "$gen_snapshot_dir/gen_snapshot"
@@ -19,33 +23,7 @@ flutter_tools_label = "$flutter_root/packages/flutter_tools:fuchsia_builder($hos
1923
flutter_tools_out_dir = get_label_info(flutter_tools_label, "root_out_dir")
2024
flutter_tools_bin = "$flutter_tools_out_dir/dart-tools/fuchsia_builder"
2125

22-
# Defines a Flutter application
23-
#
24-
# Parameters
25-
#
26-
# main_dart (required)
27-
# Name of the Dart file containing the main function.
28-
#
29-
# package_name (optional)
30-
# Name of the Dart package.
31-
#
32-
# output_name (optional)
33-
# Name of output to generate. Defaults to $target_name.flx.
34-
#
35-
# deps (optional)
36-
# List of Dart packages the application depends on.
37-
#
38-
# manifest (optional)
39-
# Path to the manifest file
40-
#
41-
# analysis_options (optional)
42-
# By default, a script to run the analyzer on the contents of the package is
43-
# generated in the output directory. This parameter contains the path to an
44-
# analysis options file for this target.
45-
#
46-
# disable_analysis (optional)
47-
# Prevents the analysis script from being generated.
48-
template("flutter_app") {
26+
template("flutter_jit_app") {
4927
assert(defined(invoker.main_dart), "Must define main_dart")
5028

5129
dart_package_name = target_name + "_dart_package"
@@ -377,3 +355,59 @@ template("flutter_aot_app") {
377355
]
378356
}
379357
}
358+
359+
# Defines a Flutter application
360+
#
361+
# Parameters
362+
#
363+
# main_dart (required)
364+
# Name of the Dart file containing the main function.
365+
#
366+
# package_name (optional)
367+
# Name of the Dart package.
368+
#
369+
# output_name (optional)
370+
# Name of output to generate. Defaults to $target_name.flx.
371+
#
372+
# deps (optional)
373+
# List of Dart packages the application depends on.
374+
#
375+
# manifest (optional)
376+
# Path to the manifest file
377+
#
378+
# analysis_options (optional)
379+
# By default, a script to run the analyzer on the contents of the package is
380+
# generated in the output directory. This parameter contains the path to an
381+
# analysis options file for this target.
382+
#
383+
# disable_analysis (optional)
384+
# Prevents the analysis script from being generated.
385+
template("flutter_app") {
386+
if (flutter_app_default_is_jit) {
387+
flutter_jit_app(target_name) {
388+
forward_variables_from(invoker,
389+
[
390+
"main_dart",
391+
"package_name",
392+
"output_name",
393+
"deps",
394+
"manifest",
395+
"analysis_options",
396+
"source_dir"
397+
])
398+
}
399+
} else {
400+
flutter_aot_app(target_name) {
401+
forward_variables_from(invoker,
402+
[
403+
"main_dart",
404+
"package_name",
405+
"output_name",
406+
"deps",
407+
"manifest",
408+
"analysis_options",
409+
"source_dir"
410+
])
411+
}
412+
}
413+
}

examples/hello_flutter/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import("//flutter/build/flutter_app.gni")
66

7-
flutter_app("hello_flutter") {
7+
flutter_jit_app("hello_flutter") {
88
main_dart = "lib/main.dart"
99

1010
deps = [

0 commit comments

Comments
 (0)