-
Notifications
You must be signed in to change notification settings - Fork 6k
Add dart_executable gn rule #52241
Add dart_executable gn rule #52241
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -409,3 +409,117 @@ template("application_snapshot") { | |
| } | ||
| } | ||
| } | ||
|
|
||
| # Generates an executable from Dart code using `dart compile exe`. | ||
| # | ||
| # This rule is primarily intended to be used to compile test targets for use | ||
| # by engine developers to build and run test code written in Dart in the engine | ||
| # repo, in particular via the `et` tool. It is NOT intended for use in | ||
| # generating production-ready user-facing binaries. | ||
| # | ||
| # See: //flutter/tools/engine_tool for more information on `et`. | ||
| # | ||
| # Arguments | ||
| # main_dart (required): | ||
| # The Dart entrypoint file. | ||
| # | ||
| # package_config (optional): | ||
| # The packages.json file for the Dart package (if any). Required when | ||
| # building libraries that are part of packages with Dart dependencies. | ||
| # Not needed when building standalone Dart code that is not part of a | ||
| # package. | ||
| # | ||
| # output (optional): | ||
| # The output executable name. By default, the target name. On Windows, an | ||
| # 'exe' is automatically appended. | ||
| # | ||
| # deps (optional): | ||
| # Additional dependencies. Dependencies on the frontend server and | ||
| # Flutter's platform.dill are included by default. This rule creates and | ||
| # uses a depfile, so listing all Dart sources is not necessary. | ||
| template("dart_executable") { | ||
| assert(defined(invoker.main_dart), "Must specify 'main_dart'") | ||
|
|
||
| main_dart = invoker.main_dart | ||
|
|
||
| name = target_name | ||
|
|
||
| extra_deps = [] | ||
| if (defined(invoker.deps)) { | ||
| extra_deps += invoker.deps | ||
| } | ||
| extra_inputs = [ main_dart ] | ||
| if (defined(invoker.inputs)) { | ||
| extra_inputs += invoker.inputs | ||
| } | ||
| if (defined(invoker.package_config)) { | ||
| package_config = rebase_path(invoker.package_config, root_build_dir) | ||
| extra_inputs += [ package_config ] | ||
| } | ||
|
|
||
| ext = "" | ||
| if (is_win) { | ||
| ext = ".exe" | ||
| } | ||
| output = "$target_gen_dir/$name$ext" | ||
| if (defined(invoker.output)) { | ||
| output = invoker.output | ||
| } | ||
|
|
||
| exe_vm_args = [ "--deterministic" ] | ||
| if (defined(invoker.vm_args)) { | ||
| exe_vm_args += invoker.vm_args | ||
| } | ||
|
|
||
| abs_output = rebase_path(output, root_build_dir) | ||
| exe_vm_args += [ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how it's spelled, but we'll want to pass the flag here that disables analytics/telemetry. |
||
| "compile", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does Does
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's a good question. I haven't looked at the implementation. My guess is probably, which we should avoid. Will take a look.
Not one that's documented (even with |
||
| "exe", | ||
| "--output=$abs_output", | ||
| ] | ||
| if (defined(package_config)) { | ||
| exe_vm_args += [ "--packages=$package_config" ] | ||
| } | ||
|
|
||
| if (flutter_prebuilt_dart_sdk) { | ||
| action(target_name) { | ||
| forward_variables_from(invoker, | ||
| [ | ||
| "testonly", | ||
| "visibility", | ||
| ]) | ||
| deps = extra_deps | ||
| script = "//build/gn_run_binary.py" | ||
| inputs = extra_inputs | ||
| outputs = [ output ] | ||
| pool = "//flutter/build/dart:dart_pool" | ||
|
|
||
| dart = rebase_path("$host_prebuilt_dart_sdk/bin/dart$ext", root_build_dir) | ||
|
|
||
| args = [ dart ] | ||
| args += exe_vm_args | ||
| args += [ rebase_path(main_dart) ] | ||
| metadata = { | ||
| action_type = [ "dart_executable" ] | ||
| } | ||
| } | ||
| } else { | ||
| dart_action(target_name) { | ||
| forward_variables_from(invoker, | ||
| [ | ||
| "testonly", | ||
| "visibility", | ||
| ]) | ||
| script = main_dart | ||
| pool = "//flutter/build/dart:dart_pool" | ||
| deps = extra_deps | ||
| inputs = extra_inputs | ||
| outputs = [ output ] | ||
| vm_args = exe_vm_args | ||
| args = [] | ||
| metadata = { | ||
| action_type = [ "dart_executable" ] | ||
| } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll need to send a patch upstream to copy this over onto the underlying |
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # 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/build/dart/rules.gni") | ||
|
|
||
| dart_executable("engine_tool") { | ||
| main_dart = "bin/et.dart" | ||
| output = "$root_out_dir/et" | ||
| } | ||
|
|
||
| group("tests") { | ||
| testonly = true | ||
| public_deps = [ | ||
| ":build_command_test", | ||
| ":entry_point_test", | ||
| ":fetch_command_test", | ||
| ":format_command_test", | ||
| ":gn_utils_test", | ||
| ":lint_command_test", | ||
| ":logger_test", | ||
| ":proc_utils_test", | ||
| ":query_command_test", | ||
| ":run_command_test", | ||
| ":test_command_test", | ||
| ":worker_pool_test", | ||
| ] | ||
| } | ||
|
|
||
| dart_executable("build_command_test") { | ||
| testonly = true | ||
| main_dart = "test/build_command_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } | ||
|
|
||
| dart_executable("entry_point_test") { | ||
| testonly = true | ||
| main_dart = "test/entry_point_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } | ||
|
|
||
| dart_executable("fetch_command_test") { | ||
| testonly = true | ||
| main_dart = "test/fetch_command_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } | ||
|
|
||
| dart_executable("format_command_test") { | ||
| testonly = true | ||
| main_dart = "test/format_command_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } | ||
|
|
||
| dart_executable("gn_utils_test") { | ||
| testonly = true | ||
| main_dart = "test/gn_utils_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } | ||
|
|
||
| dart_executable("lint_command_test") { | ||
| testonly = true | ||
| main_dart = "test/lint_command_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } | ||
|
|
||
| dart_executable("logger_test") { | ||
| testonly = true | ||
| main_dart = "test/logger_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } | ||
|
|
||
| dart_executable("proc_utils_test") { | ||
| testonly = true | ||
| main_dart = "test/proc_utils_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } | ||
|
|
||
| dart_executable("query_command_test") { | ||
| testonly = true | ||
| main_dart = "test/query_command_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } | ||
|
|
||
| dart_executable("run_command_test") { | ||
| testonly = true | ||
| main_dart = "test/run_command_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } | ||
|
|
||
| dart_executable("test_command_test") { | ||
| testonly = true | ||
| main_dart = "test/test_command_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } | ||
|
|
||
| dart_executable("worker_pool_test") { | ||
| testonly = true | ||
| main_dart = "test/worker_pool_test.dart" | ||
| package_config = ".dart_tool/package_config.json" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't create a depfile as written =)