Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 61 additions & 27 deletions build/flutter_app.gni
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import("//flutter/lib/ui/dart_ui.gni")
import("//apps/mozart/lib/flutter/sdk_ext/sdk_ext.gni")
import("//lib/fidl/dart/sdk_ext/sdk_ext.gni")

declare_args() {
flutter_app_default_is_jit = true
}

gen_snapshot_label = "//dart/runtime/bin:gen_snapshot($host_toolchain)"
gen_snapshot_dir = get_label_info(gen_snapshot_label, "root_out_dir")
gen_snapshot = "$gen_snapshot_dir/gen_snapshot"
Expand All @@ -18,33 +22,7 @@ flutter_tools_label = "$flutter_root/packages/flutter_tools:fuchsia_builder($hos
flutter_tools_out_dir = get_label_info(flutter_tools_label, "root_out_dir")
flutter_tools_bin = "$flutter_tools_out_dir/dart-tools/fuchsia_builder"

# Defines a Flutter application
#
# Parameters
#
# main_dart (required)
# Name of the Dart file containing the main function.
#
# package_name (optional)
# Name of the Dart package.
#
# output_name (optional)
# Name of output to generate. Defaults to $target_name.flx.
#
# deps (optional)
# List of Dart packages the application depends on.
#
# manifest (optional)
# Path to the manifest file
#
# analysis_options (optional)
# By default, a script to run the analyzer on the contents of the package is
# generated in the output directory. This parameter contains the path to an
# analysis options file for this target.
#
# disable_analysis (optional)
# Prevents the analysis script from being generated.
template("flutter_app") {
template("flutter_jit_app") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "flutter_dynamic_app" or "dynamic_flutter_app"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And "flutter_static_app" or "static_flutter_app" below.

assert(defined(invoker.main_dart), "Must define main_dart")

dart_package_name = target_name + "_dart_package"
Expand Down Expand Up @@ -374,3 +352,59 @@ template("flutter_aot_app") {
]
}
}

# Defines a Flutter application
#
# Parameters
#
# main_dart (required)
# Name of the Dart file containing the main function.
#
# package_name (optional)
# Name of the Dart package.
#
# output_name (optional)
# Name of output to generate. Defaults to $target_name.flx.
#
# deps (optional)
# List of Dart packages the application depends on.
#
# manifest (optional)
# Path to the manifest file
#
# analysis_options (optional)
# By default, a script to run the analyzer on the contents of the package is
# generated in the output directory. This parameter contains the path to an
# analysis options file for this target.
#
# disable_analysis (optional)
# Prevents the analysis script from being generated.
template("flutter_app") {
if (flutter_app_default_is_jit) {
flutter_jit_app(target_name) {
forward_variables_from(invoker,
[
"main_dart",
"package_name",
"output_name",
"deps",
"manifest",
"analysis_options",
"source_dir"
])
}
} else {
flutter_aot_app(target_name) {
forward_variables_from(invoker,
[
"main_dart",
"package_name",
"output_name",
"deps",
"manifest",
"analysis_options",
"source_dir"
])
}
}
}
2 changes: 1 addition & 1 deletion examples/hello_flutter/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

flutter_app("hello_flutter") {
flutter_jit_app("hello_flutter") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to change? I thought most clients would use flutter_app and follow external configuration?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea here is to build the hello_flutter app both ways to make sure that both ways work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent is to ensure there's at least one app built both ways. There's a flutter_aot_app just below here.

main_dart = "lib/main.dart"

deps = [
Expand Down