[native_assets] Preparation existing tests for future of other (i.e. non-Code) assets (#160436)

In the future a hook may be invoked multiple times with different
`supportedAssetTypes` (soon to be renamed to `buildAssetTypes`).

The hook should only emit those asset types that are in
`supportedAssetTypes` - anything else is an error. Right now flutter
happens to invoke hooks only with `Code` asset types, but more asset
types are coming, for which this PR is a preparation for.
This commit is contained in:
Martin Kustermann
2024-12-20 18:46:55 +01:00
committed by GitHub
parent a5902458c6
commit 181f4244b4
4 changed files with 20 additions and 8 deletions

View File

@@ -9,6 +9,10 @@ import 'package:native_toolchain_c/native_toolchain_c.dart';
void main(List<String> args) async {
await build(args, (BuildConfig config, BuildOutputBuilder output) async {
if (!config.supportedAssetTypes.contains(CodeAsset.type)) {
return;
}
final String assetName;
if (config.linkingEnabled) {
// The link hook will be run. So emit an asset with a name that is

View File

@@ -6,6 +6,9 @@ import 'package:native_assets_cli/code_assets.dart';
void main(List<String> args) async {
await link(args, (LinkConfig config, LinkOutputBuilder output) async {
if (!config.supportedAssetTypes.contains(CodeAsset.type)) {
return;
}
final CodeAsset asset = config.codeAssets.single;
final String packageName = config.packageName;
output.codeAssets.add(