Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Make package_config optional
  • Loading branch information
cbracken committed Sep 10, 2024
commit f25a33f348614346d9920c00cfecd1da50ab1c5d
30 changes: 20 additions & 10 deletions build/dart/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,24 @@ template("application_snapshot") {
}
}

# Generates a Dart executable using `dart compile exe`
# 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 (required):
# The packages.json file for the app.
# 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
Expand All @@ -432,22 +442,20 @@ template("dart_executable") {

main_dart = invoker.main_dart

package_config = rebase_path(".dart_tool/package_config.json")
if (defined(invoker.package_config)) {
package_config = rebase_path(invoker.package_config)
}
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
}
extra_inputs += [ package_config ]
if (defined(invoker.package_config)) {
package_config = rebase_path(invoker.package_config)
extra_inputs += [ package_config ]
}

ext = ""
if (is_win) {
Expand All @@ -467,9 +475,11 @@ template("dart_executable") {
exe_vm_args += [
Copy link
Member

Choose a reason for hiding this comment

The 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",
Copy link
Member

Choose a reason for hiding this comment

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

Does dart compile exe run pub? If so, we'll need a way to keep it from touching the network.

Does dart compile exe have a flag that causes it to dump a depfile like flutter_frontend_server does? See https://github.com/flutter/engine/blob/main/build/dart/rules.gni#L71. Without that, GN won't do dependency tracking correctly. You might be able to see that in this PR by editing et source files, and seeing that rebuilds might not happen when you need them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Does dart compile exe run pub?

That's a good question. I haven't looked at the implementation. My guess is probably, which we should avoid. Will take a look.

Does dart compile exe have a flag that causes it to dump a depfile like flutter_frontend_server does?

Not one that's documented (even with -v -v set). This patch is still a draft experiment to test the general concept/tool integration. It should work even if we swap out the implementation with an invocation of dart_snapshot (wrapped with a launch script) instead, that approach does support --depfile (and is already implemented above). Will play with that a little.

"exe",
"--packages=$package_config",
"--output=$abs_output",
]
if (defined(package_config)) {
exe_vm_args += [ "--packages=$package_config" ]
}

if (flutter_prebuilt_dart_sdk) {
action(target_name) {
Expand Down
12 changes: 12 additions & 0 deletions tools/engine_tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,59 +30,71 @@ group("tests") {
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"
}