Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dart_executable gn rule #52241

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

cbracken
Copy link
Member

Adds a dart_executable rule that compiles Dart code to an ELF, Mach-O, or PE binary. Can be used to build tools written in Dart, or Dart unit tests.

Issue: flutter/flutter#147013

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I added at least one unnecessary checkbox just to see if anyone actually reads these things.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@cbracken cbracken marked this pull request as draft April 19, 2024 05:27
build/dart/rules.gni Outdated Show resolved Hide resolved
args = []
metadata = {
action_type = [ "dart_executable" ]
}
Copy link
Member Author

Choose a reason for hiding this comment

The 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 action target in the dart_action template.

build/dart/rules.gni Outdated Show resolved Hide resolved
@cbracken cbracken force-pushed the dart-executable branch 2 times, most recently from fc7ba2c to 827f0a2 Compare April 22, 2024 18:25
}

abs_output = rebase_path(output)
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.

build/dart/rules.gni Outdated Show resolved Hide resolved
build/dart/rules.gni Outdated Show resolved Hide resolved

abs_output = rebase_path(output)
exe_vm_args += [
"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.

#
# deps (optional):
# Additional dependencies. Dependencies on the frontend server and
# Flutter's platform.dill are included by default. This rule creates and
Copy link
Member

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 =)

Adds a dart_executable rule that compiles Dart code to an ELF, Mach-O,
or PE binary. Can be used to build tools written in Dart, or Dart unit
tests.

Issue: flutter/flutter#147013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants