Conversation
mosuem
left a comment
There was a problem hiding this comment.
LGTM with some nits and more docs - but I like this API.
| } | ||
|
|
||
| /// Supports emitting code assets for build hooks. | ||
| extension type CodeAssetBuildOutputBuilderAdd._(BuildOutputBuilder _output) { |
There was a problem hiding this comment.
This name is giving me Java flashbacks - how about CodeAssetCollector?
| /// Code asset specific configuration. | ||
| CodeConfig get codeConfig => CodeConfig(this); | ||
| // Weird class that combines `CodeConfig` getters and a getter for code assets. | ||
| class LinkCodeConfig implements CodeConfig { |
There was a problem hiding this comment.
This is indeed a bit ugly, but I don't know a way around it...
There was a problem hiding this comment.
This doesn't seem very right to me. It mixes orthogonal concerns (code configuration and outputed assets)
| null => | ||
| throw StateError('Cannot access iOSConfig if targetOS is not iOS' | ||
| ' or in dry runs.'), | ||
| IOSConfig get iOS => switch (_iOSConfig) { |
There was a problem hiding this comment.
Nit: Why a switch instead of a simple if check?
| } | ||
|
|
||
| /// Extension on [LinkOutputBuilder] to emit code assets. | ||
| extension type CodeAssetLinkOutputBuilderAdd._(LinkOutputBuilder _output) { |
There was a problem hiding this comment.
Similarly verbose as above - and not very understandable...
Based on recent discussions with @mosuem @liamappelbe about what is used to hash the build directory and this PR restructuring, we may want to consider rename a few things and do the following // build hook
main(...) asyc {
await build((BuildInput input, BuildOutputBuilder output) {
input.outputDirectory;
input.config.{code,...} // <-- only this goes into hashing
input.metadata.* // <-- metadata emitted from package deps we can utilize
output.assets.code.add();
});
}
// link hook
main(...) asyc {
await link((LinkInput input, LinkOutputBuilder output) {
input.outputDirectory
input.config.{code,...}. // <-- only this goes into hashing
input.assets.{code,data,...} // <-- symmetric to `hook/build.dart`'s `output.assets.{code,data,...}`
output.assets.code.add();
});
}That would achieve
I prefer we don't use @dcharkes wdyt? |
|
Thanks @mkustermann and @mosuem for the input! I've replied to the refactoring suggestion in the original thread. Overall SGTM. I'll close this PR.
Please see #1829 where I explored that. |
Addresses:
BuildConfig.targetOStoBuildConfig.codeConfig.targetOS, remove it entirely or extend to cover web #1738 (comment)A variant of:
Configsuffixes v1 #1829This PR normalizes the
codeanddataspecific APIs on the config, config builder, output and output builders under a.codeand.dataextension.Example link hook code:
Example build hook code:
This drops
Configsuffixes from the various config accessors.This changes
output.codeAssets.add(tooutput.code.addAsset(.The weird quirk in this PR is that it has to provide an API for
LinkConfig.codethat gives both theCodeConfiggetters and anassetsgetter. I tried using extension types to alleviate this, but extension types can only extend the type they are extending, not the first element of a tuple they are extending.Separating the
linkConfig.code : CodeConfigandlinkConfig.assets.code : Iterable<CodeAsset>leads to a less symmetric API though:Configsuffixes v1 #1829Alternatively, we could also opt to land neither of the PRs. And stick with
config.codeConfig.androidConfigandoutput.codeAssets.