Skip to content

[native_assets_cli] Sharing work between build hooks #1379

Closed
@dcharkes

Description

@dcharkes

Build hooks are per OS/arch. However, if assets are identical across multiple invocations, and the work to produce those assets is non-trivial, such work should be shared.

Examples:

  • Data assets which are "compiled" (svg -> tessellated, 3d model -> bytes, translation json).
  • Native code assets which are downloaded as fat binaries (e.g. containing already MacOS arm64 and MacOS x64)

Non-examples:

  • Native code assets different per OS and per arch.
  • Data assets that are on disk already and are simply reported.

We have multiple avenues of sharing the work:

  1. Add documentation that the actual work should happen in .dart_tool/<your-package-name>.
  2. Make the output directory per asset type, and give the same output directory for data assets for all invocations.

Both of these options require hook writers to think about locking due to concurrent invocations of the build hook for different OSes/architectures. So whatever we come up with for #1319, should be made available in an API to hook writers.

Option (2) doesn't support sharing native code assets, so in for the second example, hook writers would still use option (1) even if we go for option (2).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onpackage:hooks

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions