From b6c1f3ca0ce5a6bd3845c6fb261bdcfb5639e5cb Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Wed, 12 Jul 2017 18:01:19 -0700 Subject: [PATCH 1/2] [fuchsia] Make it easy to flip the whole system between flutter_jit_app and flutter_aot_app. --- build/flutter_app.gni | 84 ++++++++++++++++++++++----------- examples/hello_flutter/BUILD.gn | 2 +- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/build/flutter_app.gni b/build/flutter_app.gni index a4576035a2d18..899e59a9254cb 100644 --- a/build/flutter_app.gni +++ b/build/flutter_app.gni @@ -18,33 +18,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") { assert(defined(invoker.main_dart), "Must define main_dart") dart_package_name = target_name + "_dart_package" @@ -374,3 +348,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 (true) { + 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" + ]) + } + } +} diff --git a/examples/hello_flutter/BUILD.gn b/examples/hello_flutter/BUILD.gn index 2385019a3ea27..ad0b8922e790e 100644 --- a/examples/hello_flutter/BUILD.gn +++ b/examples/hello_flutter/BUILD.gn @@ -4,7 +4,7 @@ import("//flutter/build/flutter_app.gni") -flutter_app("hello_flutter") { +flutter_jit_app("hello_flutter") { main_dart = "lib/main.dart" deps = [ From 7e6eabe0476374af7d6e9ad0cf577be842a6700d Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Fri, 14 Jul 2017 16:13:37 -0700 Subject: [PATCH 2/2] gn flag --- build/flutter_app.gni | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build/flutter_app.gni b/build/flutter_app.gni index 899e59a9254cb..9aea24d3319f8 100644 --- a/build/flutter_app.gni +++ b/build/flutter_app.gni @@ -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" @@ -376,7 +380,7 @@ template("flutter_aot_app") { # disable_analysis (optional) # Prevents the analysis script from being generated. template("flutter_app") { - if (true) { + if (flutter_app_default_is_jit) { flutter_jit_app(target_name) { forward_variables_from(invoker, [