Skip to content

[native_assets_cli] Provide a Builder abstraction #995

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

Closed
1 task done
dcharkes opened this issue Mar 12, 2024 · 1 comment · Fixed by #1174
Closed
1 task done

[native_assets_cli] Provide a Builder abstraction #995

dcharkes opened this issue Mar 12, 2024 · 1 comment · Fixed by #1174
Labels
P3 A lower priority bug or feature request package:hooks package:native_toolchain_c

Comments

@dcharkes
Copy link
Collaborator

dcharkes commented Mar 12, 2024

package:native_assets_cli defines:

abstract class Builder {
  Future<void> run({
    required BuildConfig config,
    required BuildOutput output,
    required Logger? logger,
  });
}

class CBuilder implements Builder {

In a sketch for an asset downloader we also have

class AssetDownloader implements Builder {

We should probably standardize the Builder interface somewhere so that they are composable.

This interacts slightly with hiding fields from the BuildConfig that aren't used:

It most likely means that run method implementing the interface should immediately shell out to another method that takes the interfaces/extension types that only show a subset of the getters on BuildConfig, and the more specific methods on BuildOutput.

Related issues:

@dcharkes
Copy link
Collaborator Author

We do the same for linker:

abstract class Linker {
  Future<void> run({
    required LinkConfig config,
    required LinkOutput output,
    required Logger? logger,
  });
}

class CLinker implements Linker {

We don't want a shared run:

abstract class Linker {
  Future<void> run({
    required HookConfig config,
    required HookOutput output,
    required Logger? logger,
  });
}

Reasoning for not having a shared run is that caching behavior is different for build hooks and link hooks. Build hooks are rerun much less often than link hooks. So downloading assets and building code should always be done in the build hook, even if the dylib might not be included in the end. (If you only download or build in the link hook, you might save a build or download on the first run, but it will have to be rerun very often.)

auto-submit bot pushed a commit that referenced this issue May 29, 2024
…1174)

This PR adds an opinionated `Builder` and `Linker` interface with documentation on what builders and linkers should be used for.

Closes: #995

(Also, flips all versions back to WIP, now that the link hooks have landed in both Dart and Flutter.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 A lower priority bug or feature request package:hooks package:native_toolchain_c
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant