Skip to content

Tool support for passing in pre-built macro binaries #53710

@jakemac53

Description

@jakemac53

For running internally at least, we will want the ability to pass in pre-built binaries for macros to all tools, instead of having them do their own compilation of macros. In particular, the source files for macros would ideally not even be made available, only their summary/outline files, which means that compilation is not possible.

Note that this only applies to tools which are directly invoked by the build rules internally, we don't need to pre-emptively add support beyond that for now. But we will likely need API support from the analyzer/cfe to support this.

We should align on the command line arguments for this across tools so that we can integrate with them more easily and have consistency. I propose the following arguments, based largely what the frontend_server already supports:

--precompiled-macro

Informs the tool of the binary to be used for all macros defined in a given library.

Usage: --precompiled-macro=<absolute-path-to-binary>;<macro-library-uri-1>;<macro-library-uri-2>

Example: -precompiled-macro="/path/to/compiled/macro;package:some_macro/some_macro.dart

This would be a multi-option so you can pass as many of these as you need.

See existing option configuration here. This is the same but supporting multiple macro libraries, and swapping the order to support that better.

[Optional] --precompiled-macro-format

For now, only AOT mode needs to be supported as this is what initial prototypes will use.

Informs the tool of the type of binary that is provided (kernel file and aot binary are supported for now).

Usage: --precompiled-macro-format=<aot|kernel>

Example: --precompiled-macro-format=aot

Default: aot

This is a single option, all precompiled macros must use the same format.

See existing option configuration here.

[Optional] --macro-serialization-mode

The frontend_server does support a mode for customizing whether JSON or a custom byte data format is used, but the JSON format is really only for debugging purposes. I don't think we need to pre-emptively add support for this.

[Optional] --macro-communication-channel

Informs the tool of which communication channel to use when talking to a macros.

Usage: --macro-communication-channel=<socket|stdio>

Example: --macro-communication-channel=stdio

Default: socket

This is a single option, all precompiled macros must use the same format.

Tracking:

  • analyzer worker
  • analyzer based codegen rules
  • kernel worker

Metadata

Metadata

Assignees

Labels

area-google3Tracking issues for internal work. Note that this area is not triaged.feature-macrosImplementation of the macros feature

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions